Hay
Date
Dec. 5, 2024, 2:07 p.m.

Environment
qemu-arm64
qemu-x86_64

[   31.109007] ==================================================================
[   31.109932] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x480/0x4a8
[   31.111114] Read of size 8 at addr fff00000c655f1c0 by task kunit_try_catch/189
[   31.111980] 
[   31.112330] CPU: 1 UID: 0 PID: 189 Comm: kunit_try_catch Tainted: G    B            N 6.13.0-rc1-next-20241205 #1
[   31.114319] Tainted: [B]=BAD_PAGE, [N]=TEST
[   31.115241] Hardware name: linux,dummy-virt (DT)
[   31.116294] Call trace:
[   31.116606]  show_stack+0x20/0x38 (C)
[   31.117507]  dump_stack_lvl+0x8c/0xd0
[   31.118197]  print_report+0x118/0x5e0
[   31.118844]  kasan_report+0xc8/0x118
[   31.119562]  __asan_report_load8_noabort+0x20/0x30
[   31.120477]  workqueue_uaf+0x480/0x4a8
[   31.121209]  kunit_try_run_case+0x14c/0x3d0
[   31.122063]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   31.122816]  kthread+0x24c/0x2d0
[   31.124102]  ret_from_fork+0x10/0x20
[   31.124641] 
[   31.124981] Allocated by task 189:
[   31.125525]  kasan_save_stack+0x3c/0x68
[   31.126181]  kasan_save_track+0x20/0x40
[   31.126772]  kasan_save_alloc_info+0x40/0x58
[   31.127592]  __kasan_kmalloc+0xd4/0xd8
[   31.128302]  __kmalloc_cache_noprof+0x15c/0x3c0
[   31.128847]  workqueue_uaf+0x13c/0x4a8
[   31.129359]  kunit_try_run_case+0x14c/0x3d0
[   31.130064]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   31.130671]  kthread+0x24c/0x2d0
[   31.131330]  ret_from_fork+0x10/0x20
[   31.132097] 
[   31.132475] Freed by task 31:
[   31.132995]  kasan_save_stack+0x3c/0x68
[   31.133694]  kasan_save_track+0x20/0x40
[   31.134342]  kasan_save_free_info+0x4c/0x78
[   31.134938]  __kasan_slab_free+0x6c/0x98
[   31.135892]  kfree+0x114/0x3c8
[   31.136335]  workqueue_uaf_work+0x18/0x30
[   31.137028]  process_one_work+0x530/0xf98
[   31.137621]  worker_thread+0x614/0xf28
[   31.138383]  kthread+0x24c/0x2d0
[   31.138855]  ret_from_fork+0x10/0x20
[   31.139862] 
[   31.140232] Last potentially related work creation:
[   31.140823]  kasan_save_stack+0x3c/0x68
[   31.141450]  kasan_record_aux_stack+0xb4/0xc8
[   31.142111]  __queue_work+0x65c/0xfd8
[   31.142636]  queue_work_on+0xbc/0xf8
[   31.143490]  workqueue_uaf+0x210/0x4a8
[   31.144036]  kunit_try_run_case+0x14c/0x3d0
[   31.144637]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   31.145419]  kthread+0x24c/0x2d0
[   31.146031]  ret_from_fork+0x10/0x20
[   31.146603] 
[   31.146933] The buggy address belongs to the object at fff00000c655f1c0
[   31.146933]  which belongs to the cache kmalloc-32 of size 32
[   31.149128] The buggy address is located 0 bytes inside of
[   31.149128]  freed 32-byte region [fff00000c655f1c0, fff00000c655f1e0)
[   31.150613] 
[   31.150925] The buggy address belongs to the physical page:
[   31.151893] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10655f
[   31.152822] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   31.153735] page_type: f5(slab)
[   31.154216] raw: 0bfffe0000000000 fff00000c0001780 dead000000000122 0000000000000000
[   31.155131] raw: 0000000000000000 0000000080400040 00000000f5000000 0000000000000000
[   31.156255] page dumped because: kasan: bad access detected
[   31.157112] 
[   31.157485] Memory state around the buggy address:
[   31.158226]  fff00000c655f080: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   31.159457]  fff00000c655f100: fa fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc
[   31.160370] >fff00000c655f180: 00 00 00 07 fc fc fc fc fa fb fb fb fc fc fc fc
[   31.161280]                                            ^
[   31.162003]  fff00000c655f200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   31.162828]  fff00000c655f280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   31.163947] ==================================================================

