Hay
Date
Nov. 27, 2024, 3:37 a.m.

Environment
qemu-arm64
qemu-x86_64

[   48.243918] ==================================================================
[   48.245548] BUG: KASAN: slab-use-after-free in kmalloc_uaf_memset+0x170/0x310
[   48.246189] Write of size 33 at addr fff00000c616ad00 by task kunit_try_catch/175
[   48.247790] 
[   48.248268] CPU: 0 UID: 0 PID: 175 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241127 #1
[   48.250176] Tainted: [B]=BAD_PAGE, [N]=TEST
[   48.250837] Hardware name: linux,dummy-virt (DT)
[   48.251529] Call trace:
[   48.252098]  show_stack+0x20/0x38 (C)
[   48.252795]  dump_stack_lvl+0x8c/0xd0
[   48.253641]  print_report+0x118/0x5e0
[   48.254664]  kasan_report+0xc8/0x118
[   48.255440]  kasan_check_range+0x100/0x1a8
[   48.256310]  __asan_memset+0x34/0x78
[   48.256857]  kmalloc_uaf_memset+0x170/0x310
[   48.257920]  kunit_try_run_case+0x14c/0x3d0
[   48.258697]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   48.259375]  kthread+0x24c/0x2d0
[   48.259987]  ret_from_fork+0x10/0x20
[   48.260544] 
[   48.260876] Allocated by task 175:
[   48.261748]  kasan_save_stack+0x3c/0x68
[   48.262379]  kasan_save_track+0x20/0x40
[   48.262934]  kasan_save_alloc_info+0x40/0x58
[   48.264226]  __kasan_kmalloc+0xd4/0xd8
[   48.264741]  __kmalloc_cache_noprof+0x15c/0x3c0
[   48.265916]  kmalloc_uaf_memset+0xb8/0x310
[   48.266523]  kunit_try_run_case+0x14c/0x3d0
[   48.267080]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   48.267739]  kthread+0x24c/0x2d0
[   48.268314]  ret_from_fork+0x10/0x20
[   48.268797] 
[   48.269132] Freed by task 175:
[   48.270213]  kasan_save_stack+0x3c/0x68
[   48.271044]  kasan_save_track+0x20/0x40
[   48.271588]  kasan_save_free_info+0x4c/0x78
[   48.272454]  __kasan_slab_free+0x6c/0x98
[   48.272863]  kfree+0x114/0x3c8
[   48.273965]  kmalloc_uaf_memset+0x11c/0x310
[   48.274605]  kunit_try_run_case+0x14c/0x3d0
[   48.275196]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   48.275849]  kthread+0x24c/0x2d0
[   48.276515]  ret_from_fork+0x10/0x20
[   48.277009] 
[   48.277319] The buggy address belongs to the object at fff00000c616ad00
[   48.277319]  which belongs to the cache kmalloc-64 of size 64
[   48.279615] The buggy address is located 0 bytes inside of
[   48.279615]  freed 64-byte region [fff00000c616ad00, fff00000c616ad40)
[   48.280851] 
[   48.281519] The buggy address belongs to the physical page:
[   48.282043] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10616a
[   48.282953] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   48.283877] page_type: f5(slab)
[   48.284393] raw: 0bfffe0000000000 fff00000c00018c0 dead000000000122 0000000000000000
[   48.285406] raw: 0000000000000000 0000000080200020 00000001f5000000 0000000000000000
[   48.286441] page dumped because: kasan: bad access detected
[   48.287259] 
[   48.287584] Memory state around the buggy address:
[   48.288323]  fff00000c616ac00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
[   48.289436]  fff00000c616ac80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   48.290385] >fff00000c616ad00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   48.290806]                    ^
[   48.291047]  fff00000c616ad80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   48.291972]  fff00000c616ae00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   48.292730] ==================================================================

