Hay
Date
Nov. 20, 2024, 6:35 a.m.

Environment
qemu-arm64
qemu-x86_64

[   37.686156] ==================================================================
[   37.688360] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x480/0x4a8
[   37.689237] Read of size 8 at addr fff00000c65b0300 by task kunit_try_catch/189
[   37.690089] 
[   37.691270] CPU: 1 UID: 0 PID: 189 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241120 #1
[   37.692486] Tainted: [B]=BAD_PAGE, [N]=TEST
[   37.693043] Hardware name: linux,dummy-virt (DT)
[   37.694189] Call trace:
[   37.694616]  show_stack+0x20/0x38 (C)
[   37.695240]  dump_stack_lvl+0x8c/0xd0
[   37.695851]  print_report+0x118/0x5e0
[   37.696406]  kasan_report+0xc8/0x118
[   37.696897]  __asan_report_load8_noabort+0x20/0x30
[   37.697984]  workqueue_uaf+0x480/0x4a8
[   37.698577]  kunit_try_run_case+0x14c/0x3d0
[   37.699186]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.700271]  kthread+0x24c/0x2d0
[   37.700787]  ret_from_fork+0x10/0x20
[   37.701313] 
[   37.702095] Allocated by task 189:
[   37.702473]  kasan_save_stack+0x3c/0x68
[   37.702880]  kasan_save_track+0x20/0x40
[   37.703961]  kasan_save_alloc_info+0x40/0x58
[   37.705046]  __kasan_kmalloc+0xd4/0xd8
[   37.705844]  __kmalloc_cache_noprof+0x15c/0x3c8
[   37.706654]  workqueue_uaf+0x13c/0x4a8
[   37.707157]  kunit_try_run_case+0x14c/0x3d0
[   37.707723]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.708377]  kthread+0x24c/0x2d0
[   37.708849]  ret_from_fork+0x10/0x20
[   37.710121] 
[   37.710500] Freed by task 31:
[   37.711011]  kasan_save_stack+0x3c/0x68
[   37.711522]  kasan_save_track+0x20/0x40
[   37.712087]  kasan_save_free_info+0x4c/0x78
[   37.712734]  __kasan_slab_free+0x6c/0x98
[   37.713824]  kfree+0x114/0x3d0
[   37.714249]  workqueue_uaf_work+0x18/0x30
[   37.714851]  process_one_work+0x530/0xfa8
[   37.715358]  worker_thread+0x614/0xf28
[   37.715927]  kthread+0x24c/0x2d0
[   37.716470]  ret_from_fork+0x10/0x20
[   37.716920] 
[   37.718458] Last potentially related work creation:
[   37.718946]  kasan_save_stack+0x3c/0x68
[   37.719481]  __kasan_record_aux_stack+0xbc/0xe8
[   37.720119]  kasan_record_aux_stack_noalloc+0x14/0x20
[   37.720777]  __queue_work+0x654/0xfe0
[   37.721255]  queue_work_on+0xbc/0xf8
[   37.721814]  workqueue_uaf+0x210/0x4a8
[   37.722372]  kunit_try_run_case+0x14c/0x3d0
[   37.723549]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.724215]  kthread+0x24c/0x2d0
[   37.724760]  ret_from_fork+0x10/0x20
[   37.725280] 
[   37.725980] The buggy address belongs to the object at fff00000c65b0300
[   37.725980]  which belongs to the cache kmalloc-32 of size 32
[   37.727594] The buggy address is located 0 bytes inside of
[   37.727594]  freed 32-byte region [fff00000c65b0300, fff00000c65b0320)
[   37.729203] 
[   37.729910] The buggy address belongs to the physical page:
[   37.730783] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1065b0
[   37.731683] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   37.732456] page_type: f5(slab)
[   37.732940] raw: 0bfffe0000000000 fff00000c0001780 dead000000000122 0000000000000000
[   37.733796] raw: 0000000000000000 0000000080400040 00000001f5000000 0000000000000000
[   37.734593] page dumped because: kasan: bad access detected
[   37.735258] 
[   37.736128] Memory state around the buggy address:
[   37.737255]  fff00000c65b0200: fa fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc
[   37.738273]  fff00000c65b0280: 00 00 00 fc fc fc fc fc 00 00 00 07 fc fc fc fc
[   37.739188] >fff00000c65b0300: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
[   37.740023]                    ^
[   37.740502]  fff00000c65b0380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   37.741153]  fff00000c65b0400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   37.742493] ==================================================================

