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

Environment
qemu-arm64
qemu-x86_64

[   37.210800] ==================================================================
[   37.212269] BUG: KASAN: slab-use-after-free in kmalloc_double_kzfree+0x168/0x308
[   37.213321] Read of size 1 at addr fff00000c5a3bf20 by task kunit_try_catch/181
[   37.215004] 
[   37.215381] CPU: 1 UID: 0 PID: 181 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241120 #1
[   37.216432] Tainted: [B]=BAD_PAGE, [N]=TEST
[   37.217016] Hardware name: linux,dummy-virt (DT)
[   37.217557] Call trace:
[   37.217970]  show_stack+0x20/0x38 (C)
[   37.218614]  dump_stack_lvl+0x8c/0xd0
[   37.219152]  print_report+0x118/0x5e0
[   37.219766]  kasan_report+0xc8/0x118
[   37.220336]  __kasan_check_byte+0x54/0x70
[   37.220903]  kfree_sensitive+0x30/0xb0
[   37.221487]  kmalloc_double_kzfree+0x168/0x308
[   37.222078]  kunit_try_run_case+0x14c/0x3d0
[   37.222653]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.223323]  kthread+0x24c/0x2d0
[   37.223891]  ret_from_fork+0x10/0x20
[   37.224489] 
[   37.224780] Allocated by task 181:
[   37.225280]  kasan_save_stack+0x3c/0x68
[   37.225863]  kasan_save_track+0x20/0x40
[   37.226416]  kasan_save_alloc_info+0x40/0x58
[   37.226930]  __kasan_kmalloc+0xd4/0xd8
[   37.227505]  __kmalloc_cache_noprof+0x15c/0x3c8
[   37.228106]  kmalloc_double_kzfree+0xb8/0x308
[   37.228705]  kunit_try_run_case+0x14c/0x3d0
[   37.229318]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.229894]  kthread+0x24c/0x2d0
[   37.230406]  ret_from_fork+0x10/0x20
[   37.230942] 
[   37.231276] Freed by task 181:
[   37.231754]  kasan_save_stack+0x3c/0x68
[   37.232285]  kasan_save_track+0x20/0x40
[   37.232800]  kasan_save_free_info+0x4c/0x78
[   37.233396]  __kasan_slab_free+0x6c/0x98
[   37.234001]  kfree+0x114/0x3d0
[   37.234534]  kfree_sensitive+0x80/0xb0
[   37.235093]  kmalloc_double_kzfree+0x11c/0x308
[   37.235565]  kunit_try_run_case+0x14c/0x3d0
[   37.235843]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.236133]  kthread+0x24c/0x2d0
[   37.236360]  ret_from_fork+0x10/0x20
[   37.236969] 
[   37.237255] The buggy address belongs to the object at fff00000c5a3bf20
[   37.237255]  which belongs to the cache kmalloc-16 of size 16
[   37.238377] The buggy address is located 0 bytes inside of
[   37.238377]  freed 16-byte region [fff00000c5a3bf20, fff00000c5a3bf30)
[   37.239283] 
[   37.239590] The buggy address belongs to the physical page:
[   37.240289] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x105a3b
[   37.241222] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   37.242043] page_type: f5(slab)
[   37.242585] raw: 0bfffe0000000000 fff00000c0001640 dead000000000122 0000000000000000
[   37.243505] raw: 0000000000000000 0000000080800080 00000001f5000000 0000000000000000
[   37.244268] page dumped because: kasan: bad access detected
[   37.244894] 
[   37.245231] Memory state around the buggy address:
[   37.245875]  fff00000c5a3be00: fa fb fc fc 00 02 fc fc fa fb fc fc fa fb fc fc
[   37.246557]  fff00000c5a3be80: fa fb fc fc fa fb fc fc fa fb fc fc 00 04 fc fc
[   37.247404] >fff00000c5a3bf00: fa fb fc fc fa fb fc fc fc fc fc fc fc fc fc fc
[   37.248254]                                ^
[   37.248859]  fff00000c5a3bf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   37.249725]  fff00000c5a3c000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[   37.250494] ==================================================================