[   28.967523] ==================================================================
[   28.968374] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x4d8/0x560
[   28.968817] Read of size 8 at addr ffff888101ab1b40 by task kunit_try_catch/207
[   28.970300] 
[   28.970582] CPU: 0 UID: 0 PID: 207 Comm: kunit_try_catch Tainted: G    B            N 6.13.0-rc1-next-20241205 #1
[   28.971941] Tainted: [B]=BAD_PAGE, [N]=TEST
[   28.972369] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   28.973992] Call Trace:
[   28.974389]  <TASK>
[   28.975099]  dump_stack_lvl+0x73/0xb0
[   28.975493]  print_report+0xd1/0x640
[   28.975916]  ? __virt_addr_valid+0x1db/0x2d0
[   28.976975]  ? kasan_complete_mode_report_info+0x64/0x200
[   28.977638]  kasan_report+0x102/0x140
[   28.978363]  ? workqueue_uaf+0x4d8/0x560
[   28.978796]  ? workqueue_uaf+0x4d8/0x560
[   28.979449]  __asan_report_load8_noabort+0x18/0x20
[   28.980400]  workqueue_uaf+0x4d8/0x560
[   28.980605]  ? __pfx_workqueue_uaf+0x10/0x10
[   28.981313]  ? __schedule+0xc70/0x27e0
[   28.981862]  ? __pfx_read_tsc+0x10/0x10
[   28.982214]  ? ktime_get_ts64+0x86/0x230
[   28.982561]  kunit_try_run_case+0x1b3/0x490
[   28.983343]  ? __pfx_kunit_try_run_case+0x10/0x10
[   28.983928]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   28.984421]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   28.984967]  ? __kthread_parkme+0x82/0x160
[   28.985513]  ? preempt_count_sub+0x50/0x80
[   28.986113]  ? __pfx_kunit_try_run_case+0x10/0x10
[   28.986595]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   28.987410]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   28.987876]  kthread+0x257/0x310
[   28.988488]  ? __pfx_kthread+0x10/0x10
[   28.989111]  ret_from_fork+0x41/0x80
[   28.989583]  ? __pfx_kthread+0x10/0x10
[   28.990032]  ret_from_fork_asm+0x1a/0x30
[   28.990360]  </TASK>
[   28.990666] 
[   28.990957] Allocated by task 207:
[   28.991342]  kasan_save_stack+0x3d/0x60
[   28.991964]  kasan_save_track+0x18/0x40
[   28.992471]  kasan_save_alloc_info+0x3b/0x50
[   28.992953]  __kasan_kmalloc+0xb7/0xc0
[   28.993509]  __kmalloc_cache_noprof+0x184/0x410
[   28.994182]  workqueue_uaf+0x153/0x560
[   28.994524]  kunit_try_run_case+0x1b3/0x490
[   28.995105]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   28.995733]  kthread+0x257/0x310
[   28.996180]  ret_from_fork+0x41/0x80
[   28.996625]  ret_from_fork_asm+0x1a/0x30
[   28.997295] 
[   28.997469] Freed by task 9:
[   28.997883]  kasan_save_stack+0x3d/0x60
[   28.998370]  kasan_save_track+0x18/0x40
[   28.999255]  kasan_save_free_info+0x3f/0x60
[   28.999749]  __kasan_slab_free+0x56/0x70
[   29.000376]  kfree+0x123/0x3f0
[   29.000764]  workqueue_uaf_work+0x12/0x20
[   29.001379]  process_one_work+0x5ee/0xf60
[   29.001754]  worker_thread+0x720/0x1300
[   29.002491]  kthread+0x257/0x310
[   29.002857]  ret_from_fork+0x41/0x80
[   29.003262]  ret_from_fork_asm+0x1a/0x30
[   29.003787] 
[   29.003997] Last potentially related work creation:
[   29.004492]  kasan_save_stack+0x3d/0x60
[   29.005188]  kasan_record_aux_stack+0xb2/0xc0
[   29.005500]  __queue_work+0x626/0xe60
[   29.005927]  queue_work_on+0x74/0xa0
[   29.006513]  workqueue_uaf+0x26e/0x560
[   29.007096]  kunit_try_run_case+0x1b3/0x490
[   29.007512]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   29.007930]  kthread+0x257/0x310
[   29.008387]  ret_from_fork+0x41/0x80
[   29.008896]  ret_from_fork_asm+0x1a/0x30
[   29.009474] 
[   29.009755] The buggy address belongs to the object at ffff888101ab1b40
[   29.009755]  which belongs to the cache kmalloc-32 of size 32
[   29.010953] The buggy address is located 0 bytes inside of
[   29.010953]  freed 32-byte region [ffff888101ab1b40, ffff888101ab1b60)
[   29.012457] 
[   29.012718] The buggy address belongs to the physical page:
[   29.013276] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x101ab1
[   29.014238] flags: 0x200000000000000(node=0|zone=2)
[   29.014869] page_type: f5(slab)
[   29.015229] raw: 0200000000000000 ffff888100041780 dead000000000122 0000000000000000
[   29.015874] raw: 0000000000000000 0000000080400040 00000000f5000000 0000000000000000
[   29.016521] page dumped because: kasan: bad access detected
[   29.017315] 
[   29.017557] Memory state around the buggy address:
[   29.018233]  ffff888101ab1a00: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   29.018870]  ffff888101ab1a80: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   29.019707] >ffff888101ab1b00: 00 00 00 fc fc fc fc fc fa fb fb fb fc fc fc fc
[   29.020418]                                            ^
[   29.021591]  ffff888101ab1b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   29.022213]  ffff888101ab1c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   29.022770] ==================================================================