Hay
Date
Dec. 4, 2024, 3:07 p.m.

Environment
qemu-arm64
qemu-x86_64

[   33.133399] ==================================================================
[   33.135468] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x480/0x4a8
[   33.136326] Read of size 8 at addr fff00000c6609440 by task kunit_try_catch/188
[   33.137242] 
[   33.138417] CPU: 0 UID: 0 PID: 188 Comm: kunit_try_catch Tainted: G    B            N 6.13.0-rc1-next-20241204 #1
[   33.139816] Tainted: [B]=BAD_PAGE, [N]=TEST
[   33.140340] Hardware name: linux,dummy-virt (DT)
[   33.140857] Call trace:
[   33.141340]  show_stack+0x20/0x38 (C)
[   33.142123]  dump_stack_lvl+0x8c/0xd0
[   33.143232]  print_report+0x118/0x5e0
[   33.143723]  kasan_report+0xc8/0x118
[   33.144571]  __asan_report_load8_noabort+0x20/0x30
[   33.145543]  workqueue_uaf+0x480/0x4a8
[   33.146189]  kunit_try_run_case+0x14c/0x3d0
[   33.146930]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   33.148144]  kthread+0x24c/0x2d0
[   33.148805]  ret_from_fork+0x10/0x20
[   33.149439] 
[   33.149770] Allocated by task 188:
[   33.150450]  kasan_save_stack+0x3c/0x68
[   33.151745]  kasan_save_track+0x20/0x40
[   33.152790]  kasan_save_alloc_info+0x40/0x58
[   33.153271]  __kasan_kmalloc+0xd4/0xd8
[   33.153847]  __kmalloc_cache_noprof+0x15c/0x3c0
[   33.155080]  workqueue_uaf+0x13c/0x4a8
[   33.155673]  kunit_try_run_case+0x14c/0x3d0
[   33.156473]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   33.157193]  kthread+0x24c/0x2d0
[   33.157935]  ret_from_fork+0x10/0x20
[   33.158442] 
[   33.158739] Freed by task 8:
[   33.159242]  kasan_save_stack+0x3c/0x68
[   33.160738]  kasan_save_track+0x20/0x40
[   33.161222]  kasan_save_free_info+0x4c/0x78
[   33.161821]  __kasan_slab_free+0x6c/0x98
[   33.162279]  kfree+0x114/0x3c8
[   33.163288]  workqueue_uaf_work+0x18/0x30
[   33.163822]  process_one_work+0x530/0xf98
[   33.164449]  worker_thread+0x614/0xf28
[   33.164994]  kthread+0x24c/0x2d0
[   33.165578]  ret_from_fork+0x10/0x20
[   33.166777] 
[   33.167128] Last potentially related work creation:
[   33.167618]  kasan_save_stack+0x3c/0x68
[   33.168320]  kasan_record_aux_stack+0xb4/0xc8
[   33.170109]  __queue_work+0x65c/0xfd8
[   33.170676]  queue_work_on+0xbc/0xf8
[   33.171247]  workqueue_uaf+0x210/0x4a8
[   33.171908]  kunit_try_run_case+0x14c/0x3d0
[   33.172497]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   33.173189]  kthread+0x24c/0x2d0
[   33.173692]  ret_from_fork+0x10/0x20
[   33.174690] 
[   33.174999] The buggy address belongs to the object at fff00000c6609440
[   33.174999]  which belongs to the cache kmalloc-32 of size 32
[   33.176406] The buggy address is located 0 bytes inside of
[   33.176406]  freed 32-byte region [fff00000c6609440, fff00000c6609460)
[   33.178751] 
[   33.179162] The buggy address belongs to the physical page:
[   33.180311] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x106609
[   33.181437] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   33.182141] page_type: f5(slab)
[   33.182731] raw: 0bfffe0000000000 fff00000c0001780 dead000000000122 0000000000000000
[   33.184394] raw: 0000000000000000 0000000080400040 00000000f5000000 0000000000000000
[   33.185328] page dumped because: kasan: bad access detected
[   33.186620] 
[   33.187320] Memory state around the buggy address:
[   33.188012]  fff00000c6609300: 00 00 00 fc fc fc fc fc 00 00 05 fc fc fc fc fc
[   33.188993]  fff00000c6609380: 00 00 07 fc fc fc fc fc 00 00 07 fc fc fc fc fc
[   33.189816] >fff00000c6609400: 00 00 00 fc fc fc fc fc fa fb fb fb fc fc fc fc
[   33.191073]                                            ^
[   33.191805]  fff00000c6609480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   33.192726]  fff00000c6609500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   33.193531] ==================================================================

