Hay
Date
Dec. 9, 2024, 6:35 a.m.

Environment
qemu-arm64
qemu-x86_64

[   24.625111] ==================================================================
[   24.626102] BUG: KASAN: slab-use-after-free in kmalloc_uaf_memset+0x170/0x310
[   24.626913] Write of size 33 at addr fff00000c125ae00 by task kunit_try_catch/174
[   24.628855] 
[   24.629216] CPU: 1 UID: 0 PID: 174 Comm: kunit_try_catch Tainted: G    B            N 6.13.0-rc2-next-20241209 #1
[   24.630396] Tainted: [B]=BAD_PAGE, [N]=TEST
[   24.631001] Hardware name: linux,dummy-virt (DT)
[   24.631549] Call trace:
[   24.632011]  show_stack+0x20/0x38 (C)
[   24.632575]  dump_stack_lvl+0x8c/0xd0
[   24.633583]  print_report+0x118/0x5e0
[   24.634365]  kasan_report+0xc8/0x118
[   24.634916]  kasan_check_range+0x100/0x1a8
[   24.635594]  __asan_memset+0x34/0x78
[   24.636210]  kmalloc_uaf_memset+0x170/0x310
[   24.636916]  kunit_try_run_case+0x14c/0x3d0
[   24.637507]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   24.638379]  kthread+0x24c/0x2d0
[   24.639110]  ret_from_fork+0x10/0x20
[   24.639640] 
[   24.639935] Allocated by task 174:
[   24.640495]  kasan_save_stack+0x3c/0x68
[   24.641214]  kasan_save_track+0x20/0x40
[   24.641844]  kasan_save_alloc_info+0x40/0x58
[   24.642428]  __kasan_kmalloc+0xd4/0xd8
[   24.643046]  __kmalloc_cache_noprof+0x15c/0x3c0
[   24.643722]  kmalloc_uaf_memset+0xb8/0x310
[   24.644301]  kunit_try_run_case+0x14c/0x3d0
[   24.644969]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   24.645675]  kthread+0x24c/0x2d0
[   24.646220]  ret_from_fork+0x10/0x20
[   24.646835] 
[   24.647161] Freed by task 174:
[   24.647694]  kasan_save_stack+0x3c/0x68
[   24.648289]  kasan_save_track+0x20/0x40
[   24.648911]  kasan_save_free_info+0x4c/0x78
[   24.649529]  __kasan_slab_free+0x6c/0x98
[   24.650145]  kfree+0x114/0x3c8
[   24.650637]  kmalloc_uaf_memset+0x11c/0x310
[   24.651294]  kunit_try_run_case+0x14c/0x3d0
[   24.651909]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   24.652670]  kthread+0x24c/0x2d0
[   24.653237]  ret_from_fork+0x10/0x20
[   24.653845] 
[   24.654166] The buggy address belongs to the object at fff00000c125ae00
[   24.654166]  which belongs to the cache kmalloc-64 of size 64
[   24.655448] The buggy address is located 0 bytes inside of
[   24.655448]  freed 64-byte region [fff00000c125ae00, fff00000c125ae40)
[   24.656576] 
[   24.656978] The buggy address belongs to the physical page:
[   24.657562] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10125a
[   24.658687] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   24.659603] page_type: f5(slab)
[   24.660120] raw: 0bfffe0000000000 fff00000c00018c0 dead000000000122 0000000000000000
[   24.661088] raw: 0000000000000000 0000000080200020 00000000f5000000 0000000000000000
[   24.661957] page dumped because: kasan: bad access detected
[   24.662652] 
[   24.662993] Memory state around the buggy address:
[   24.663642]  fff00000c125ad00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   24.664520]  fff00000c125ad80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   24.665412] >fff00000c125ae00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   24.666254]                    ^
[   24.666759]  fff00000c125ae80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   24.667573]  fff00000c125af00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   24.668377] ==================================================================

