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

Environment
qemu-arm64
qemu-x86_64

[   38.058115] ==================================================================
[   38.059118] BUG: KASAN: slab-use-after-free in kmem_cache_rcu_uaf+0x390/0x468
[   38.059913] Read of size 1 at addr fff00000c65c1000 by task kunit_try_catch/202
[   38.060754] 
[   38.061131] CPU: 0 UID: 0 PID: 202 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241120 #1
[   38.062654] Tainted: [B]=BAD_PAGE, [N]=TEST
[   38.063075] Hardware name: linux,dummy-virt (DT)
[   38.063657] Call trace:
[   38.064080]  show_stack+0x20/0x38 (C)
[   38.064703]  dump_stack_lvl+0x8c/0xd0
[   38.065292]  print_report+0x118/0x5e0
[   38.066312]  kasan_report+0xc8/0x118
[   38.066884]  __asan_report_load1_noabort+0x20/0x30
[   38.067486]  kmem_cache_rcu_uaf+0x390/0x468
[   38.068101]  kunit_try_run_case+0x14c/0x3d0
[   38.068633]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   38.069554]  kthread+0x24c/0x2d0
[   38.070137]  ret_from_fork+0x10/0x20
[   38.070667] 
[   38.070977] Allocated by task 202:
[   38.071482]  kasan_save_stack+0x3c/0x68
[   38.072050]  kasan_save_track+0x20/0x40
[   38.072631]  kasan_save_alloc_info+0x40/0x58
[   38.073226]  __kasan_slab_alloc+0xa8/0xb0
[   38.074100]  kmem_cache_alloc_noprof+0x108/0x3a0
[   38.075037]  kmem_cache_rcu_uaf+0x12c/0x468
[   38.075622]  kunit_try_run_case+0x14c/0x3d0
[   38.076194]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   38.076899]  kthread+0x24c/0x2d0
[   38.077782]  ret_from_fork+0x10/0x20
[   38.078515] 
[   38.078866] Freed by task 0:
[   38.079285]  kasan_save_stack+0x3c/0x68
[   38.079884]  kasan_save_track+0x20/0x40
[   38.080566]  kasan_save_free_info+0x4c/0x78
[   38.081268]  __kasan_slab_free+0x6c/0x98
[   38.081920]  slab_free_after_rcu_debug+0xd4/0x2f8
[   38.082570]  rcu_core+0xa54/0x1df8
[   38.083560]  rcu_core_si+0x18/0x30
[   38.083957]  handle_softirqs+0x374/0xb20
[   38.084482]  __do_softirq+0x1c/0x28
[   38.085618] 
[   38.085907] Last potentially related work creation:
[   38.086768]  kasan_save_stack+0x3c/0x68
[   38.087274]  __kasan_record_aux_stack+0xbc/0xe8
[   38.087932]  kasan_record_aux_stack_noalloc+0x14/0x20
[   38.088523]  kmem_cache_free+0x28c/0x470
[   38.089104]  kmem_cache_rcu_uaf+0x16c/0x468
[   38.089685]  kunit_try_run_case+0x14c/0x3d0
[   38.090301]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   38.091034]  kthread+0x24c/0x2d0
[   38.091848]  ret_from_fork+0x10/0x20
[   38.092432] 
[   38.092784] The buggy address belongs to the object at fff00000c65c1000
[   38.092784]  which belongs to the cache test_cache of size 200
[   38.094373] The buggy address is located 0 bytes inside of
[   38.094373]  freed 200-byte region [fff00000c65c1000, fff00000c65c10c8)
[   38.095647] 
[   38.095972] The buggy address belongs to the physical page:
[   38.096592] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1065c1
[   38.097908] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   38.098775] page_type: f5(slab)
[   38.099248] raw: 0bfffe0000000000 fff00000c652d140 dead000000000122 0000000000000000
[   38.100010] raw: 0000000000000000 00000000800f000f 00000001f5000000 0000000000000000
[   38.100879] page dumped because: kasan: bad access detected
[   38.102010] 
[   38.102618] Memory state around the buggy address:
[   38.103052]  fff00000c65c0f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   38.103978]  fff00000c65c0f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   38.104747] >fff00000c65c1000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[   38.106207]                    ^
[   38.106804]  fff00000c65c1080: fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc
[   38.107161]  fff00000c65c1100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   38.107576] ==================================================================

