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

Environment
qemu-arm64
qemu-x86_64

[   35.317798] ==================================================================
[   35.319306] BUG: KASAN: slab-use-after-free in kmem_cache_rcu_uaf+0x390/0x468
[   35.320363] Read of size 1 at addr fff00000c6afc000 by task kunit_try_catch/202
[   35.321711] 
[   35.322859] CPU: 0 UID: 0 PID: 202 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241122 #1
[   35.324506] Tainted: [B]=BAD_PAGE, [N]=TEST
[   35.325684] Hardware name: linux,dummy-virt (DT)
[   35.326506] Call trace:
[   35.326928]  show_stack+0x20/0x38 (C)
[   35.327750]  dump_stack_lvl+0x8c/0xd0
[   35.328585]  print_report+0x118/0x5e0
[   35.329139]  kasan_report+0xc8/0x118
[   35.329704]  __asan_report_load1_noabort+0x20/0x30
[   35.331053]  kmem_cache_rcu_uaf+0x390/0x468
[   35.332184]  kunit_try_run_case+0x14c/0x3d0
[   35.332867]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   35.334045]  kthread+0x24c/0x2d0
[   35.334605]  ret_from_fork+0x10/0x20
[   35.335314] 
[   35.335802] Allocated by task 202:
[   35.336360]  kasan_save_stack+0x3c/0x68
[   35.337370]  kasan_save_track+0x20/0x40
[   35.338099]  kasan_save_alloc_info+0x40/0x58
[   35.339018]  __kasan_slab_alloc+0xa8/0xb0
[   35.339326]  kmem_cache_alloc_noprof+0x108/0x3a0
[   35.340195]  kmem_cache_rcu_uaf+0x12c/0x468
[   35.340806]  kunit_try_run_case+0x14c/0x3d0
[   35.341879]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   35.343260]  kthread+0x24c/0x2d0
[   35.343701]  ret_from_fork+0x10/0x20
[   35.344182] 
[   35.344879] Freed by task 0:
[   35.345353]  kasan_save_stack+0x3c/0x68
[   35.346190]  kasan_save_track+0x20/0x40
[   35.346940]  kasan_save_free_info+0x4c/0x78
[   35.347614]  __kasan_slab_free+0x6c/0x98
[   35.348803]  slab_free_after_rcu_debug+0xd4/0x2f8
[   35.349350]  rcu_core+0xa54/0x1df8
[   35.350203]  rcu_core_si+0x18/0x30
[   35.351958]  handle_softirqs+0x374/0xb20
[   35.353030]  __do_softirq+0x1c/0x28
[   35.353632] 
[   35.353917] Last potentially related work creation:
[   35.354896]  kasan_save_stack+0x3c/0x68
[   35.355671]  __kasan_record_aux_stack+0xbc/0xe8
[   35.356420]  kasan_record_aux_stack_noalloc+0x14/0x20
[   35.357636]  kmem_cache_free+0x28c/0x470
[   35.359026]  kmem_cache_rcu_uaf+0x16c/0x468
[   35.359701]  kunit_try_run_case+0x14c/0x3d0
[   35.360329]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   35.361063]  kthread+0x24c/0x2d0
[   35.361589]  ret_from_fork+0x10/0x20
[   35.362755] 
[   35.363178] The buggy address belongs to the object at fff00000c6afc000
[   35.363178]  which belongs to the cache test_cache of size 200
[   35.365626] The buggy address is located 0 bytes inside of
[   35.365626]  freed 200-byte region [fff00000c6afc000, fff00000c6afc0c8)
[   35.368164] 
[   35.368974] The buggy address belongs to the physical page:
[   35.369915] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x106afc
[   35.371017] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   35.371792] page_type: f5(slab)
[   35.372407] raw: 0bfffe0000000000 fff00000c408c640 dead000000000122 0000000000000000
[   35.373947] raw: 0000000000000000 00000000800f000f 00000001f5000000 0000000000000000
[   35.374922] page dumped because: kasan: bad access detected
[   35.375603] 
[   35.376076] Memory state around the buggy address:
[   35.377271]  fff00000c6afbf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   35.378263]  fff00000c6afbf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   35.379072] >fff00000c6afc000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[   35.380061]                    ^
[   35.380525]  fff00000c6afc080: fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc
[   35.381983]  fff00000c6afc100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   35.382893] ==================================================================

