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

Environment
qemu-arm64
qemu-x86_64

[   25.185148] ==================================================================
[   25.186163] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x480/0x4a8
[   25.187439] Read of size 8 at addr fff00000c63712c0 by task kunit_try_catch/188
[   25.188375] 
[   25.188878] CPU: 1 UID: 0 PID: 188 Comm: kunit_try_catch Tainted: G    B            N 6.13.0-rc2-next-20241209 #1
[   25.190245] Tainted: [B]=BAD_PAGE, [N]=TEST
[   25.190918] Hardware name: linux,dummy-virt (DT)
[   25.191422] Call trace:
[   25.191765]  show_stack+0x20/0x38 (C)
[   25.192242]  dump_stack_lvl+0x8c/0xd0
[   25.193279]  print_report+0x118/0x5e0
[   25.193892]  kasan_report+0xc8/0x118
[   25.194139]  __asan_report_load8_noabort+0x20/0x30
[   25.194411]  workqueue_uaf+0x480/0x4a8
[   25.194640]  kunit_try_run_case+0x14c/0x3d0
[   25.196018]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   25.196940]  kthread+0x24c/0x2d0
[   25.197517]  ret_from_fork+0x10/0x20
[   25.198183] 
[   25.198467] Allocated by task 188:
[   25.199335]  kasan_save_stack+0x3c/0x68
[   25.200042]  kasan_save_track+0x20/0x40
[   25.200735]  kasan_save_alloc_info+0x40/0x58
[   25.201431]  __kasan_kmalloc+0xd4/0xd8
[   25.202105]  __kmalloc_cache_noprof+0x15c/0x3c0
[   25.202834]  workqueue_uaf+0x13c/0x4a8
[   25.203611]  kunit_try_run_case+0x14c/0x3d0
[   25.204092]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   25.205241]  kthread+0x24c/0x2d0
[   25.205941]  ret_from_fork+0x10/0x20
[   25.206615] 
[   25.206956] Freed by task 31:
[   25.207859]  kasan_save_stack+0x3c/0x68
[   25.208434]  kasan_save_track+0x20/0x40
[   25.208989]  kasan_save_free_info+0x4c/0x78
[   25.209559]  __kasan_slab_free+0x6c/0x98
[   25.210138]  kfree+0x114/0x3c8
[   25.210642]  workqueue_uaf_work+0x18/0x30
[   25.211148]  process_one_work+0x530/0xf98
[   25.211777]  worker_thread+0x614/0xf28
[   25.212334]  kthread+0x24c/0x2d0
[   25.212851]  ret_from_fork+0x10/0x20
[   25.213450] 
[   25.213785] Last potentially related work creation:
[   25.214391]  kasan_save_stack+0x3c/0x68
[   25.214975]  kasan_record_aux_stack+0xb4/0xc8
[   25.215641]  __queue_work+0x65c/0xfd8
[   25.216135]  queue_work_on+0xbc/0xf8
[   25.216750]  workqueue_uaf+0x210/0x4a8
[   25.217229]  kunit_try_run_case+0x14c/0x3d0
[   25.217912]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   25.218595]  kthread+0x24c/0x2d0
[   25.219310]  ret_from_fork+0x10/0x20
[   25.219844] 
[   25.220173] The buggy address belongs to the object at fff00000c63712c0
[   25.220173]  which belongs to the cache kmalloc-32 of size 32
[   25.221299] The buggy address is located 0 bytes inside of
[   25.221299]  freed 32-byte region [fff00000c63712c0, fff00000c63712e0)
[   25.222536] 
[   25.222887] The buggy address belongs to the physical page:
[   25.223603] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x106371
[   25.224434] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   25.225238] page_type: f5(slab)
[   25.225652] raw: 0bfffe0000000000 fff00000c0001780 dead000000000122 0000000000000000
[   25.226418] raw: 0000000000000000 0000000080400040 00000000f5000000 0000000000000000
[   25.227367] page dumped because: kasan: bad access detected
[   25.228050] 
[   25.228315] Memory state around the buggy address:
[   25.229413]  fff00000c6371180: fa fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc
[   25.230225]  fff00000c6371200: 00 00 00 fc fc fc fc fc 00 00 03 fc fc fc fc fc
[   25.231246] >fff00000c6371280: 00 00 07 fc fc fc fc fc fa fb fb fb fc fc fc fc
[   25.231958]                                            ^
[   25.232836]  fff00000c6371300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   25.233664]  fff00000c6371380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   25.234424] ==================================================================

