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

Environment
qemu-arm64
qemu-x86_64

[   48.874754] ==================================================================
[   48.875819] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x480/0x4a8
[   48.876503] Read of size 8 at addr fff00000c615ddc0 by task kunit_try_catch/189
[   48.877470] 
[   48.877940] CPU: 0 UID: 0 PID: 189 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241127 #1
[   48.879127] Tainted: [B]=BAD_PAGE, [N]=TEST
[   48.879927] Hardware name: linux,dummy-virt (DT)
[   48.881365] Call trace:
[   48.882142]  show_stack+0x20/0x38 (C)
[   48.882860]  dump_stack_lvl+0x8c/0xd0
[   48.883609]  print_report+0x118/0x5e0
[   48.884209]  kasan_report+0xc8/0x118
[   48.884845]  __asan_report_load8_noabort+0x20/0x30
[   48.885919]  workqueue_uaf+0x480/0x4a8
[   48.886448]  kunit_try_run_case+0x14c/0x3d0
[   48.887084]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   48.887841]  kthread+0x24c/0x2d0
[   48.888589]  ret_from_fork+0x10/0x20
[   48.889348] 
[   48.889637] Allocated by task 189:
[   48.890260]  kasan_save_stack+0x3c/0x68
[   48.891632]  kasan_save_track+0x20/0x40
[   48.892186]  kasan_save_alloc_info+0x40/0x58
[   48.893077]  __kasan_kmalloc+0xd4/0xd8
[   48.893794]  __kmalloc_cache_noprof+0x15c/0x3c0
[   48.894618]  workqueue_uaf+0x13c/0x4a8
[   48.895208]  kunit_try_run_case+0x14c/0x3d0
[   48.895865]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   48.896692]  kthread+0x24c/0x2d0
[   48.897506]  ret_from_fork+0x10/0x20
[   48.897918] 
[   48.898231] Freed by task 31:
[   48.898988]  kasan_save_stack+0x3c/0x68
[   48.899681]  kasan_save_track+0x20/0x40
[   48.899972]  kasan_save_free_info+0x4c/0x78
[   48.900264]  __kasan_slab_free+0x6c/0x98
[   48.901023]  kfree+0x114/0x3c8
[   48.902099]  workqueue_uaf_work+0x18/0x30
[   48.902765]  process_one_work+0x530/0xf98
[   48.903390]  worker_thread+0x614/0xf28
[   48.904103]  kthread+0x24c/0x2d0
[   48.904711]  ret_from_fork+0x10/0x20
[   48.905355] 
[   48.905983] Last potentially related work creation:
[   48.906688]  kasan_save_stack+0x3c/0x68
[   48.907142]  __kasan_record_aux_stack+0xbc/0xe8
[   48.907808]  kasan_record_aux_stack_noalloc+0x14/0x20
[   48.908687]  __queue_work+0x65c/0xfd8
[   48.909181]  queue_work_on+0xbc/0xf8
[   48.910188]  workqueue_uaf+0x210/0x4a8
[   48.910842]  kunit_try_run_case+0x14c/0x3d0
[   48.911440]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   48.912021]  kthread+0x24c/0x2d0
[   48.912622]  ret_from_fork+0x10/0x20
[   48.913210] 
[   48.913990] The buggy address belongs to the object at fff00000c615ddc0
[   48.913990]  which belongs to the cache kmalloc-32 of size 32
[   48.915284] The buggy address is located 0 bytes inside of
[   48.915284]  freed 32-byte region [fff00000c615ddc0, fff00000c615dde0)
[   48.916713] 
[   48.916996] The buggy address belongs to the physical page:
[   48.917554] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10615d
[   48.919024] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   48.919932] page_type: f5(slab)
[   48.920645] raw: 0bfffe0000000000 fff00000c0001780 dead000000000122 0000000000000000
[   48.921721] raw: 0000000000000000 0000000080400040 00000001f5000000 0000000000000000
[   48.923094] page dumped because: kasan: bad access detected
[   48.923811] 
[   48.924060] Memory state around the buggy address:
[   48.924816]  fff00000c615dc80: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   48.926355]  fff00000c615dd00: 00 00 00 fc fc fc fc fc 00 00 03 fc fc fc fc fc
[   48.927257] >fff00000c615dd80: 00 00 07 fc fc fc fc fc fa fb fb fb fc fc fc fc
[   48.928046]                                            ^
[   48.928682]  fff00000c615de00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   48.929981]  fff00000c615de80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   48.931006] ==================================================================