[   25.479808] ==================================================================
[   25.480854] BUG: KASAN: slab-use-after-free in kmalloc_uaf_memset+0x1a4/0x360
[   25.481746] Write of size 33 at addr ffff888101a9ef00 by task kunit_try_catch/194
[   25.482552] 
[   25.482725] CPU: 1 UID: 0 PID: 194 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241127 #1
[   25.483538] Tainted: [B]=BAD_PAGE, [N]=TEST
[   25.484066] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   25.485380] Call Trace:
[   25.485680]  <TASK>
[   25.486196]  dump_stack_lvl+0x73/0xb0
[   25.486649]  print_report+0xd1/0x640
[   25.487185]  ? __virt_addr_valid+0x1db/0x2d0
[   25.487547]  ? kasan_complete_mode_report_info+0x64/0x200
[   25.488279]  kasan_report+0x102/0x140
[   25.488678]  ? kmalloc_uaf_memset+0x1a4/0x360
[   25.489373]  ? kmalloc_uaf_memset+0x1a4/0x360
[   25.489743]  kasan_check_range+0x10c/0x1c0
[   25.490252]  __asan_memset+0x27/0x50
[   25.490705]  kmalloc_uaf_memset+0x1a4/0x360
[   25.491259]  ? __pfx_kmalloc_uaf_memset+0x10/0x10
[   25.491677]  ? __schedule+0xc3e/0x2790
[   25.492214]  ? __pfx_read_tsc+0x10/0x10
[   25.492653]  ? ktime_get_ts64+0x84/0x230
[   25.493183]  kunit_try_run_case+0x1b3/0x490
[   25.493644]  ? __pfx_kunit_try_run_case+0x10/0x10
[   25.494192]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   25.494837]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   25.495358]  ? __kthread_parkme+0x82/0x160
[   25.495907]  ? preempt_count_sub+0x50/0x80
[   25.496332]  ? __pfx_kunit_try_run_case+0x10/0x10
[   25.496942]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   25.497526]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   25.498173]  kthread+0x257/0x310
[   25.498598]  ? __pfx_kthread+0x10/0x10
[   25.498891]  ret_from_fork+0x41/0x80
[   25.499398]  ? __pfx_kthread+0x10/0x10
[   25.499800]  ret_from_fork_asm+0x1a/0x30
[   25.500365]  </TASK>
[   25.500664] 
[   25.500923] Allocated by task 194:
[   25.501307]  kasan_save_stack+0x3d/0x60
[   25.501734]  kasan_save_track+0x18/0x40
[   25.502339]  kasan_save_alloc_info+0x3b/0x50
[   25.502713]  __kasan_kmalloc+0xb7/0xc0
[   25.503219]  __kmalloc_cache_noprof+0x184/0x410
[   25.503660]  kmalloc_uaf_memset+0xaa/0x360
[   25.504259]  kunit_try_run_case+0x1b3/0x490
[   25.504770]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   25.505395]  kthread+0x257/0x310
[   25.505864]  ret_from_fork+0x41/0x80
[   25.506235]  ret_from_fork_asm+0x1a/0x30
[   25.506813] 
[   25.507161] Freed by task 194:
[   25.507432]  kasan_save_stack+0x3d/0x60
[   25.508061]  kasan_save_track+0x18/0x40
[   25.508527]  kasan_save_free_info+0x3f/0x60
[   25.508892]  __kasan_slab_free+0x56/0x70
[   25.509494]  kfree+0x123/0x3f0
[   25.509776]  kmalloc_uaf_memset+0x12c/0x360
[   25.510363]  kunit_try_run_case+0x1b3/0x490
[   25.510799]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   25.511375]  kthread+0x257/0x310
[   25.511796]  ret_from_fork+0x41/0x80
[   25.512218]  ret_from_fork_asm+0x1a/0x30
[   25.512780] 
[   25.513069] The buggy address belongs to the object at ffff888101a9ef00
[   25.513069]  which belongs to the cache kmalloc-64 of size 64
[   25.514082] The buggy address is located 0 bytes inside of
[   25.514082]  freed 64-byte region [ffff888101a9ef00, ffff888101a9ef40)
[   25.515266] 
[   25.515453] The buggy address belongs to the physical page:
[   25.516001] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x101a9e
[   25.516801] flags: 0x200000000000000(node=0|zone=2)
[   25.517404] page_type: f5(slab)
[   25.517670] raw: 0200000000000000 ffff8881000418c0 dead000000000122 0000000000000000
[   25.518601] raw: 0000000000000000 0000000080200020 00000001f5000000 0000000000000000
[   25.519513] page dumped because: kasan: bad access detected
[   25.519952] 
[   25.520261] Memory state around the buggy address:
[   25.520826]  ffff888101a9ee00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   25.521584]  ffff888101a9ee80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   25.522212] >ffff888101a9ef00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   25.522951]                    ^
[   25.523401]  ffff888101a9ef80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   25.524111]  ffff888101a9f000: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   25.524722] ==================================================================