[   25.295498] ==================================================================
[   25.297346] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x4d8/0x560
[   25.298651] Read of size 8 at addr ffff888102956940 by task kunit_try_catch/207
[   25.299968] 
[   25.300421] CPU: 0 UID: 0 PID: 207 Comm: kunit_try_catch Tainted: G    B            N 6.13.0-rc2-next-20241209 #1
[   25.301129] Tainted: [B]=BAD_PAGE, [N]=TEST
[   25.301875] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   25.303340] Call Trace:
[   25.303557]  <TASK>
[   25.304072]  dump_stack_lvl+0x73/0xb0
[   25.304889]  print_report+0xd1/0x640
[   25.305083]  ? __virt_addr_valid+0x1db/0x2d0
[   25.305319]  ? kasan_complete_mode_report_info+0x64/0x200
[   25.305671]  kasan_report+0x102/0x140
[   25.306166]  ? workqueue_uaf+0x4d8/0x560
[   25.306872]  ? workqueue_uaf+0x4d8/0x560
[   25.307248]  __asan_report_load8_noabort+0x18/0x20
[   25.307596]  workqueue_uaf+0x4d8/0x560
[   25.307939]  ? __pfx_workqueue_uaf+0x10/0x10
[   25.308528]  ? __schedule+0xc70/0x27e0
[   25.309422]  ? __pfx_read_tsc+0x10/0x10
[   25.310043]  ? ktime_get_ts64+0x86/0x230
[   25.310609]  kunit_try_run_case+0x1b3/0x490
[   25.311458]  ? __pfx_kunit_try_run_case+0x10/0x10
[   25.312354]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   25.313195]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   25.314073]  ? __kthread_parkme+0x82/0x160
[   25.314733]  ? preempt_count_sub+0x50/0x80
[   25.315246]  ? __pfx_kunit_try_run_case+0x10/0x10
[   25.315896]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   25.316182]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   25.317365]  kthread+0x257/0x310
[   25.317710]  ? __pfx_kthread+0x10/0x10
[   25.318504]  ret_from_fork+0x41/0x80
[   25.318974]  ? __pfx_kthread+0x10/0x10
[   25.319584]  ret_from_fork_asm+0x1a/0x30
[   25.319871]  </TASK>
[   25.320205] 
[   25.320486] Allocated by task 207:
[   25.320922]  kasan_save_stack+0x3d/0x60
[   25.321358]  kasan_save_track+0x18/0x40
[   25.321707]  kasan_save_alloc_info+0x3b/0x50
[   25.322135]  __kasan_kmalloc+0xb7/0xc0
[   25.323139]  __kmalloc_cache_noprof+0x184/0x410
[   25.323966]  workqueue_uaf+0x153/0x560
[   25.325242]  kunit_try_run_case+0x1b3/0x490
[   25.325836]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   25.326882]  kthread+0x257/0x310
[   25.327409]  ret_from_fork+0x41/0x80
[   25.327711]  ret_from_fork_asm+0x1a/0x30
[   25.328253] 
[   25.328510] Freed by task 8:
[   25.328748]  kasan_save_stack+0x3d/0x60
[   25.329535]  kasan_save_track+0x18/0x40
[   25.330037]  kasan_save_free_info+0x3f/0x60
[   25.330921]  __kasan_slab_free+0x56/0x70
[   25.331130]  kfree+0x123/0x3f0
[   25.331627]  workqueue_uaf_work+0x12/0x20
[   25.332286]  process_one_work+0x5ee/0xf60
[   25.332738]  worker_thread+0x720/0x1300
[   25.333150]  kthread+0x257/0x310
[   25.333737]  ret_from_fork+0x41/0x80
[   25.334073]  ret_from_fork_asm+0x1a/0x30
[   25.335049] 
[   25.335374] Last potentially related work creation:
[   25.335997]  kasan_save_stack+0x3d/0x60
[   25.336756]  kasan_record_aux_stack+0xb2/0xc0
[   25.337509]  __queue_work+0x626/0xe60
[   25.338018]  queue_work_on+0x74/0xa0
[   25.339265]  workqueue_uaf+0x26e/0x560
[   25.339726]  kunit_try_run_case+0x1b3/0x490
[   25.340141]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   25.340780]  kthread+0x257/0x310
[   25.341340]  ret_from_fork+0x41/0x80
[   25.341744]  ret_from_fork_asm+0x1a/0x30
[   25.342829] 
[   25.343103] The buggy address belongs to the object at ffff888102956940
[   25.343103]  which belongs to the cache kmalloc-32 of size 32
[   25.344546] The buggy address is located 0 bytes inside of
[   25.344546]  freed 32-byte region [ffff888102956940, ffff888102956960)
[   25.345974] 
[   25.346819] The buggy address belongs to the physical page:
[   25.347278] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x102956
[   25.348021] flags: 0x200000000000000(node=0|zone=2)
[   25.348580] page_type: f5(slab)
[   25.349053] raw: 0200000000000000 ffff888100041780 dead000000000122 0000000000000000
[   25.349730] raw: 0000000000000000 0000000080400040 00000000f5000000 0000000000000000
[   25.350390] page dumped because: kasan: bad access detected
[   25.350848] 
[   25.351059] Memory state around the buggy address:
[   25.351913]  ffff888102956800: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   25.352665]  ffff888102956880: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   25.353507] >ffff888102956900: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   25.354107]                                            ^
[   25.354737]  ffff888102956980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   25.355918]  ffff888102956a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   25.356504] ==================================================================