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

Environment
qemu-arm64
qemu-x86_64

[   37.087831] ==================================================================
[   37.088758] BUG: KASAN: slab-use-after-free in kmalloc_uaf_memset+0x170/0x310
[   37.090806] Write of size 33 at addr fff00000c659f680 by task kunit_try_catch/175
[   37.091605] 
[   37.091986] CPU: 0 UID: 0 PID: 175 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241120 #1
[   37.092971] Tainted: [B]=BAD_PAGE, [N]=TEST
[   37.093593] Hardware name: linux,dummy-virt (DT)
[   37.094183] Call trace:
[   37.095059]  show_stack+0x20/0x38 (C)
[   37.095638]  dump_stack_lvl+0x8c/0xd0
[   37.096184]  print_report+0x118/0x5e0
[   37.096723]  kasan_report+0xc8/0x118
[   37.097813]  kasan_check_range+0x100/0x1a8
[   37.098320]  __asan_memset+0x34/0x78
[   37.098844]  kmalloc_uaf_memset+0x170/0x310
[   37.099364]  kunit_try_run_case+0x14c/0x3d0
[   37.100011]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.100681]  kthread+0x24c/0x2d0
[   37.101764]  ret_from_fork+0x10/0x20
[   37.102279] 
[   37.102635] Allocated by task 175:
[   37.103049]  kasan_save_stack+0x3c/0x68
[   37.103376]  kasan_save_track+0x20/0x40
[   37.103811]  kasan_save_alloc_info+0x40/0x58
[   37.104396]  __kasan_kmalloc+0xd4/0xd8
[   37.104871]  __kmalloc_cache_noprof+0x15c/0x3c8
[   37.105544]  kmalloc_uaf_memset+0xb8/0x310
[   37.106135]  kunit_try_run_case+0x14c/0x3d0
[   37.106811]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.107534]  kthread+0x24c/0x2d0
[   37.108060]  ret_from_fork+0x10/0x20
[   37.109180] 
[   37.109550] Freed by task 175:
[   37.109976]  kasan_save_stack+0x3c/0x68
[   37.110578]  kasan_save_track+0x20/0x40
[   37.111161]  kasan_save_free_info+0x4c/0x78
[   37.112196]  __kasan_slab_free+0x6c/0x98
[   37.112749]  kfree+0x114/0x3d0
[   37.113815]  kmalloc_uaf_memset+0x11c/0x310
[   37.114315]  kunit_try_run_case+0x14c/0x3d0
[   37.114933]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.115574]  kthread+0x24c/0x2d0
[   37.116097]  ret_from_fork+0x10/0x20
[   37.116650] 
[   37.116950] The buggy address belongs to the object at fff00000c659f680
[   37.116950]  which belongs to the cache kmalloc-64 of size 64
[   37.118659] The buggy address is located 0 bytes inside of
[   37.118659]  freed 64-byte region [fff00000c659f680, fff00000c659f6c0)
[   37.119775] 
[   37.120117] The buggy address belongs to the physical page:
[   37.120774] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10659f
[   37.122259] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   37.123012] page_type: f5(slab)
[   37.123478] raw: 0bfffe0000000000 fff00000c00018c0 dead000000000122 0000000000000000
[   37.124242] raw: 0000000000000000 0000000080200020 00000001f5000000 0000000000000000
[   37.125004] page dumped because: kasan: bad access detected
[   37.126257] 
[   37.126631] Memory state around the buggy address:
[   37.127244]  fff00000c659f580: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
[   37.128482]  fff00000c659f600: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   37.129845] >fff00000c659f680: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   37.130524]                    ^
[   37.130955]  fff00000c659f700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   37.131706]  fff00000c659f780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   37.132407] ==================================================================

