Hay
Date
Nov. 27, 2024, 3:37 a.m.

Environment
qemu-arm64
qemu-x86_64

[   48.369793] ==================================================================
[   48.371561] BUG: KASAN: slab-use-after-free in kmalloc_double_kzfree+0x168/0x308
[   48.372351] Read of size 1 at addr fff00000c5f55300 by task kunit_try_catch/181
[   48.373020] 
[   48.373768] CPU: 0 UID: 0 PID: 181 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241127 #1
[   48.375246] Tainted: [B]=BAD_PAGE, [N]=TEST
[   48.375799] Hardware name: linux,dummy-virt (DT)
[   48.376400] Call trace:
[   48.376767]  show_stack+0x20/0x38 (C)
[   48.377627]  dump_stack_lvl+0x8c/0xd0
[   48.378179]  print_report+0x118/0x5e0
[   48.378836]  kasan_report+0xc8/0x118
[   48.379948]  __kasan_check_byte+0x54/0x70
[   48.380782]  kfree_sensitive+0x30/0xb0
[   48.381830]  kmalloc_double_kzfree+0x168/0x308
[   48.382508]  kunit_try_run_case+0x14c/0x3d0
[   48.383257]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   48.384188]  kthread+0x24c/0x2d0
[   48.384793]  ret_from_fork+0x10/0x20
[   48.385494] 
[   48.386491] Allocated by task 181:
[   48.387003]  kasan_save_stack+0x3c/0x68
[   48.387700]  kasan_save_track+0x20/0x40
[   48.388380]  kasan_save_alloc_info+0x40/0x58
[   48.389160]  __kasan_kmalloc+0xd4/0xd8
[   48.389915]  __kmalloc_cache_noprof+0x15c/0x3c0
[   48.390606]  kmalloc_double_kzfree+0xb8/0x308
[   48.391258]  kunit_try_run_case+0x14c/0x3d0
[   48.391917]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   48.392724]  kthread+0x24c/0x2d0
[   48.393427]  ret_from_fork+0x10/0x20
[   48.394664] 
[   48.395019] Freed by task 181:
[   48.395645]  kasan_save_stack+0x3c/0x68
[   48.396259]  kasan_save_track+0x20/0x40
[   48.397012]  kasan_save_free_info+0x4c/0x78
[   48.398009]  __kasan_slab_free+0x6c/0x98
[   48.398601]  kfree+0x114/0x3c8
[   48.399113]  kfree_sensitive+0x80/0xb0
[   48.399999]  kmalloc_double_kzfree+0x11c/0x308
[   48.400881]  kunit_try_run_case+0x14c/0x3d0
[   48.401726]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   48.402258]  kthread+0x24c/0x2d0
[   48.402885]  ret_from_fork+0x10/0x20
[   48.403635] 
[   48.404154] The buggy address belongs to the object at fff00000c5f55300
[   48.404154]  which belongs to the cache kmalloc-16 of size 16
[   48.405690] The buggy address is located 0 bytes inside of
[   48.405690]  freed 16-byte region [fff00000c5f55300, fff00000c5f55310)
[   48.407216] 
[   48.407636] The buggy address belongs to the physical page:
[   48.408421] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x105f55
[   48.409820] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   48.410667] page_type: f5(slab)
[   48.411391] raw: 0bfffe0000000000 fff00000c0001640 dead000000000122 0000000000000000
[   48.412267] raw: 0000000000000000 0000000080800080 00000001f5000000 0000000000000000
[   48.413638] page dumped because: kasan: bad access detected
[   48.414506] 
[   48.414985] Memory state around the buggy address:
[   48.415812]  fff00000c5f55200: 00 05 fc fc fa fb fc fc 00 02 fc fc fa fb fc fc
[   48.416668]  fff00000c5f55280: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
[   48.417597] >fff00000c5f55300: fa fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   48.418511]                    ^
[   48.419221]  fff00000c5f55380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   48.420039]  fff00000c5f55400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   48.421492] ==================================================================

