linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* "lib: rework bitmap_parse()" triggers invalid access errors
@ 2019-05-30 19:01 Qian Cai
  2019-06-04 18:23 ` Qian Cai
  0 siblings, 1 reply; 4+ messages in thread
From: Qian Cai @ 2019-05-30 19:01 UTC (permalink / raw)
  To: Yury Norov
  Cc: Andrey Konovalov, linux-kernel, Andy Shevchenko, Andrew Morton, linux-mm

The linux-next commit "lib: rework bitmap_parse" triggers errors below during
boot on both arm64 and powerpc with KASAN_SW_TAGS or SLUB_DEBUG enabled.

Reverted the commit and its dependency (lib: opencode in_str()) fixed the issue.

[   67.056867][ T3737] BUG kmalloc-16 (Tainted: G    B            ): Redzone
overwritten
[   67.056905][ T3737] -------------------------------------------------------
----------------------
[   67.056905][ T3737] 
[   67.056946][ T3737] INFO: 0x00000000bd269811-0x0000000039a2fb86. First byte
0x0 instead of 0xcc
[   67.056989][ T3737] INFO: Allocated in alloc_cpumask_var_node+0x38/0x80 age=0
cpu=62 pid=3737
[   67.057029][ T3737] 	__slab_alloc+0x34/0x60
[   67.057052][ T3737] 	__kmalloc_node+0x1a8/0x860
[   67.057086][ T3737] 	alloc_cpumask_var_node+0x38/0x80
[   67.057133][ T3737] 	write_irq_affinity.isra.0+0x84/0x1e0
[   67.057178][ T3737] 	proc_reg_write+0x90/0x130
[   67.057224][ T3737] 	__vfs_write+0x3c/0x70
[   67.057261][ T3737] 	vfs_write+0xd8/0x210
[   67.057292][ T3737] 	ksys_write+0x7c/0x140
[   67.057325][ T3737] 	system_call+0x5c/0x70
[   67.057355][ T3737] INFO: Freed in free_cpumask_var+0x18/0x30 age=0 cpu=62
pid=3737
[   67.057392][ T3737] 	free_cpumask_var+0x18/0x30
[   67.057427][ T3737] 	write_irq_affinity.isra.0+0x130/0x1e0
[   67.057464][ T3737] 	proc_reg_write+0x90/0x130
[   67.057525][ T3737] 	__vfs_write+0x3c/0x70
[   67.057558][ T3737] 	vfs_write+0xd8/0x210
[   67.057607][ T3737] 	ksys_write+0x7c/0x140
[   67.057643][ T3737] 	system_call+0x5c/0x70
[   67.057692][ T3737] INFO: Slab 0x00000000786814bb objects=186 used=49
fp=0x0000000019431596 flags=0x3fffc000000201
[   67.057810][ T3737] INFO: Object 0x000000005c0b6a3a @offset=25352
fp=0x00000000a42ffc35
[   67.057810][ T3737] 
[   67.057922][ T3737] Redzone 00000000d929958b: cc cc cc cc cc cc cc
cc                          ........
[   67.058024][ T3737] Object 000000005c0b6a3a: 00 00 00 00 00 00 00 04 00 00 00
00 00 00 00 00  ................
[   67.058171][ T3737] Redzone 00000000bd269811: 00 00 00 00 00 00 00
00                          ........
[   67.058283][ T3737] Padding 00000000b327be67: 5a 5a 5a 5a 5a 5a 5a
5a                          ZZZZZZZZ
[   67.058383][ T3737] CPU: 62 PID: 3737 Comm: irqbalance Tainted:
G    B             5.2.0-rc2-next-20190530 #13
[   67.058508][ T3737] Call Trace:
[   67.058531][ T3737] [c000001c4738f930] [c00000000089045c]
dump_stack+0xb0/0xf4 (unreliable)
[   67.058653][ T3737] [c000001c4738f970] [c0000000003dd368]
print_trailer+0x23c/0x264
[   67.058751][ T3737] [c000001c4738fa00] [c0000000003cd7d8]
check_bytes_and_report+0x138/0x160
[   67.058846][ T3737] [c000001c4738faa0] [c0000000003cfb9c]
check_object+0x2ac/0x3e0
[   67.058914][ T3737] [c000001c4738fb10] [c0000000003d646c]
free_debug_processing+0x1ec/0x680
[   67.059009][ T3737] [c000001c4738fc00] [c0000000003d6c54]
__slab_free+0x354/0x6d0
[   67.059113][ T3737] [c000001c4738fcc0] [c00000000088fda8]
free_cpumask_var+0x18/0x30
[   67.059205][ T3737] [c000001c4738fce0] [c0000000001c3fc0]
write_irq_affinity.isra.0+0x130/0x1e0
[   67.059324][ T3737] [c000001c4738fd30] [c00000000050c6b0]
proc_reg_write+0x90/0x130
[   67.059415][ T3737] [c000001c4738fd60] [c0000000004475ac]
__vfs_write+0x3c/0x70
[   67.059498][ T3737] [c000001c4738fd80] [c00000000044b0a8]
vfs_write+0xd8/0x210
[   67.059581][ T3737] [c000001c4738fdd0] [c00000000044b44c]
ksys_write+0x7c/0x140
[   67.059692][ T3737] [c000001c4738fe20] [c00000000000b108]
system_call+0x5c/0x70
[   67.059781][ T3737] FIX kmalloc-16: Restoring 0x00000000bd269811-
0x0000000039a2fb86=0xcc
[   67.059781][ T3737] 
[   67.059922][ T3737] FIX kmalloc-16: Object at 0x000000005c0b6a3a not freed


  185.039693][ T3647] BUG: KASAN: invalid-access in bitmap_parse+0x20c/0x2d8
[  185.039701][ T3647] Write of size 8 at addr 33ff809501263f20 by task
irqbalance/3647
[  185.039710][ T3647] Pointer tag: [33], memory tag: [fe]
[  185.056475][ T3647] 
[  185.056486][ T3647] CPU: 218 PID: 3647 Comm: irqbalance Tainted:
G        W         5.2.0-rc2-next-20190530+ #5
[  185.056491][ T3647] Hardware name: HPE Apollo
70             /C01_APACHE_MB         , BIOS L50_5.13_1.0.9 03/01/2019
[  185.056498][ T3647] Call trace:
[  185.079885][ T3647]  dump_backtrace+0x0/0x268
[  185.079896][ T3647]  show_stack+0x20/0x2c
[  185.092149][ T3647]  dump_stack+0xb4/0x108
[  185.092162][ T3647]  print_address_description+0x7c/0x330
[  185.092172][ T3647]  __kasan_report+0x194/0x1dc
[  185.116236][ T3647]  kasan_report+0x10/0x18
[  185.116243][ T3647]  __hwasan_store8_noabort+0x74/0x7c
[  185.116248][ T3647]  bitmap_parse+0x20c/0x2d8
[  185.116254][ T3647]  bitmap_parse_user+0x40/0x64
[  185.116268][ T3647]  write_irq_affinity+0x118/0x1a8
[  185.135032][ T3647]  irq_affinity_proc_write+0x34/0x44
[  185.135040][ T3647]  proc_reg_write+0xf4/0x130
[  185.135057][ T3647]  __vfs_write+0x88/0x33c
[  185.135067][ T3647]  vfs_write+0x118/0x208
[  185.144546][ T3647]  ksys_write+0xa0/0x110
[  185.158794][ T3647]  __arm64_sys_write+0x54/0x88
[  185.158811][ T3647]  el0_svc_handler+0x198/0x260
[  185.158820][ T3647]  el0_svc+0x8/0xc
[  185.172464][ T3647] 
[  185.172469][ T3647] Allocated by task 3647:
[  185.172476][ T3647]  __kasan_kmalloc+0x114/0x1d0
[  185.172481][ T3647]  kasan_kmalloc+0x10/0x18
[  185.172499][ T3647]  __kmalloc_node+0x1e0/0x7cc
[  185.192389][ T3647]  alloc_cpumask_var_node+0x48/0x94
[  185.192395][ T3647]  alloc_cpumask_var+0x10/0x1c
[  185.192400][ T3647]  write_irq_affinity+0xa8/0x1a8
[  185.192406][ T3647]  irq_affinity_proc_write+0x34/0x44
[  185.192415][ T3647]  proc_reg_write+0xf4/0x130
[  185.224744][ T3647]  __vfs_write+0x88/0x33c
[  185.224750][ T3647]  vfs_write+0x118/0x208
[  185.224756][ T3647]  ksys_write+0xa0/0x110
[  185.224766][ T3647]  __arm64_sys_write+0x54/0x88
[  185.258392][ T3647]  el0_svc_handler+0x198/0x260
[  185.258398][ T3647]  el0_svc+0x8/0xc
[  185.258401][ T3647] 
[  185.258405][ T3647] Freed by task 3647:
[  185.258411][ T3647]  __kasan_slab_free+0x154/0x228
[  185.258417][ T3647]  kasan_slab_free+0xc/0x18
[  185.258422][ T3647]  kfree+0x268/0xb70
[  185.258428][ T3647]  free_cpumask_var+0xc/0x14
[  185.258446][ T3647]  write_irq_affinity+0x19c/0x1a8
[  185.273666][ T3647]  irq_affinity_proc_write+0x34/0x44
[  185.273675][ T3647]  proc_reg_write+0xf4/0x130
[  185.288620][ T3647]  __vfs_write+0x88/0x33c
[  185.288626][ T3647]  vfs_write+0x118/0x208
[  185.288632][ T3647]  ksys_write+0xa0/0x110
[  185.288645][ T3647]  __arm64_sys_write+0x54/0x88
[  185.303075][ T3647]  el0_svc_handler+0x198/0x260
[  185.303081][ T3647]  el0_svc+0x8/0xc
[  185.303084][ T3647] 
[  185.303091][ T3647] The buggy address belongs to the object at
ffff809501263f00
[  185.303091][ T3647]  which belongs to the cache kmalloc-128 of size 128
[  185.303103][ T3647] The buggy address is located 32 bytes inside of
[  185.303103][ T3647]  128-byte region [ffff809501263f00, ffff809501263f80)
[  185.331347][ T3647] The buggy address belongs to the page:
[  185.331356][ T3647] page:ffff7fe025404980 refcount:1 mapcount:0
mapping:7fff800800010480 index:0xaff809501267d80
[  185.331365][ T3647] flags: 0x17ffffffc000200(slab)
[  185.331377][ T3647] raw: 017ffffffc000200 ffff7fe025997308 e5ff808b7d00fd40
7fff800800010480
[  185.350500][ T3647] raw: 19ff80950126aa80 0000000000660059 00000001ffffffff
0000000000000000
[  185.350505][ T3647] page dumped because: kasan: bad access detected
[  185.350514][ T3647] page allocated via order 0, migratetype Unmovable,
gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY)
[  185.350535][ T3647]  prep_new_page+0x2ec/0x388
[  185.364704][ T3647]  get_page_from_freelist+0x2530/0x27fc
[  185.364711][ T3647]  __alloc_pages_nodemask+0x360/0x1c60
[  185.364719][ T3647]  new_slab+0x108/0x9d4
[  185.364725][ T3647]  ___slab_alloc+0x57c/0x9e4
[  185.364735][ T3647]  __kmalloc_node+0x734/0x7cc
[  185.382050][ T3647]  alloc_rt_sched_group+0x17c/0x258
[  185.382070][ T3647]  sched_create_group+0x54/0x9c
[  185.382090][ T3647]  sched_autogroup_create_attach+0x40/0x1f0
[  185.494511][ T3647]  ksys_setsid+0x158/0x15c
[  185.494517][ T3647]  __arm64_sys_setsid+0x10/0x1c
[  185.494524][ T3647]  el0_svc_handler+0x198/0x260
[  185.494529][ T3647]  el0_svc+0x8/0xc
[  185.494532][ T3647] 
[  185.494536][ T3647] Memory state around the buggy address:
[  185.494549][ T3647]  ffff809501263d00: fe fe fe fe fe fe fe fe fe fe fe fe fe
fe fe fe
[  185.514973][ T3647]  ffff809501263e00: fe fe fe fe fe fe fe fe fe fe fe fe fe
fe fe fe
[  185.514979][ T3647] >ffff809501263f00: 33 33 fe fe fe fe fe fe fe fe fe fe fe
fe fe fe
[  185.514982][ T3647]                          ^
[  185.514988][ T3647]  ffff809501264000: fe fe fe fe fe fe fe fe fe fe fe fe fe
fe fe fe
[  185.514997][ T3647]  ffff809501264100: fe fe fe fe fe fe fe fe 36 36 36 36 36
36 36 36


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "lib: rework bitmap_parse()" triggers invalid access errors
  2019-05-30 19:01 "lib: rework bitmap_parse()" triggers invalid access errors Qian Cai
@ 2019-06-04 18:23 ` Qian Cai
       [not found]   ` <BN6PR1801MB20655CFFEA0CEA242C088C25CB160@BN6PR1801MB2065.namprd18.prod.outlook.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Qian Cai @ 2019-06-04 18:23 UTC (permalink / raw)
  To: Yury Norov
  Cc: Andrey Konovalov, linux-kernel, Andy Shevchenko, Andrew Morton, linux-mm

BTW, this problem below is still reproducible after applied the series [1] on
the top of today's linux-next tree "next-20190604" which has already included
the patch for the "Bad swap file entry" issue.

[1] https://lore.kernel.org/lkml/20190501010636.30595-1-ynorov@marvell.com/

On Thu, 2019-05-30 at 15:01 -0400, Qian Cai wrote:
> The linux-next commit "lib: rework bitmap_parse" triggers errors below during
> boot on both arm64 and powerpc with KASAN_SW_TAGS or SLUB_DEBUG enabled.
> 
> Reverted the commit and its dependency (lib: opencode in_str()) fixed the
> issue.
> 
> [   67.056867][ T3737] BUG kmalloc-16 (Tainted: G    B            ): Redzone
> overwritten
> [   67.056905][ T3737] -------------------------------------------------------
> ----------------------
> [   67.056905][ T3737] 
> [   67.056946][ T3737] INFO: 0x00000000bd269811-0x0000000039a2fb86. First byte
> 0x0 instead of 0xcc
> [   67.056989][ T3737] INFO: Allocated in alloc_cpumask_var_node+0x38/0x80
> age=0
> cpu=62 pid=3737
> [   67.057029][ T3737] 	__slab_alloc+0x34/0x60
> [   67.057052][ T3737] 	__kmalloc_node+0x1a8/0x860
> [   67.057086][ T3737] 	alloc_cpumask_var_node+0x38/0x80
> [   67.057133][ T3737] 	write_irq_affinity.isra.0+0x84/0x1e0
> [   67.057178][ T3737] 	proc_reg_write+0x90/0x130
> [   67.057224][ T3737] 	__vfs_write+0x3c/0x70
> [   67.057261][ T3737] 	vfs_write+0xd8/0x210
> [   67.057292][ T3737] 	ksys_write+0x7c/0x140
> [   67.057325][ T3737] 	system_call+0x5c/0x70
> [   67.057355][ T3737] INFO: Freed in free_cpumask_var+0x18/0x30 age=0 cpu=62
> pid=3737
> [   67.057392][ T3737] 	free_cpumask_var+0x18/0x30
> [   67.057427][ T3737] 	write_irq_affinity.isra.0+0x130/0x1e0
> [   67.057464][ T3737] 	proc_reg_write+0x90/0x130
> [   67.057525][ T3737] 	__vfs_write+0x3c/0x70
> [   67.057558][ T3737] 	vfs_write+0xd8/0x210
> [   67.057607][ T3737] 	ksys_write+0x7c/0x140
> [   67.057643][ T3737] 	system_call+0x5c/0x70
> [   67.057692][ T3737] INFO: Slab 0x00000000786814bb objects=186 used=49
> fp=0x0000000019431596 flags=0x3fffc000000201
> [   67.057810][ T3737] INFO: Object 0x000000005c0b6a3a @offset=25352
> fp=0x00000000a42ffc35
> [   67.057810][ T3737] 
> [   67.057922][ T3737] Redzone 00000000d929958b: cc cc cc cc cc cc cc
> cc                          ........
> [   67.058024][ T3737] Object 000000005c0b6a3a: 00 00 00 00 00 00 00 04 00 00
> 00
> 00 00 00 00 00  ................
> [   67.058171][ T3737] Redzone 00000000bd269811: 00 00 00 00 00 00 00
> 00                          ........
> [   67.058283][ T3737] Padding 00000000b327be67: 5a 5a 5a 5a 5a 5a 5a
> 5a                          ZZZZZZZZ
> [   67.058383][ T3737] CPU: 62 PID: 3737 Comm: irqbalance Tainted:
> G    B             5.2.0-rc2-next-20190530 #13
> [   67.058508][ T3737] Call Trace:
> [   67.058531][ T3737] [c000001c4738f930] [c00000000089045c]
> dump_stack+0xb0/0xf4 (unreliable)
> [   67.058653][ T3737] [c000001c4738f970] [c0000000003dd368]
> print_trailer+0x23c/0x264
> [   67.058751][ T3737] [c000001c4738fa00] [c0000000003cd7d8]
> check_bytes_and_report+0x138/0x160
> [   67.058846][ T3737] [c000001c4738faa0] [c0000000003cfb9c]
> check_object+0x2ac/0x3e0
> [   67.058914][ T3737] [c000001c4738fb10] [c0000000003d646c]
> free_debug_processing+0x1ec/0x680
> [   67.059009][ T3737] [c000001c4738fc00] [c0000000003d6c54]
> __slab_free+0x354/0x6d0
> [   67.059113][ T3737] [c000001c4738fcc0] [c00000000088fda8]
> free_cpumask_var+0x18/0x30
> [   67.059205][ T3737] [c000001c4738fce0] [c0000000001c3fc0]
> write_irq_affinity.isra.0+0x130/0x1e0
> [   67.059324][ T3737] [c000001c4738fd30] [c00000000050c6b0]
> proc_reg_write+0x90/0x130
> [   67.059415][ T3737] [c000001c4738fd60] [c0000000004475ac]
> __vfs_write+0x3c/0x70
> [   67.059498][ T3737] [c000001c4738fd80] [c00000000044b0a8]
> vfs_write+0xd8/0x210
> [   67.059581][ T3737] [c000001c4738fdd0] [c00000000044b44c]
> ksys_write+0x7c/0x140
> [   67.059692][ T3737] [c000001c4738fe20] [c00000000000b108]
> system_call+0x5c/0x70
> [   67.059781][ T3737] FIX kmalloc-16: Restoring 0x00000000bd269811-
> 0x0000000039a2fb86=0xcc
> [   67.059781][ T3737] 
> [   67.059922][ T3737] FIX kmalloc-16: Object at 0x000000005c0b6a3a not freed
> 
> 
>   185.039693][ T3647] BUG: KASAN: invalid-access in bitmap_parse+0x20c/0x2d8
> [  185.039701][ T3647] Write of size 8 at addr 33ff809501263f20 by task
> irqbalance/3647
> [  185.039710][ T3647] Pointer tag: [33], memory tag: [fe]
> [  185.056475][ T3647] 
> [  185.056486][ T3647] CPU: 218 PID: 3647 Comm: irqbalance Tainted:
> G        W         5.2.0-rc2-next-20190530+ #5
> [  185.056491][ T3647] Hardware name: HPE Apollo
> 70             /C01_APACHE_MB         , BIOS L50_5.13_1.0.9 03/01/2019
> [  185.056498][ T3647] Call trace:
> [  185.079885][ T3647]  dump_backtrace+0x0/0x268
> [  185.079896][ T3647]  show_stack+0x20/0x2c
> [  185.092149][ T3647]  dump_stack+0xb4/0x108
> [  185.092162][ T3647]  print_address_description+0x7c/0x330
> [  185.092172][ T3647]  __kasan_report+0x194/0x1dc
> [  185.116236][ T3647]  kasan_report+0x10/0x18
> [  185.116243][ T3647]  __hwasan_store8_noabort+0x74/0x7c
> [  185.116248][ T3647]  bitmap_parse+0x20c/0x2d8
> [  185.116254][ T3647]  bitmap_parse_user+0x40/0x64
> [  185.116268][ T3647]  write_irq_affinity+0x118/0x1a8
> [  185.135032][ T3647]  irq_affinity_proc_write+0x34/0x44
> [  185.135040][ T3647]  proc_reg_write+0xf4/0x130
> [  185.135057][ T3647]  __vfs_write+0x88/0x33c
> [  185.135067][ T3647]  vfs_write+0x118/0x208
> [  185.144546][ T3647]  ksys_write+0xa0/0x110
> [  185.158794][ T3647]  __arm64_sys_write+0x54/0x88
> [  185.158811][ T3647]  el0_svc_handler+0x198/0x260
> [  185.158820][ T3647]  el0_svc+0x8/0xc
> [  185.172464][ T3647] 
> [  185.172469][ T3647] Allocated by task 3647:
> [  185.172476][ T3647]  __kasan_kmalloc+0x114/0x1d0
> [  185.172481][ T3647]  kasan_kmalloc+0x10/0x18
> [  185.172499][ T3647]  __kmalloc_node+0x1e0/0x7cc
> [  185.192389][ T3647]  alloc_cpumask_var_node+0x48/0x94
> [  185.192395][ T3647]  alloc_cpumask_var+0x10/0x1c
> [  185.192400][ T3647]  write_irq_affinity+0xa8/0x1a8
> [  185.192406][ T3647]  irq_affinity_proc_write+0x34/0x44
> [  185.192415][ T3647]  proc_reg_write+0xf4/0x130
> [  185.224744][ T3647]  __vfs_write+0x88/0x33c
> [  185.224750][ T3647]  vfs_write+0x118/0x208
> [  185.224756][ T3647]  ksys_write+0xa0/0x110
> [  185.224766][ T3647]  __arm64_sys_write+0x54/0x88
> [  185.258392][ T3647]  el0_svc_handler+0x198/0x260
> [  185.258398][ T3647]  el0_svc+0x8/0xc
> [  185.258401][ T3647] 
> [  185.258405][ T3647] Freed by task 3647:
> [  185.258411][ T3647]  __kasan_slab_free+0x154/0x228
> [  185.258417][ T3647]  kasan_slab_free+0xc/0x18
> [  185.258422][ T3647]  kfree+0x268/0xb70
> [  185.258428][ T3647]  free_cpumask_var+0xc/0x14
> [  185.258446][ T3647]  write_irq_affinity+0x19c/0x1a8
> [  185.273666][ T3647]  irq_affinity_proc_write+0x34/0x44
> [  185.273675][ T3647]  proc_reg_write+0xf4/0x130
> [  185.288620][ T3647]  __vfs_write+0x88/0x33c
> [  185.288626][ T3647]  vfs_write+0x118/0x208
> [  185.288632][ T3647]  ksys_write+0xa0/0x110
> [  185.288645][ T3647]  __arm64_sys_write+0x54/0x88
> [  185.303075][ T3647]  el0_svc_handler+0x198/0x260
> [  185.303081][ T3647]  el0_svc+0x8/0xc
> [  185.303084][ T3647] 
> [  185.303091][ T3647] The buggy address belongs to the object at
> ffff809501263f00
> [  185.303091][ T3647]  which belongs to the cache kmalloc-128 of size 128
> [  185.303103][ T3647] The buggy address is located 32 bytes inside of
> [  185.303103][ T3647]  128-byte region [ffff809501263f00, ffff809501263f80)
> [  185.331347][ T3647] The buggy address belongs to the page:
> [  185.331356][ T3647] page:ffff7fe025404980 refcount:1 mapcount:0
> mapping:7fff800800010480 index:0xaff809501267d80
> [  185.331365][ T3647] flags: 0x17ffffffc000200(slab)
> [  185.331377][ T3647] raw: 017ffffffc000200 ffff7fe025997308 e5ff808b7d00fd40
> 7fff800800010480
> [  185.350500][ T3647] raw: 19ff80950126aa80 0000000000660059 00000001ffffffff
> 0000000000000000
> [  185.350505][ T3647] page dumped because: kasan: bad access detected
> [  185.350514][ T3647] page allocated via order 0, migratetype Unmovable,
> gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY)
> [  185.350535][ T3647]  prep_new_page+0x2ec/0x388
> [  185.364704][ T3647]  get_page_from_freelist+0x2530/0x27fc
> [  185.364711][ T3647]  __alloc_pages_nodemask+0x360/0x1c60
> [  185.364719][ T3647]  new_slab+0x108/0x9d4
> [  185.364725][ T3647]  ___slab_alloc+0x57c/0x9e4
> [  185.364735][ T3647]  __kmalloc_node+0x734/0x7cc
> [  185.382050][ T3647]  alloc_rt_sched_group+0x17c/0x258
> [  185.382070][ T3647]  sched_create_group+0x54/0x9c
> [  185.382090][ T3647]  sched_autogroup_create_attach+0x40/0x1f0
> [  185.494511][ T3647]  ksys_setsid+0x158/0x15c
> [  185.494517][ T3647]  __arm64_sys_setsid+0x10/0x1c
> [  185.494524][ T3647]  el0_svc_handler+0x198/0x260
> [  185.494529][ T3647]  el0_svc+0x8/0xc
> [  185.494532][ T3647] 
> [  185.494536][ T3647] Memory state around the buggy address:
> [  185.494549][ T3647]  ffff809501263d00: fe fe fe fe fe fe fe fe fe fe fe fe
> fe
> fe fe fe
> [  185.514973][ T3647]  ffff809501263e00: fe fe fe fe fe fe fe fe fe fe fe fe
> fe
> fe fe fe
> [  185.514979][ T3647] >ffff809501263f00: 33 33 fe fe fe fe fe fe fe fe fe fe
> fe
> fe fe fe
> [  185.514982][ T3647]                          ^
> [  185.514988][ T3647]  ffff809501264000: fe fe fe fe fe fe fe fe fe fe fe fe
> fe
> fe fe fe
> [  185.514997][ T3647]  ffff809501264100: fe fe fe fe fe fe fe fe 36 36 36 36
> 36
> 36 36 36
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "lib: rework bitmap_parse()" triggers invalid access errors
       [not found]   ` <BN6PR1801MB20655CFFEA0CEA242C088C25CB160@BN6PR1801MB2065.namprd18.prod.outlook.com>