[   29.585441] ==================================================================
[   29.587365] BUG: KASAN: slab-use-after-free in kmem_cache_rcu_uaf+0x3e5/0x510
[   29.588135] Read of size 1 at addr ffff8881029ef000 by task kunit_try_catch/220
[   29.589048] 
[   29.589348] CPU: 1 UID: 0 PID: 220 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241120 #1
[   29.591291] Tainted: [B]=BAD_PAGE, [N]=TEST
[   29.591564] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   29.592865] Call Trace:
[   29.593266]  <TASK>
[   29.593647]  dump_stack_lvl+0x73/0xb0
[   29.594421]  print_report+0xd1/0x640
[   29.594863]  ? __virt_addr_valid+0x1db/0x2d0
[   29.595311]  ? kasan_complete_mode_report_info+0x64/0x200
[   29.595859]  kasan_report+0x102/0x140
[   29.596247]  ? kmem_cache_rcu_uaf+0x3e5/0x510
[   29.596761]  ? kmem_cache_rcu_uaf+0x3e5/0x510
[   29.597121]  __asan_report_load1_noabort+0x18/0x20
[   29.597532]  kmem_cache_rcu_uaf+0x3e5/0x510
[   29.598139]  ? __pfx_kmem_cache_rcu_uaf+0x10/0x10
[   29.598462]  ? sysvec_apic_timer_interrupt+0x50/0x90
[   29.599263]  ? __pfx_kmem_cache_rcu_uaf+0x10/0x10
[   29.599982]  kunit_try_run_case+0x1b3/0x490
[   29.600542]  ? __pfx_kunit_try_run_case+0x10/0x10
[   29.600929]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   29.601980]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   29.602680]  ? __kthread_parkme+0x82/0x160
[   29.603153]  ? preempt_count_sub+0x50/0x80
[   29.603515]  ? __pfx_kunit_try_run_case+0x10/0x10
[   29.604245]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   29.605191]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   29.605749]  kthread+0x257/0x310
[   29.606194]  ? __pfx_kthread+0x10/0x10
[   29.606563]  ret_from_fork+0x41/0x80
[   29.607167]  ? __pfx_kthread+0x10/0x10
[   29.607522]  ret_from_fork_asm+0x1a/0x30
[   29.608190]  </TASK>
[   29.609000] 
[   29.609149] Allocated by task 220:
[   29.610109]  kasan_save_stack+0x3d/0x60
[   29.610647]  kasan_save_track+0x18/0x40
[   29.611051]  kasan_save_alloc_info+0x3b/0x50
[   29.611631]  __kasan_slab_alloc+0x91/0xa0
[   29.612802]  kmem_cache_alloc_noprof+0x11e/0x3f0
[   29.613489]  kmem_cache_rcu_uaf+0x156/0x510
[   29.614530]  kunit_try_run_case+0x1b3/0x490
[   29.615162]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   29.616301]  kthread+0x257/0x310
[   29.616567]  ret_from_fork+0x41/0x80
[   29.617075]  ret_from_fork_asm+0x1a/0x30
[   29.617505] 
[   29.618295] Freed by task 0:
[   29.618705]  kasan_save_stack+0x3d/0x60
[   29.619810]  kasan_save_track+0x18/0x40
[   29.620215]  kasan_save_free_info+0x3f/0x60
[   29.621168]  __kasan_slab_free+0x56/0x70
[   29.621452]  slab_free_after_rcu_debug+0xe4/0x310
[   29.621980]  rcu_core+0x680/0x1d70
[   29.622338]  rcu_core_si+0x12/0x20
[   29.623315]  handle_softirqs+0x209/0x720
[   29.624192]  __irq_exit_rcu+0xc9/0x110
[   29.624948]  irq_exit_rcu+0x12/0x20
[   29.625141]  sysvec_apic_timer_interrupt+0x81/0x90
[   29.625889]  asm_sysvec_apic_timer_interrupt+0x1f/0x30
[   29.627056] 
[   29.627428] Last potentially related work creation:
[   29.627865]  kasan_save_stack+0x3d/0x60
[   29.628987]  __kasan_record_aux_stack+0xae/0xc0
[   29.630078]  kasan_record_aux_stack_noalloc+0xf/0x20
[   29.630841]  kmem_cache_free+0x276/0x420
[   29.631032]  kmem_cache_rcu_uaf+0x195/0x510
[   29.631222]  kunit_try_run_case+0x1b3/0x490
[   29.631875]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   29.632490]  kthread+0x257/0x310
[   29.632770]  ret_from_fork+0x41/0x80
[   29.633247]  ret_from_fork_asm+0x1a/0x30
[   29.633824] 
[   29.633999] The buggy address belongs to the object at ffff8881029ef000
[   29.633999]  which belongs to the cache test_cache of size 200
[   29.635522] The buggy address is located 0 bytes inside of
[   29.635522]  freed 200-byte region [ffff8881029ef000, ffff8881029ef0c8)
[   29.636414] 
[   29.636738] The buggy address belongs to the physical page:
[   29.637338] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1029ef
[   29.638112] flags: 0x200000000000000(node=0|zone=2)
[   29.638843] page_type: f5(slab)
[   29.639136] raw: 0200000000000000 ffff888101ebc8c0 dead000000000122 0000000000000000
[   29.640751] raw: 0000000000000000 00000000800f000f 00000001f5000000 0000000000000000
[   29.641955] page dumped because: kasan: bad access detected
[   29.642819] 
[   29.643348] Memory state around the buggy address:
[   29.644298]  ffff8881029eef00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   29.645013]  ffff8881029eef80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   29.645946] >ffff8881029ef000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[   29.647111]                    ^
[   29.647520]  ffff8881029ef080: fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc
[   29.648572]  ffff8881029ef100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   29.649352] ==================================================================