[   24.584643] ==================================================================
[   24.586459] BUG: KASAN: slab-use-after-free in kmalloc_uaf_memset+0x1a4/0x360
[   24.587502] Write of size 33 at addr ffff888102952d00 by task kunit_try_catch/193
[   24.588550] 
[   24.588819] CPU: 0 UID: 0 PID: 193 Comm: kunit_try_catch Tainted: G    B            N 6.13.0-rc2-next-20241209 #1
[   24.590327] Tainted: [B]=BAD_PAGE, [N]=TEST
[   24.590716] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   24.591952] Call Trace:
[   24.592174]  <TASK>
[   24.592856]  dump_stack_lvl+0x73/0xb0
[   24.593550]  print_report+0xd1/0x640
[   24.594221]  ? __virt_addr_valid+0x1db/0x2d0
[   24.594829]  ? kasan_complete_mode_report_info+0x64/0x200
[   24.595387]  kasan_report+0x102/0x140
[   24.595766]  ? kmalloc_uaf_memset+0x1a4/0x360
[   24.596506]  ? kmalloc_uaf_memset+0x1a4/0x360
[   24.597707]  kasan_check_range+0x10c/0x1c0
[   24.598238]  __asan_memset+0x27/0x50
[   24.598574]  kmalloc_uaf_memset+0x1a4/0x360
[   24.599269]  ? __pfx_kmalloc_uaf_memset+0x10/0x10
[   24.599789]  ? __schedule+0xc70/0x27e0
[   24.600507]  ? __pfx_read_tsc+0x10/0x10
[   24.601147]  ? ktime_get_ts64+0x86/0x230
[   24.601638]  kunit_try_run_case+0x1b3/0x490
[   24.602553]  ? __pfx_kunit_try_run_case+0x10/0x10
[   24.603202]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   24.603694]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   24.604798]  ? __kthread_parkme+0x82/0x160
[   24.605269]  ? preempt_count_sub+0x50/0x80
[   24.605610]  ? __pfx_kunit_try_run_case+0x10/0x10
[   24.606639]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   24.607578]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   24.608132]  kthread+0x257/0x310
[   24.608529]  ? __pfx_kthread+0x10/0x10
[   24.609247]  ret_from_fork+0x41/0x80
[   24.609547]  ? __pfx_kthread+0x10/0x10
[   24.610465]  ret_from_fork_asm+0x1a/0x30
[   24.611266]  </TASK>
[   24.611471] 
[   24.611702] Allocated by task 193:
[   24.612143]  kasan_save_stack+0x3d/0x60
[   24.612670]  kasan_save_track+0x18/0x40
[   24.613626]  kasan_save_alloc_info+0x3b/0x50
[   24.613956]  __kasan_kmalloc+0xb7/0xc0
[   24.614737]  __kmalloc_cache_noprof+0x184/0x410
[   24.615714]  kmalloc_uaf_memset+0xaa/0x360
[   24.616248]  kunit_try_run_case+0x1b3/0x490
[   24.616811]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   24.617490]  kthread+0x257/0x310
[   24.618535]  ret_from_fork+0x41/0x80
[   24.619266]  ret_from_fork_asm+0x1a/0x30
[   24.619659] 
[   24.619903] Freed by task 193:
[   24.620466]  kasan_save_stack+0x3d/0x60
[   24.621511]  kasan_save_track+0x18/0x40
[   24.621866]  kasan_save_free_info+0x3f/0x60
[   24.622515]  __kasan_slab_free+0x56/0x70
[   24.623396]  kfree+0x123/0x3f0
[   24.623722]  kmalloc_uaf_memset+0x12c/0x360
[   24.624446]  kunit_try_run_case+0x1b3/0x490
[   24.625042]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   24.625489]  kthread+0x257/0x310
[   24.625844]  ret_from_fork+0x41/0x80
[   24.626634]  ret_from_fork_asm+0x1a/0x30
[   24.627011] 
[   24.627691] The buggy address belongs to the object at ffff888102952d00
[   24.627691]  which belongs to the cache kmalloc-64 of size 64
[   24.629392] The buggy address is located 0 bytes inside of
[   24.629392]  freed 64-byte region [ffff888102952d00, ffff888102952d40)
[   24.631208] 
[   24.631413] The buggy address belongs to the physical page:
[   24.631835] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x102952
[   24.632801] flags: 0x200000000000000(node=0|zone=2)
[   24.633359] page_type: f5(slab)
[   24.633778] raw: 0200000000000000 ffff8881000418c0 dead000000000122 0000000000000000
[   24.635225] raw: 0000000000000000 0000000080200020 00000000f5000000 0000000000000000
[   24.636224] page dumped because: kasan: bad access detected
[   24.636703] 
[   24.636964] Memory state around the buggy address:
[   24.637553]  ffff888102952c00: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
[   24.638700]  ffff888102952c80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   24.639074] >ffff888102952d00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   24.639427]                    ^
[   24.640349]  ffff888102952d80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   24.640970]  ffff888102952e00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   24.642067] ==================================================================