Hay
Date
Nov. 28, 2024, 2:36 a.m.

Environment
qemu-arm64
qemu-x86_64

[   31.542980] ==================================================================
[   31.543918] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x480/0x4a8
[   31.545564] Read of size 8 at addr fff00000c63af680 by task kunit_try_catch/188
[   31.546442] 
[   31.546810] CPU: 1 UID: 0 PID: 188 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241128 #1
[   31.548039] Tainted: [B]=BAD_PAGE, [N]=TEST
[   31.548509] Hardware name: linux,dummy-virt (DT)
[   31.549679] Call trace:
[   31.550221]  show_stack+0x20/0x38 (C)
[   31.550827]  dump_stack_lvl+0x8c/0xd0
[   31.551433]  print_report+0x118/0x5e0
[   31.552043]  kasan_report+0xc8/0x118
[   31.552665]  __asan_report_load8_noabort+0x20/0x30
[   31.553371]  workqueue_uaf+0x480/0x4a8
[   31.554153]  kunit_try_run_case+0x14c/0x3d0
[   31.554794]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   31.555565]  kthread+0x24c/0x2d0
[   31.556104]  ret_from_fork+0x10/0x20
[   31.556727] 
[   31.557347] Allocated by task 188:
[   31.557824]  kasan_save_stack+0x3c/0x68
[   31.558433]  kasan_save_track+0x20/0x40
[   31.558985]  kasan_save_alloc_info+0x40/0x58
[   31.559508]  __kasan_kmalloc+0xd4/0xd8
[   31.560084]  __kmalloc_cache_noprof+0x15c/0x3c0
[   31.560651]  workqueue_uaf+0x13c/0x4a8
[   31.561565]  kunit_try_run_case+0x14c/0x3d0
[   31.562236]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   31.562807]  kthread+0x24c/0x2d0
[   31.563351]  ret_from_fork+0x10/0x20
[   31.563867] 
[   31.564210] Freed by task 8:
[   31.564614]  kasan_save_stack+0x3c/0x68
[   31.565552]  kasan_save_track+0x20/0x40
[   31.566232]  kasan_save_free_info+0x4c/0x78
[   31.567095]  __kasan_slab_free+0x6c/0x98
[   31.567602]  kfree+0x114/0x3c8
[   31.568070]  workqueue_uaf_work+0x18/0x30
[   31.568627]  process_one_work+0x530/0xf98
[   31.569237]  worker_thread+0x614/0xf28
[   31.570185]  kthread+0x24c/0x2d0
[   31.570809]  ret_from_fork+0x10/0x20
[   31.571497] 
[   31.571839] Last potentially related work creation:
[   31.572415]  kasan_save_stack+0x3c/0x68
[   31.572907]  __kasan_record_aux_stack+0xbc/0xe8
[   31.573756]  kasan_record_aux_stack_noalloc+0x14/0x20
[   31.574643]  __queue_work+0x65c/0xfd8
[   31.575342]  queue_work_on+0xbc/0xf8
[   31.575835]  workqueue_uaf+0x210/0x4a8
[   31.576351]  kunit_try_run_case+0x14c/0x3d0
[   31.576978]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   31.577685]  kthread+0x24c/0x2d0
[   31.578162]  ret_from_fork+0x10/0x20
[   31.578644] 
[   31.578979] The buggy address belongs to the object at fff00000c63af680
[   31.578979]  which belongs to the cache kmalloc-32 of size 32
[   31.580613] The buggy address is located 0 bytes inside of
[   31.580613]  freed 32-byte region [fff00000c63af680, fff00000c63af6a0)
[   31.582218] 
[   31.582564] The buggy address belongs to the physical page:
[   31.583169] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1063af
[   31.584101] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   31.584861] page_type: f5(slab)
[   31.585812] raw: 0bfffe0000000000 fff00000c0001780 dead000000000122 0000000000000000
[   31.586628] raw: 0000000000000000 0000000080400040 00000001f5000000 0000000000000000
[   31.587437] page dumped because: kasan: bad access detected
[   31.587986] 
[   31.588343] Memory state around the buggy address:
[   31.589380]  fff00000c63af580: 00 00 00 fc fc fc fc fc 00 00 03 fc fc fc fc fc
[   31.590203]  fff00000c63af600: 00 00 07 fc fc fc fc fc 00 00 00 07 fc fc fc fc
[   31.590953] >fff00000c63af680: fa fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc
[   31.591784]                    ^
[   31.592244]  fff00000c63af700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   31.593603]  fff00000c63af780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   31.594266] ==================================================================