[   28.580027] ==================================================================
[   28.581086] BUG: KASAN: slab-use-after-free in kmalloc_uaf_memset+0x1a4/0x360
[   28.581905] Write of size 33 at addr ffff8881029dfe00 by task kunit_try_catch/193
[   28.582595] 
[   28.582873] CPU: 1 UID: 0 PID: 193 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241120 #1
[   28.583616] Tainted: [B]=BAD_PAGE, [N]=TEST
[   28.584112] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   28.584600] Call Trace:
[   28.585002]  <TASK>
[   28.585360]  dump_stack_lvl+0x73/0xb0
[   28.585960]  print_report+0xd1/0x640
[   28.586263]  ? __virt_addr_valid+0x1db/0x2d0
[   28.586778]  ? kasan_complete_mode_report_info+0x64/0x200
[   28.587500]  kasan_report+0x102/0x140
[   28.588010]  ? kmalloc_uaf_memset+0x1a4/0x360
[   28.588338]  ? kmalloc_uaf_memset+0x1a4/0x360
[   28.589086]  kasan_check_range+0x10c/0x1c0
[   28.589494]  __asan_memset+0x27/0x50
[   28.590173]  kmalloc_uaf_memset+0x1a4/0x360
[   28.590564]  ? __pfx_kmalloc_uaf_memset+0x10/0x10
[   28.591162]  ? __schedule+0xc3e/0x2790
[   28.591455]  ? __pfx_read_tsc+0x10/0x10
[   28.591995]  ? ktime_get_ts64+0x84/0x230
[   28.592612]  kunit_try_run_case+0x1b3/0x490
[   28.593239]  ? __pfx_kunit_try_run_case+0x10/0x10
[   28.593816]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   28.594296]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   28.594921]  ? __kthread_parkme+0x82/0x160
[   28.595216]  ? preempt_count_sub+0x50/0x80
[   28.595622]  ? __pfx_kunit_try_run_case+0x10/0x10
[   28.596309]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   28.597093]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   28.597680]  kthread+0x257/0x310
[   28.598015]  ? __pfx_kthread+0x10/0x10
[   28.598313]  ret_from_fork+0x41/0x80
[   28.598934]  ? __pfx_kthread+0x10/0x10
[   28.599777]  ret_from_fork_asm+0x1a/0x30
[   28.600130]  </TASK>
[   28.600320] 
[   28.600544] Allocated by task 193:
[   28.601286]  kasan_save_stack+0x3d/0x60
[   28.601659]  kasan_save_track+0x18/0x40
[   28.602075]  kasan_save_alloc_info+0x3b/0x50
[   28.602772]  __kasan_kmalloc+0xb7/0xc0
[   28.603192]  __kmalloc_cache_noprof+0x184/0x410
[   28.603493]  kmalloc_uaf_memset+0xaa/0x360
[   28.603986]  kunit_try_run_case+0x1b3/0x490
[   28.604524]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   28.605207]  kthread+0x257/0x310
[   28.605526]  ret_from_fork+0x41/0x80
[   28.606765]  ret_from_fork_asm+0x1a/0x30
[   28.607092] 
[   28.607374] Freed by task 193:
[   28.608198]  kasan_save_stack+0x3d/0x60
[   28.608892]  kasan_save_track+0x18/0x40
[   28.609381]  kasan_save_free_info+0x3f/0x60
[   28.609864]  __kasan_slab_free+0x56/0x70
[   28.610567]  kfree+0x123/0x3f0
[   28.611207]  kmalloc_uaf_memset+0x12c/0x360
[   28.611750]  kunit_try_run_case+0x1b3/0x490
[   28.612201]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   28.612955]  kthread+0x257/0x310
[   28.613276]  ret_from_fork+0x41/0x80
[   28.613966]  ret_from_fork_asm+0x1a/0x30
[   28.614446] 
[   28.614734] The buggy address belongs to the object at ffff8881029dfe00
[   28.614734]  which belongs to the cache kmalloc-64 of size 64
[   28.616047] The buggy address is located 0 bytes inside of
[   28.616047]  freed 64-byte region [ffff8881029dfe00, ffff8881029dfe40)
[   28.617195] 
[   28.617448] The buggy address belongs to the physical page:
[   28.618038] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1029df
[   28.618841] flags: 0x200000000000000(node=0|zone=2)
[   28.619209] page_type: f5(slab)
[   28.619774] raw: 0200000000000000 ffff8881000418c0 dead000000000122 0000000000000000
[   28.620744] raw: 0000000000000000 0000000080200020 00000001f5000000 0000000000000000
[   28.621472] page dumped because: kasan: bad access detected
[   28.622105] 
[   28.622482] Memory state around the buggy address:
[   28.623076]  ffff8881029dfd00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   28.623796]  ffff8881029dfd80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   28.624554] >ffff8881029dfe00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   28.625323]                    ^
[   28.625783]  ffff8881029dfe80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   28.626458]  ffff8881029dff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   28.627129] ==================================================================