[   28.705418] ==================================================================
[   28.707367] BUG: KASAN: slab-use-after-free in kmalloc_double_kzfree+0x19d/0x360
[   28.708129] Read of size 1 at addr ffff8881025fee80 by task kunit_try_catch/199
[   28.708798] 
[   28.709166] CPU: 1 UID: 0 PID: 199 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241120 #1
[   28.710374] Tainted: [B]=BAD_PAGE, [N]=TEST
[   28.710920] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   28.711913] Call Trace:
[   28.712402]  <TASK>
[   28.712757]  dump_stack_lvl+0x73/0xb0
[   28.713417]  print_report+0xd1/0x640
[   28.713988]  ? __virt_addr_valid+0x1db/0x2d0
[   28.714466]  ? kasan_complete_mode_report_info+0x64/0x200
[   28.715152]  kasan_report+0x102/0x140
[   28.715841]  ? kmalloc_double_kzfree+0x19d/0x360
[   28.716491]  ? kmalloc_double_kzfree+0x19d/0x360
[   28.717192]  ? kmalloc_double_kzfree+0x19d/0x360
[   28.717575]  __kasan_check_byte+0x3d/0x50
[   28.718050]  kfree_sensitive+0x22/0x90
[   28.718489]  kmalloc_double_kzfree+0x19d/0x360
[   28.719024]  ? __pfx_kmalloc_double_kzfree+0x10/0x10
[   28.719803]  ? __schedule+0xc3e/0x2790
[   28.720379]  ? __pfx_read_tsc+0x10/0x10
[   28.720864]  ? ktime_get_ts64+0x84/0x230
[   28.721419]  kunit_try_run_case+0x1b3/0x490
[   28.721865]  ? __pfx_kunit_try_run_case+0x10/0x10
[   28.722443]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   28.722945]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   28.723443]  ? __kthread_parkme+0x82/0x160
[   28.724011]  ? preempt_count_sub+0x50/0x80
[   28.724501]  ? __pfx_kunit_try_run_case+0x10/0x10
[   28.725013]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   28.725885]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   28.726532]  kthread+0x257/0x310
[   28.726984]  ? __pfx_kthread+0x10/0x10
[   28.727386]  ret_from_fork+0x41/0x80
[   28.727906]  ? __pfx_kthread+0x10/0x10
[   28.728497]  ret_from_fork_asm+0x1a/0x30
[   28.729053]  </TASK>
[   28.729417] 
[   28.729682] Allocated by task 199:
[   28.730070]  kasan_save_stack+0x3d/0x60
[   28.730739]  kasan_save_track+0x18/0x40
[   28.731325]  kasan_save_alloc_info+0x3b/0x50
[   28.731771]  __kasan_kmalloc+0xb7/0xc0
[   28.732109]  __kmalloc_cache_noprof+0x184/0x410
[   28.732582]  kmalloc_double_kzfree+0xaa/0x360
[   28.733082]  kunit_try_run_case+0x1b3/0x490
[   28.733574]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   28.734228]  kthread+0x257/0x310
[   28.734724]  ret_from_fork+0x41/0x80
[   28.735711]  ret_from_fork_asm+0x1a/0x30
[   28.736578] 
[   28.736791] Freed by task 199:
[   28.737161]  kasan_save_stack+0x3d/0x60
[   28.738238]  kasan_save_track+0x18/0x40
[   28.738757]  kasan_save_free_info+0x3f/0x60
[   28.739137]  __kasan_slab_free+0x56/0x70
[   28.739872]  kfree+0x123/0x3f0
[   28.740217]  kfree_sensitive+0x67/0x90
[   28.740717]  kmalloc_double_kzfree+0x12c/0x360
[   28.741133]  kunit_try_run_case+0x1b3/0x490
[   28.741617]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   28.742178]  kthread+0x257/0x310
[   28.742555]  ret_from_fork+0x41/0x80
[   28.743344]  ret_from_fork_asm+0x1a/0x30
[   28.743808] 
[   28.744006] The buggy address belongs to the object at ffff8881025fee80
[   28.744006]  which belongs to the cache kmalloc-16 of size 16
[   28.745304] The buggy address is located 0 bytes inside of
[   28.745304]  freed 16-byte region [ffff8881025fee80, ffff8881025fee90)
[   28.746462] 
[   28.746618] The buggy address belongs to the physical page:
[   28.747630] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1025fe
[   28.748415] flags: 0x200000000000000(node=0|zone=2)
[   28.748848] page_type: f5(slab)
[   28.749253] raw: 0200000000000000 ffff888100041640 dead000000000122 0000000000000000
[   28.749900] raw: 0000000000000000 0000000080800080 00000001f5000000 0000000000000000
[   28.750551] page dumped because: kasan: bad access detected
[   28.751020] 
[   28.751358] Memory state around the buggy address:
[   28.751819]  ffff8881025fed80: fa fb fc fc 00 05 fc fc fa fb fc fc fa fb fc fc
[   28.752490]  ffff8881025fee00: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
[   28.752945] >ffff8881025fee80: fa fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   28.753674]                    ^
[   28.754493]  ffff8881025fef00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   28.754961]  ffff8881025fef80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   28.755826] ==================================================================