[   25.599443] ==================================================================
[   25.601143] BUG: KASAN: slab-use-after-free in kmalloc_double_kzfree+0x19d/0x360
[   25.602505] Read of size 1 at addr ffff888102699d60 by task kunit_try_catch/200
[   25.603441] 
[   25.603657] CPU: 0 UID: 0 PID: 200 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241127 #1
[   25.605747] Tainted: [B]=BAD_PAGE, [N]=TEST
[   25.606045] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   25.607548] Call Trace:
[   25.608134]  <TASK>
[   25.608416]  dump_stack_lvl+0x73/0xb0
[   25.609408]  print_report+0xd1/0x640
[   25.609670]  ? __virt_addr_valid+0x1db/0x2d0
[   25.610225]  ? kasan_complete_mode_report_info+0x64/0x200
[   25.610742]  kasan_report+0x102/0x140
[   25.611428]  ? kmalloc_double_kzfree+0x19d/0x360
[   25.612227]  ? kmalloc_double_kzfree+0x19d/0x360
[   25.613233]  ? kmalloc_double_kzfree+0x19d/0x360
[   25.613752]  __kasan_check_byte+0x3d/0x50
[   25.614371]  kfree_sensitive+0x22/0x90
[   25.614842]  kmalloc_double_kzfree+0x19d/0x360
[   25.615510]  ? __pfx_kmalloc_double_kzfree+0x10/0x10
[   25.615861]  ? __schedule+0xc3e/0x2790
[   25.616553]  ? __pfx_read_tsc+0x10/0x10
[   25.616977]  ? ktime_get_ts64+0x84/0x230
[   25.617756]  kunit_try_run_case+0x1b3/0x490
[   25.618466]  ? __pfx_kunit_try_run_case+0x10/0x10
[   25.619162]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   25.619738]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   25.620467]  ? __kthread_parkme+0x82/0x160
[   25.621342]  ? preempt_count_sub+0x50/0x80
[   25.621753]  ? __pfx_kunit_try_run_case+0x10/0x10
[   25.622412]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   25.622957]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   25.623604]  kthread+0x257/0x310
[   25.624223]  ? __pfx_kthread+0x10/0x10
[   25.624583]  ret_from_fork+0x41/0x80
[   25.625043]  ? __pfx_kthread+0x10/0x10
[   25.625430]  ret_from_fork_asm+0x1a/0x30
[   25.625821]  </TASK>
[   25.626442] 
[   25.626626] Allocated by task 200:
[   25.627229]  kasan_save_stack+0x3d/0x60
[   25.627611]  kasan_save_track+0x18/0x40
[   25.628321]  kasan_save_alloc_info+0x3b/0x50
[   25.628640]  __kasan_kmalloc+0xb7/0xc0
[   25.629186]  __kmalloc_cache_noprof+0x184/0x410
[   25.629768]  kmalloc_double_kzfree+0xaa/0x360
[   25.630721]  kunit_try_run_case+0x1b3/0x490
[   25.631385]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   25.632153]  kthread+0x257/0x310
[   25.632516]  ret_from_fork+0x41/0x80
[   25.632932]  ret_from_fork_asm+0x1a/0x30
[   25.633350] 
[   25.633735] Freed by task 200:
[   25.634439]  kasan_save_stack+0x3d/0x60
[   25.634776]  kasan_save_track+0x18/0x40
[   25.635481]  kasan_save_free_info+0x3f/0x60
[   25.635877]  __kasan_slab_free+0x56/0x70
[   25.636543]  kfree+0x123/0x3f0
[   25.637050]  kfree_sensitive+0x67/0x90
[   25.637463]  kmalloc_double_kzfree+0x12c/0x360
[   25.637872]  kunit_try_run_case+0x1b3/0x490
[   25.638723]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   25.639422]  kthread+0x257/0x310
[   25.639683]  ret_from_fork+0x41/0x80
[   25.640186]  ret_from_fork_asm+0x1a/0x30
[   25.640542] 
[   25.640801] The buggy address belongs to the object at ffff888102699d60
[   25.640801]  which belongs to the cache kmalloc-16 of size 16
[   25.641707] The buggy address is located 0 bytes inside of
[   25.641707]  freed 16-byte region [ffff888102699d60, ffff888102699d70)
[   25.643266] 
[   25.643446] The buggy address belongs to the physical page:
[   25.644403] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x102699
[   25.644851] flags: 0x200000000000000(node=0|zone=2)
[   25.645576] page_type: f5(slab)
[   25.646363] raw: 0200000000000000 ffff888100041640 dead000000000122 0000000000000000
[   25.647214] raw: 0000000000000000 0000000080800080 00000001f5000000 0000000000000000
[   25.647778] page dumped because: kasan: bad access detected
[   25.648548] 
[   25.648699] Memory state around the buggy address:
[   25.649496]  ffff888102699c00: 00 02 fc fc 00 02 fc fc 00 02 fc fc fa fb fc fc
[   25.650365]  ffff888102699c80: fa fb fc fc fa fb fc fc 00 05 fc fc 00 04 fc fc
[   25.651236] >ffff888102699d00: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
[   25.651853]                                                        ^
[   25.652587]  ffff888102699d80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   25.653639]  ffff888102699e00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   25.654567] ==================================================================