@ 2019-06-06 16:09     ` Qian Cai
  2019-06-07  1:57       ` Yury Norov
  0 siblings, 1 reply; 4+ messages in thread
From: Qian Cai @ 2019-06-06 16:09 UTC (permalink / raw)
  To: Yuri Norov
  Cc: Andrey Konovalov, linux-kernel, Andy Shevchenko, Andrew Morton,
	linux-mm, Yury Norov

On Wed, 2019-06-05 at 08:01 +0000, Yuri Norov wrote:
> (Sorry for top-posting)
> 
> I can reproduce this on next-20190604. Is it new trace, or like one you've
> posted before?

Same thing, "nbits" causes an invalid access.

# ./scripts/faddr2line vmlinux bitmap_parse+0x20c/0x2d8
bitmap_parse+0x20c/0x2d8:
__bitmap_clear at lib/bitmap.c:280
(inlined by) bitmap_clear at include/linux/bitmap.h:390
(inlined by) bitmap_parse at lib/bitmap.c:662

This line,

while (len - bits_to_clear >= 0) {

[  151.025490][ T3745]
==================================================================
[  151.033437][ T3745] BUG: KASAN: invalid-access in bitmap_parse+0x20c/0x2d8
[  151.040313][ T3745] Write of size 8 at addr 88ff80961f5637a0 by task
irqbalance/3745
[  151.048052][ T3745] Pointer tag: [88], memory tag: [fe]
[  151.053272][ T3745] 
[  151.055462][ T3745] CPU: 191 PID: 3745 Comm: irqbalance Tainted:
G        W         5.2.0-rc3-next-20190606+ #2
[  151.065548][ T3745] Hardware name: HPE Apollo
70             /C01_APACHE_MB         , BIOS L50_5.13_1.0.9 03/01/2019
[  151.076064][ T3745] Call trace:
[  151.079218][ T3745]  dump_backtrace+0x0/0x268
[  151.083574][ T3745]  show_stack+0x20/0x2c
[  151.087589][ T3745]  dump_stack+0xb4/0x108
[  151.091691][ T3745]  print_address_description+0x7c/0x330
[  151.097088][ T3745]  __kasan_report+0x194/0x1dc
[  151.101616][ T3745]  kasan_report+0x10/0x18
[  151.105799][ T3745]  __hwasan_store8_noabort+0x74/0x7c
[  151.110935][ T3745]  bitmap_parse+0x20c/0x2d8
[  151.115291][ T3745]  bitmap_parse_user+0x40/0x64
[  151.119910][ T3745]  write_irq_affinity+0x118/0x1a8
[  151.124786][ T3745]  irq_affinity_proc_write+0x34/0x44
[  151.129925][ T3745]  proc_reg_write+0xf4/0x130
[  151.134376][ T3745]  __vfs_write+0x88/0x33c
[  151.138561][ T3745]  vfs_write+0x118/0x208
[  151.142656][ T3745]  ksys_write+0xa0/0x110
[  151.146752][ T3745]  __arm64_sys_write+0x54/0x88
[  151.151377][ T3745]  el0_svc_handler+0x198/0x260
[  151.155992][ T3745]  el0_svc+0x8/0xc
[  151.159566][ T3745] 
[  151.161751][ T3745] Allocated by task 3745:
[  151.165933][ T3745]  __kasan_kmalloc+0x114/0x1d0
[  151.170553][ T3745]  kasan_kmalloc+0x10/0x18
[  151.174830][ T3745]  __kmalloc_node+0x1e0/0x788
[  151.179358][ T3745]  alloc_cpumask_var_node+0x48/0x94
[  151.184407][ T3745]  alloc_cpumask_var+0x10/0x1c
[  151.189022][ T3745]  write_irq_affinity+0xa8/0x1a8
[  151.193811][ T3745]  irq_affinity_proc_write+0x34/0x44
[  151.198947][ T3745]  proc_reg_write+0xf4/0x130
[  151.203389][ T3745]  __vfs_write+0x88/0x33c
[  151.207573][ T3745]  vfs_write+0x118/0x208
[  151.211668][ T3745]  ksys_write+0xa0/0x110
[  151.215764][ T3745]  __arm64_sys_write+0x54/0x88
[  151.220380][ T3745]  el0_svc_handler+0x198/0x260
[  151.224996][ T3745]  el0_svc+0x8/0xc
[  151.228566][ T3745] 
[  151.230749][ T3745] Freed by task 3745:
[  151.234585][ T3745]  __kasan_slab_free+0x154/0x228
[  151.239374][ T3745]  kasan_slab_free+0xc/0x18
[  151.243729][ T3745]  kfree+0x268/0xb70
[  151.247484][ T3745]  free_cpumask_var+0xc/0x14
[  151.251932][ T3745]  write_irq_affinity+0x19c/0x1a8
[  151.256807][ T3745]  irq_affinity_proc_write+0x34/0x44
[  151.261943][ T3745]  proc_reg_write+0xf4/0x130
[  151.266386][ T3745]  __vfs_write+0x88/0x33c
[  151.270567][ T3745]  vfs_write+0x118/0x208
[  151.274661][ T3745]  ksys_write+0xa0/0x110
[  151.278756][ T3745]  __arm64_sys_write+0x54/0x88
[  151.283371][ T3745]  el0_svc_handler+0x198/0x260
[  151.287986][ T3745]  el0_svc+0x8/0xc
[  151.291556][ T3745] 
[  151.293742][ T3745] The buggy address belongs to the object at
ffff80961f563780
[  151.293742][ T3745]  which belongs to the cache kmalloc-128 of size 128
[  151.307647][ T3745] The buggy address is located 32 bytes inside of
[  151.307647][ T3745]  128-byte region [ffff80961f563780, ffff80961f563800)
[  151.320681][ T3745] The buggy address belongs to the page:
[  151.326167][ T3745] page:ffff7fe02587d580 refcount:1 mapcount:0
mapping:fdff800800010480 index:0x8aff80961f56dc80
[  151.336429][ T3745] flags: 0x17ffffffc000200(slab)
[  151.341222][ T3745] raw: 017ffffffc000200 ffff7fe025843788 e3ff808b7d00fd40
fdff800800010480
[  151.349659][ T3745] raw: 8aff80961f56dc80 000000000066001d 00000001ffffffff
0000000000000000
[  151.358092][ T3745] page dumped because: kasan: bad access detected
[  151.364361][ T3745] page allocated via order 0, migratetype Unmovable,
gfp_mask 0x12800(GFP_NOWAIT|__GFP_NOWARN|__GFP_NORETRY)
[  151.375757][ T3745]  prep_new_page+0x2f4/0x378
[  151.380201][ T3745]  get_page_from_freelist+0x253c/0x2868
[  151.385598][ T3745]  __alloc_pages_nodemask+0x360/0x1c60
[  151.390908][ T3745]  alloc_pages_current+0xd0/0xe0
[  151.395699][ T3745]  new_slab+0x15c/0x9d4
[  151.399707][ T3745]  ___slab_alloc+0x57c/0x9e4
[  151.404148][ T3745]  __kmalloc+0x58c/0x5e0
[  151.408247][ T3745]  memcg_kmem_get_cache+0x150/0x65c
[  151.413296][ T3745]  kmem_cache_alloc+0x208/0x568
[  151.418010][ T3745]  __anon_vma_prepare+0x60/0x210
[  151.422799][ T3745]  do_fault+0xc64/0xf80
[  151.426807][ T3745]  handle_pte_fault+0x4e4/0x15e8
[  151.431597][ T3745]  handle_mm_fault+0x6a4/0x95c
[  151.436216][ T3745]  do_page_fault+0x4a0/0x770
[  151.440657][ T3745]  do_translation_fault+0x60/0xa0
[  151.445537][ T3745]  do_mem_abort+0x58/0xf4
[  151.449715][ T3745] 
[  151.451897][ T3745] Memory state around the buggy address:
[  151.457381][ T3745]  ffff80961f563500: 93 93 93 93 93 93 93 93 fe fe fe fe fe
fe fe fe
[  151.465295][ T3745]  ffff80961f563600: fe fe fe fe fe fe fe fe fe fe fe fe fe
fe fe fe
[  151.473209][ T3745] >ffff80961f563700: fe fe fe fe fe fe fe fe 88 88 fe fe fe
fe fe fe
[  151.481120][ T3745]                                                  ^
[  151.487645][ T3745]  ffff80961f563800: fe fe fe fe fe fe fe fe fe fe fe fe fe
fe fe fe
[  151.495562][ T3745]  ffff80961f563900: fe fe fe fe fe fe fe fe fe fe fe fe fe
fe fe fe
[  151.503481][ T3745]
==================================================================
[  151.511399][ T3745] Disabling lock debugging due to kernel taint


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "lib: rework bitmap_parse()" triggers invalid access errors
  2019-06-06 16:09     ` Qian Cai
@ 2019-06-07  1:57       ` Yury Norov
  0 siblings, 0 replies; 4+ messages in thread
From: Yury Norov @ 2019-06-07  1:57 UTC (permalink / raw)
  To: Qian Cai, g
  Cc: Yuri Norov, Andrey Konovalov, linux-kernel, Andy Shevchenko,
	Andrew Morton, linux-mm

On Thu, Jun 06, 2019 at 12:09:46PM -0400, Qian Cai wrote:
> On Wed, 2019-06-05 at 08:01 +0000, Yuri Norov wrote:
> > (Sorry for top-posting)
> > 
> > I can reproduce this on next-20190604. Is it new trace, or like one you've
> > posted before?
> 
> Same thing, "nbits" causes an invalid access.
> 
> # ./scripts/faddr2line vmlinux bitmap_parse+0x20c/0x2d8
> bitmap_parse+0x20c/0x2d8:
> __bitmap_clear at lib/bitmap.c:280
> (inlined by) bitmap_clear at include/linux/bitmap.h:390
> (inlined by) bitmap_parse at lib/bitmap.c:662
> 
> This line,
> 
> while (len - bits_to_clear >= 0) {

[...]

The problem is in my code, and the fix is:

diff --git a/lib/bitmap.c b/lib/bitmap.c
index ebcf4700ebed..6b3e921f4e91 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -664,7 +664,7 @@ int bitmap_parse(const char *start, unsigned int buflen,
 
 	unset_bit = (BITS_TO_U32(nmaskbits) - chunks) * 32;
 	if (unset_bit < nmaskbits) {
-		bitmap_clear(maskp, unset_bit, nmaskbits);
+		bitmap_clear(maskp, unset_bit, nmaskbits - unset_bit);
 		return 0;
 	}
 
I'll add a test for this case and submit v3 soon.

Yury

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-07  1:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30 19:01 "lib: rework bitmap_parse()" triggers invalid access errors Qian Cai
2019-06-04 18:23 ` Qian Cai
     [not found]   ` <BN6PR1801MB20655CFFEA0CEA242C088C25CB160@BN6PR1801MB2065.namprd18.prod.outlook.com>
2019-06-06 16:09     ` Qian Cai
2019-06-07  1:57       ` Yury Norov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).