[   23.937661] ==================================================================
[   23.940250] BUG: KASAN: slab-use-after-free in workqueue_uaf+0x4d8/0x560
[   23.940910] Read of size 8 at addr ffff888101aeabc0 by task kunit_try_catch/208
[   23.942057] 
[   23.943116] CPU: 0 UID: 0 PID: 208 Comm: kunit_try_catch Tainted: G    B            N 6.13.0-rc1-next-20241204 #1
[   23.944756] Tainted: [B]=BAD_PAGE, [N]=TEST
[   23.945326] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   23.946162] Call Trace:
[   23.946500]  <TASK>
[   23.946801]  dump_stack_lvl+0x73/0xb0
[   23.947689]  print_report+0xd1/0x640
[   23.948135]  ? __virt_addr_valid+0x1db/0x2d0
[   23.948780]  ? kasan_complete_mode_report_info+0x64/0x200
[   23.949233]  kasan_report+0x102/0x140
[   23.950489]  ? workqueue_uaf+0x4d8/0x560
[   23.950879]  ? workqueue_uaf+0x4d8/0x560
[   23.951301]  __asan_report_load8_noabort+0x18/0x20
[   23.951715]  workqueue_uaf+0x4d8/0x560
[   23.952753]  ? __pfx_workqueue_uaf+0x10/0x10
[   23.953213]  ? __pfx_workqueue_uaf+0x10/0x10
[   23.954096]  kunit_try_run_case+0x1b3/0x490
[   23.955028]  ? __pfx_kunit_try_run_case+0x10/0x10
[   23.955504]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   23.956703]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   23.957420]  ? __kthread_parkme+0x82/0x160
[   23.958321]  ? preempt_count_sub+0x50/0x80
[   23.958786]  ? __pfx_kunit_try_run_case+0x10/0x10
[   23.959258]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   23.960681]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   23.961220]  kthread+0x257/0x310
[   23.961614]  ? __pfx_kthread+0x10/0x10
[   23.962526]  ret_from_fork+0x41/0x80
[   23.962859]  ? __pfx_kthread+0x10/0x10
[   23.963269]  ret_from_fork_asm+0x1a/0x30
[   23.964335]  </TASK>
[   23.965102] 
[   23.965365] Allocated by task 208:
[   23.966539]  kasan_save_stack+0x3d/0x60
[   23.966952]  kasan_save_track+0x18/0x40
[   23.968139]  kasan_save_alloc_info+0x3b/0x50
[   23.969038]  __kasan_kmalloc+0xb7/0xc0
[   23.969683]  __kmalloc_cache_noprof+0x184/0x410
[   23.970188]  workqueue_uaf+0x153/0x560
[   23.970470]  kunit_try_run_case+0x1b3/0x490
[   23.971709]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   23.972109]  kthread+0x257/0x310
[   23.973145]  ret_from_fork+0x41/0x80
[   23.973912]  ret_from_fork_asm+0x1a/0x30
[   23.974459] 
[   23.974660] Freed by task 8:
[   23.975161]  kasan_save_stack+0x3d/0x60
[   23.975820]  kasan_save_track+0x18/0x40
[   23.976140]  kasan_save_free_info+0x3f/0x60
[   23.976857]  __kasan_slab_free+0x56/0x70
[   23.978222]  kfree+0x123/0x3f0
[   23.978621]  workqueue_uaf_work+0x12/0x20
[   23.979117]  process_one_work+0x5ee/0xf60
[   23.980146]  worker_thread+0x720/0x1300
[   23.980555]  kthread+0x257/0x310
[   23.981030]  ret_from_fork+0x41/0x80
[   23.982094]  ret_from_fork_asm+0x1a/0x30
[   23.982452] 
[   23.982611] Last potentially related work creation:
[   23.983296]  kasan_save_stack+0x3d/0x60
[   23.983890]  kasan_record_aux_stack+0xb2/0xc0
[   23.984364]  __queue_work+0x626/0xe60
[   23.984834]  queue_work_on+0x74/0xa0
[   23.985231]  workqueue_uaf+0x26e/0x560
[   23.985941]  kunit_try_run_case+0x1b3/0x490
[   23.986420]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   23.987110]  kthread+0x257/0x310
[   23.988139]  ret_from_fork+0x41/0x80
[   23.988440]  ret_from_fork_asm+0x1a/0x30
[   23.988980] 
[   23.989934] The buggy address belongs to the object at ffff888101aeabc0
[   23.989934]  which belongs to the cache kmalloc-32 of size 32
[   23.990792] The buggy address is located 0 bytes inside of
[   23.990792]  freed 32-byte region [ffff888101aeabc0, ffff888101aeabe0)
[   23.992663] 
[   23.992925] The buggy address belongs to the physical page:
[   23.993483] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x101aea
[   23.994225] flags: 0x200000000000000(node=0|zone=2)
[   23.995108] page_type: f5(slab)
[   23.996320] raw: 0200000000000000 ffff888100041780 dead000000000122 0000000000000000
[   23.997203] raw: 0000000000000000 0000000080400040 00000000f5000000 0000000000000000
[   23.998441] page dumped because: kasan: bad access detected
[   23.998907] 
[   23.999105] Memory state around the buggy address:
[   23.999591]  ffff888101aeaa80: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   24.000368]  ffff888101aeab00: 00 00 00 fc fc fc fc fc 00 00 03 fc fc fc fc fc
[   24.001186] >ffff888101aeab80: 00 00 07 fc fc fc fc fc fa fb fb fb fc fc fc fc
[   24.002591]                                            ^
[   24.003105]  ffff888101aeac00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   24.004140]  ffff888101aeac80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   24.005006] ==================================================================