Re: "lib: rework bitmap_parse()" triggers invalid access errors
From: Qian Cai
Date: Tue Jun 04 2019 - 14:27:16 EST
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@xxxxxxxxxxx/
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
>