[   26.121891] ==================================================================
[   26.122863] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x4d8/0x560
[   26.124466] Read of size 8 at addr ffff888101aa5480 by task kunit_try_catch/208
[   26.125511] 
[   26.125627] CPU: 1 UID: 0 PID: 208 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241127 #1
[   26.126107] Tainted: [B]=BAD_PAGE, [N]=TEST
[   26.126875] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   26.128408] Call Trace:
[   26.128798]  <TASK>
[   26.129256]  dump_stack_lvl+0x73/0xb0
[   26.129880]  print_report+0xd1/0x640
[   26.130676]  ? __virt_addr_valid+0x1db/0x2d0
[   26.131182]  ? kasan_complete_mode_report_info+0x64/0x200
[   26.132096]  kasan_report+0x102/0x140
[   26.133030]  ? workqueue_uaf+0x4d8/0x560
[   26.133586]  ? workqueue_uaf+0x4d8/0x560
[   26.134540]  __asan_report_load8_noabort+0x18/0x20
[   26.135052]  workqueue_uaf+0x4d8/0x560
[   26.135702]  ? __pfx_workqueue_uaf+0x10/0x10
[   26.136500]  ? __schedule+0xc3e/0x2790
[   26.136805]  ? __pfx_read_tsc+0x10/0x10
[   26.137585]  ? ktime_get_ts64+0x84/0x230
[   26.138163]  ? irqentry_exit+0x2a/0x60
[   26.138539]  kunit_try_run_case+0x1b3/0x490
[   26.139011]  ? __pfx_kunit_try_run_case+0x10/0x10
[   26.139441]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   26.139958]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   26.140443]  ? __kthread_parkme+0x82/0x160
[   26.140793]  ? preempt_count_sub+0x50/0x80
[   26.141445]  ? __pfx_kunit_try_run_case+0x10/0x10
[   26.142112]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   26.142616]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   26.143131]  kthread+0x257/0x310
[   26.143737]  ? __pfx_kthread+0x10/0x10
[   26.144076]  ret_from_fork+0x41/0x80
[   26.144565]  ? __pfx_kthread+0x10/0x10
[   26.145012]  ret_from_fork_asm+0x1a/0x30
[   26.145485]  </TASK>
[   26.145677] 
[   26.145866] Allocated by task 208:
[   26.146272]  kasan_save_stack+0x3d/0x60
[   26.147035]  kasan_save_track+0x18/0x40
[   26.147411]  kasan_save_alloc_info+0x3b/0x50
[   26.147709]  __kasan_kmalloc+0xb7/0xc0
[   26.148228]  __kmalloc_cache_noprof+0x184/0x410
[   26.148884]  workqueue_uaf+0x153/0x560
[   26.149284]  kunit_try_run_case+0x1b3/0x490
[   26.149579]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   26.150552]  kthread+0x257/0x310
[   26.150818]  ret_from_fork+0x41/0x80
[   26.151418]  ret_from_fork_asm+0x1a/0x30
[   26.151908] 
[   26.152341] Freed by task 70:
[   26.152636]  kasan_save_stack+0x3d/0x60
[   26.152911]  kasan_save_track+0x18/0x40
[   26.153507]  kasan_save_free_info+0x3f/0x60
[   26.153954]  __kasan_slab_free+0x56/0x70
[   26.154390]  kfree+0x123/0x3f0
[   26.154629]  workqueue_uaf_work+0x12/0x20
[   26.154909]  process_one_work+0x5ee/0xf60
[   26.155458]  worker_thread+0x720/0x1300
[   26.155974]  kthread+0x257/0x310
[   26.157788]  ret_from_fork+0x41/0x80
[   26.158280]  ret_from_fork_asm+0x1a/0x30
[   26.158570] 
[   26.158722] Last potentially related work creation:
[   26.159340]  kasan_save_stack+0x3d/0x60
[   26.159808]  __kasan_record_aux_stack+0xae/0xc0
[   26.160387]  kasan_record_aux_stack_noalloc+0xf/0x20
[   26.161168]  __queue_work+0x67e/0xf70
[   26.161519]  queue_work_on+0x74/0xa0
[   26.161884]  workqueue_uaf+0x26e/0x560
[   26.162619]  kunit_try_run_case+0x1b3/0x490
[   26.162914]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   26.163874]  kthread+0x257/0x310
[   26.164407]  ret_from_fork+0x41/0x80
[   26.164713]  ret_from_fork_asm+0x1a/0x30
[   26.165020] 
[   26.165179] The buggy address belongs to the object at ffff888101aa5480
[   26.165179]  which belongs to the cache kmalloc-32 of size 32
[   26.166792] The buggy address is located 0 bytes inside of
[   26.166792]  freed 32-byte region [ffff888101aa5480, ffff888101aa54a0)
[   26.168052] 
[   26.168236] The buggy address belongs to the physical page:
[   26.168667] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x101aa5
[   26.169349] flags: 0x200000000000000(node=0|zone=2)
[   26.170104] page_type: f5(slab)
[   26.170428] raw: 0200000000000000 ffff888100041780 dead000000000122 0000000000000000
[   26.170860] raw: 0000000000000000 0000000080400040 00000001f5000000 0000000000000000
[   26.171929] page dumped because: kasan: bad access detected
[   26.172427] 
[   26.172628] Memory state around the buggy address:
[   26.173358]  ffff888101aa5380: fa fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc
[   26.173860]  ffff888101aa5400: 00 00 05 fc fc fc fc fc fa fb fb fb fc fc fc fc
[   26.174790] >ffff888101aa5480: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
[   26.175489]                    ^
[   26.175727]  ffff888101aa5500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   26.176145]  ffff888101aa5580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   26.177324] ==================================================================