[   29.272196] ==================================================================
[   29.273257] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x4d8/0x560
[   29.274399] Read of size 8 at addr ffff8881029e55c0 by task kunit_try_catch/207
[   29.275866] 
[   29.276045] CPU: 1 UID: 0 PID: 207 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241120 #1
[   29.277576] Tainted: [B]=BAD_PAGE, [N]=TEST
[   29.278135] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   29.279504] Call Trace:
[   29.280066]  <TASK>
[   29.280632]  dump_stack_lvl+0x73/0xb0
[   29.281450]  print_report+0xd1/0x640
[   29.281987]  ? __virt_addr_valid+0x1db/0x2d0
[   29.282726]  ? kasan_complete_mode_report_info+0x64/0x200
[   29.283315]  kasan_report+0x102/0x140
[   29.284299]  ? workqueue_uaf+0x4d8/0x560
[   29.284930]  ? workqueue_uaf+0x4d8/0x560
[   29.285789]  __asan_report_load8_noabort+0x18/0x20
[   29.286598]  workqueue_uaf+0x4d8/0x560
[   29.287151]  ? __pfx_workqueue_uaf+0x10/0x10
[   29.288364]  ? __pfx_workqueue_uaf+0x10/0x10
[   29.288750]  kunit_try_run_case+0x1b3/0x490
[   29.289515]  ? __pfx_kunit_try_run_case+0x10/0x10
[   29.290255]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   29.290921]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   29.291711]  ? __kthread_parkme+0x82/0x160
[   29.292804]  ? preempt_count_sub+0x50/0x80
[   29.293376]  ? __pfx_kunit_try_run_case+0x10/0x10
[   29.294300]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   29.294919]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   29.296715]  kthread+0x257/0x310
[   29.297473]  ? __pfx_kthread+0x10/0x10
[   29.297788]  ret_from_fork+0x41/0x80
[   29.298022]  ? __pfx_kthread+0x10/0x10
[   29.298225]  ret_from_fork_asm+0x1a/0x30
[   29.298430]  </TASK>
[   29.298549] 
[   29.298643] Allocated by task 207:
[   29.299012]  kasan_save_stack+0x3d/0x60
[   29.300424]  kasan_save_track+0x18/0x40
[   29.302630]  kasan_save_alloc_info+0x3b/0x50
[   29.304200]  __kasan_kmalloc+0xb7/0xc0
[   29.305085]  __kmalloc_cache_noprof+0x184/0x410
[   29.306586]  workqueue_uaf+0x153/0x560
[   29.306858]  kunit_try_run_case+0x1b3/0x490
[   29.307116]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   29.307413]  kthread+0x257/0x310
[   29.308098]  ret_from_fork+0x41/0x80
[   29.308643]  ret_from_fork_asm+0x1a/0x30
[   29.309606] 
[   29.309898] Freed by task 43:
[   29.310336]  kasan_save_stack+0x3d/0x60
[   29.310976]  kasan_save_track+0x18/0x40
[   29.311510]  kasan_save_free_info+0x3f/0x60
[   29.312275]  __kasan_slab_free+0x56/0x70
[   29.313244]  kfree+0x123/0x3f0
[   29.313893]  workqueue_uaf_work+0x12/0x20
[   29.314205]  process_one_work+0x5ee/0xf60
[   29.314576]  worker_thread+0x720/0x1300
[   29.315901]  kthread+0x257/0x310
[   29.316818]  ret_from_fork+0x41/0x80
[   29.317194]  ret_from_fork_asm+0x1a/0x30
[   29.317855] 
[   29.318038] Last potentially related work creation:
[   29.318502]  kasan_save_stack+0x3d/0x60
[   29.319551]  __kasan_record_aux_stack+0xae/0xc0
[   29.320411]  kasan_record_aux_stack_noalloc+0xf/0x20
[   29.320846]  __queue_work+0x67e/0xf70
[   29.321233]  queue_work_on+0x74/0xa0
[   29.321605]  workqueue_uaf+0x26e/0x560
[   29.322017]  kunit_try_run_case+0x1b3/0x490
[   29.322455]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   29.324339]  kthread+0x257/0x310
[   29.325079]  ret_from_fork+0x41/0x80
[   29.325808]  ret_from_fork_asm+0x1a/0x30
[   29.326248] 
[   29.326867] The buggy address belongs to the object at ffff8881029e55c0
[   29.326867]  which belongs to the cache kmalloc-32 of size 32
[   29.328514] The buggy address is located 0 bytes inside of
[   29.328514]  freed 32-byte region [ffff8881029e55c0, ffff8881029e55e0)
[   29.329646] 
[   29.330625] The buggy address belongs to the physical page:
[   29.331265] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1029e5
[   29.331809] flags: 0x200000000000000(node=0|zone=2)
[   29.332501] page_type: f5(slab)
[   29.332859] raw: 0200000000000000 ffff888100041780 dead000000000122 0000000000000000
[   29.333820] raw: 0000000000000000 0000000080400040 00000001f5000000 0000000000000000
[   29.334476] page dumped because: kasan: bad access detected
[   29.335149] 
[   29.335337] Memory state around the buggy address:
[   29.335976]  ffff8881029e5480: 00 00 00 fc fc fc fc fc fa fb fb fb fc fc fc fc
[   29.336735]  ffff8881029e5500: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   29.337903] >ffff8881029e5580: 00 00 00 fc fc fc fc fc fa fb fb fb fc fc fc fc
[   29.339122]                                            ^
[   29.339918]  ffff8881029e5600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   29.340951]  ffff8881029e5680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   29.342357] ==================================================================