[   22.477462] ==================================================================
[   22.478760] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x4d8/0x560
[   22.479469] Read of size 8 at addr ffff888101b55c80 by task kunit_try_catch/208
[   22.480013] 
[   22.480460] CPU: 1 UID: 0 PID: 208 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241128 #1
[   22.481812] Tainted: [B]=BAD_PAGE, [N]=TEST
[   22.482493] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   22.483435] Call Trace:
[   22.483786]  <TASK>
[   22.484414]  dump_stack_lvl+0x73/0xb0
[   22.485019]  print_report+0xd1/0x640
[   22.485697]  ? __virt_addr_valid+0x1db/0x2d0
[   22.486231]  ? kasan_complete_mode_report_info+0x64/0x200
[   22.486762]  kasan_report+0x102/0x140
[   22.487188]  ? workqueue_uaf+0x4d8/0x560
[   22.487621]  ? workqueue_uaf+0x4d8/0x560
[   22.488103]  __asan_report_load8_noabort+0x18/0x20
[   22.488453]  workqueue_uaf+0x4d8/0x560
[   22.489137]  ? __pfx_workqueue_uaf+0x10/0x10
[   22.490025]  ? __schedule+0xc3e/0x2790
[   22.490515]  ? __pfx_read_tsc+0x10/0x10
[   22.490816]  ? ktime_get_ts64+0x84/0x230
[   22.491106]  kunit_try_run_case+0x1b3/0x490
[   22.491656]  ? __pfx_kunit_try_run_case+0x10/0x10
[   22.492197]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   22.492764]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   22.493131]  ? __kthread_parkme+0x82/0x160
[   22.494214]  ? preempt_count_sub+0x50/0x80
[   22.495147]  ? __pfx_kunit_try_run_case+0x10/0x10
[   22.495805]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   22.496709]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   22.497497]  kthread+0x257/0x310
[   22.497918]  ? __pfx_kthread+0x10/0x10
[   22.498414]  ret_from_fork+0x41/0x80
[   22.498771]  ? __pfx_kthread+0x10/0x10
[   22.499630]  ret_from_fork_asm+0x1a/0x30
[   22.500272]  </TASK>
[   22.500547] 
[   22.500796] Allocated by task 208:
[   22.501063]  kasan_save_stack+0x3d/0x60
[   22.502118]  kasan_save_track+0x18/0x40
[   22.502494]  kasan_save_alloc_info+0x3b/0x50
[   22.502853]  __kasan_kmalloc+0xb7/0xc0
[   22.503264]  __kmalloc_cache_noprof+0x184/0x410
[   22.503761]  workqueue_uaf+0x153/0x560
[   22.504353]  kunit_try_run_case+0x1b3/0x490
[   22.504826]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   22.505565]  kthread+0x257/0x310
[   22.505975]  ret_from_fork+0x41/0x80
[   22.506523]  ret_from_fork_asm+0x1a/0x30
[   22.506952] 
[   22.507785] Freed by task 71:
[   22.508044]  kasan_save_stack+0x3d/0x60
[   22.508431]  kasan_save_track+0x18/0x40
[   22.508908]  kasan_save_free_info+0x3f/0x60
[   22.509573]  __kasan_slab_free+0x56/0x70
[   22.509906]  kfree+0x123/0x3f0
[   22.510463]  workqueue_uaf_work+0x12/0x20
[   22.510882]  process_one_work+0x5ee/0xf60
[   22.511353]  worker_thread+0x720/0x1300
[   22.511631]  kthread+0x257/0x310
[   22.512052]  ret_from_fork+0x41/0x80
[   22.512536]  ret_from_fork_asm+0x1a/0x30
[   22.513007] 
[   22.513774] Last potentially related work creation:
[   22.514117]  kasan_save_stack+0x3d/0x60
[   22.514704]  __kasan_record_aux_stack+0xae/0xc0
[   22.515320]  kasan_record_aux_stack_noalloc+0xf/0x20
[   22.515757]  __queue_work+0x67e/0xf70
[   22.516020]  queue_work_on+0x74/0xa0
[   22.516569]  workqueue_uaf+0x26e/0x560
[   22.517048]  kunit_try_run_case+0x1b3/0x490
[   22.517693]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   22.518046]  kthread+0x257/0x310
[   22.518808]  ret_from_fork+0x41/0x80
[   22.519261]  ret_from_fork_asm+0x1a/0x30
[   22.519867] 
[   22.520138] The buggy address belongs to the object at ffff888101b55c80
[   22.520138]  which belongs to the cache kmalloc-32 of size 32
[   22.521363] The buggy address is located 0 bytes inside of
[   22.521363]  freed 32-byte region [ffff888101b55c80, ffff888101b55ca0)
[   22.522393] 
[   22.522550] The buggy address belongs to the physical page:
[   22.522874] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x101b55
[   22.523764] flags: 0x200000000000000(node=0|zone=2)
[   22.524480] page_type: f5(slab)
[   22.524761] raw: 0200000000000000 ffff888100041780 dead000000000122 0000000000000000
[   22.525917] raw: 0000000000000000 0000000080400040 00000001f5000000 0000000000000000
[   22.526856] page dumped because: kasan: bad access detected
[   22.527506] 
[   22.527729] Memory state around the buggy address:
[   22.528228]  ffff888101b55b80: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   22.528749]  ffff888101b55c00: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   22.529586] >ffff888101b55c80: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
[   22.530147]                    ^
[   22.531000]  ffff888101b55d00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   22.532014]  ffff888101b55d80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   22.532694] ==================================================================