[   26.424225] ==================================================================
[   26.425388] BUG: KASAN: slab-use-after-free in kmem_cache_rcu_uaf+0x3e5/0x510
[   26.426747] Read of size 1 at addr ffff888101ab7000 by task kunit_try_catch/221
[   26.427434] 
[   26.427628] CPU: 0 UID: 0 PID: 221 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241122 #1
[   26.428471] Tainted: [B]=BAD_PAGE, [N]=TEST
[   26.428923] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   26.429966] Call Trace:
[   26.430173]  <TASK>
[   26.430381]  dump_stack_lvl+0x73/0xb0
[   26.430676]  print_report+0xd1/0x640
[   26.431106]  ? __virt_addr_valid+0x1db/0x2d0
[   26.431537]  ? kasan_complete_mode_report_info+0x64/0x200
[   26.432205]  kasan_report+0x102/0x140
[   26.432696]  ? kmem_cache_rcu_uaf+0x3e5/0x510
[   26.433288]  ? kmem_cache_rcu_uaf+0x3e5/0x510
[   26.433869]  __asan_report_load1_noabort+0x18/0x20
[   26.434489]  kmem_cache_rcu_uaf+0x3e5/0x510
[   26.435015]  ? __pfx_kmem_cache_rcu_uaf+0x10/0x10
[   26.436029]  ? finish_task_switch.isra.0+0x153/0x700
[   26.436550]  ? __switch_to+0x5d9/0xf60
[   26.437138]  ? __pfx_read_tsc+0x10/0x10
[   26.437851]  ? ktime_get_ts64+0x84/0x230
[   26.438484]  kunit_try_run_case+0x1b3/0x490
[   26.438925]  ? __pfx_kunit_try_run_case+0x10/0x10
[   26.439288]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   26.439900]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   26.440329]  ? __kthread_parkme+0x82/0x160
[   26.440773]  ? preempt_count_sub+0x50/0x80
[   26.441125]  ? __pfx_kunit_try_run_case+0x10/0x10
[   26.441640]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   26.442308]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   26.442801]  kthread+0x257/0x310
[   26.443211]  ? __pfx_kthread+0x10/0x10
[   26.443726]  ret_from_fork+0x41/0x80
[   26.444057]  ? __pfx_kthread+0x10/0x10
[   26.444330]  ret_from_fork_asm+0x1a/0x30
[   26.444784]  </TASK>
[   26.445100] 
[   26.445376] Allocated by task 221:
[   26.445758]  kasan_save_stack+0x3d/0x60
[   26.446183]  kasan_save_track+0x18/0x40
[   26.446662]  kasan_save_alloc_info+0x3b/0x50
[   26.446986]  __kasan_slab_alloc+0x91/0xa0
[   26.447259]  kmem_cache_alloc_noprof+0x11e/0x3f0
[   26.448701]  kmem_cache_rcu_uaf+0x156/0x510
[   26.449298]  kunit_try_run_case+0x1b3/0x490
[   26.449735]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   26.450215]  kthread+0x257/0x310
[   26.450549]  ret_from_fork+0x41/0x80
[   26.451020]  ret_from_fork_asm+0x1a/0x30
[   26.451451] 
[   26.451647] Freed by task 0:
[   26.451927]  kasan_save_stack+0x3d/0x60
[   26.452312]  kasan_save_track+0x18/0x40
[   26.452763]  kasan_save_free_info+0x3f/0x60
[   26.453161]  __kasan_slab_free+0x56/0x70
[   26.453632]  slab_free_after_rcu_debug+0xe4/0x310
[   26.453957]  rcu_core+0x680/0x1d70
[   26.454211]  rcu_core_si+0x12/0x20
[   26.454678]  handle_softirqs+0x209/0x720
[   26.455216]  __irq_exit_rcu+0xc9/0x110
[   26.455733]  irq_exit_rcu+0x12/0x20
[   26.456168]  sysvec_apic_timer_interrupt+0x81/0x90
[   26.456520]  asm_sysvec_apic_timer_interrupt+0x1f/0x30
[   26.457060] 
[   26.457318] Last potentially related work creation:
[   26.457754]  kasan_save_stack+0x3d/0x60
[   26.458199]  __kasan_record_aux_stack+0xae/0xc0
[   26.458600]  kasan_record_aux_stack_noalloc+0xf/0x20
[   26.458970]  kmem_cache_free+0x276/0x420
[   26.459235]  kmem_cache_rcu_uaf+0x195/0x510
[   26.459764]  kunit_try_run_case+0x1b3/0x490
[   26.460229]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   26.460795]  kthread+0x257/0x310
[   26.461181]  ret_from_fork+0x41/0x80
[   26.461655]  ret_from_fork_asm+0x1a/0x30
[   26.462132] 
[   26.462374] The buggy address belongs to the object at ffff888101ab7000
[   26.462374]  which belongs to the cache test_cache of size 200
[   26.463129] The buggy address is located 0 bytes inside of
[   26.463129]  freed 200-byte region [ffff888101ab7000, ffff888101ab70c8)
[   26.464129] 
[   26.464356] The buggy address belongs to the physical page:
[   26.464685] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x101ab7
[   26.465508] flags: 0x200000000000000(node=0|zone=2)
[   26.465856] page_type: f5(slab)
[   26.466280] raw: 0200000000000000 ffff888101a673c0 dead000000000122 0000000000000000
[   26.466790] raw: 0000000000000000 00000000800f000f 00000001f5000000 0000000000000000
[   26.467461] page dumped because: kasan: bad access detected
[   26.467976] 
[   26.468156] Memory state around the buggy address:
[   26.468479]  ffff888101ab6f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   26.468983]  ffff888101ab6f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   26.469669] >ffff888101ab7000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[   26.470367]                    ^
[   26.470717]  ffff888101ab7080: fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc
[   26.471197]  ffff888101ab7100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   26.471952] ==================================================================