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

Environment
qemu-arm64
qemu-x86_64

[   37.485043] ==================================================================
[   37.486587] BUG: KASAN: slab-use-after-free in strnlen+0x80/0x88
[   37.487474] Read of size 1 at addr fff00000c6a4c550 by task kunit_try_catch/248
[   37.488382] 
[   37.489100] CPU: 1 UID: 0 PID: 248 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241122 #1
[   37.490914] Tainted: [B]=BAD_PAGE, [N]=TEST
[   37.491369] Hardware name: linux,dummy-virt (DT)
[   37.491741] Call trace:
[   37.491951]  show_stack+0x20/0x38 (C)
[   37.492263]  dump_stack_lvl+0x8c/0xd0
[   37.492847]  print_report+0x118/0x5e0
[   37.493743]  kasan_report+0xc8/0x118
[   37.495284]  __asan_report_load1_noabort+0x20/0x30
[   37.496235]  strnlen+0x80/0x88
[   37.496825]  kasan_strings+0x380/0x8f8
[   37.497413]  kunit_try_run_case+0x14c/0x3d0
[   37.499363]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.501012]  kthread+0x24c/0x2d0
[   37.501649]  ret_from_fork+0x10/0x20
[   37.502281] 
[   37.502643] Allocated by task 248:
[   37.503409]  kasan_save_stack+0x3c/0x68
[   37.504150]  kasan_save_track+0x20/0x40
[   37.505329]  kasan_save_alloc_info+0x40/0x58
[   37.506046]  __kasan_kmalloc+0xd4/0xd8
[   37.506980]  __kmalloc_cache_noprof+0x15c/0x3c8
[   37.508520]  kasan_strings+0xb4/0x8f8
[   37.509372]  kunit_try_run_case+0x14c/0x3d0
[   37.510397]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.511272]  kthread+0x24c/0x2d0
[   37.511872]  ret_from_fork+0x10/0x20
[   37.512790] 
[   37.513689] Freed by task 248:
[   37.514076]  kasan_save_stack+0x3c/0x68
[   37.514561]  kasan_save_track+0x20/0x40
[   37.515208]  kasan_save_free_info+0x4c/0x78
[   37.515926]  __kasan_slab_free+0x6c/0x98
[   37.516976]  kfree+0x114/0x3d0
[   37.517863]  kasan_strings+0x128/0x8f8
[   37.518568]  kunit_try_run_case+0x14c/0x3d0
[   37.519213]  kunit_generic_run_threadfn_adapter+0x88/0x100
[   37.520127]  kthread+0x24c/0x2d0
[   37.520731]  ret_from_fork+0x10/0x20
[   37.522115] 
[   37.522391] The buggy address belongs to the object at fff00000c6a4c540
[   37.522391]  which belongs to the cache kmalloc-32 of size 32
[   37.524331] The buggy address is located 16 bytes inside of
[   37.524331]  freed 32-byte region [fff00000c6a4c540, fff00000c6a4c560)
[   37.525994] 
[   37.527083] The buggy address belongs to the physical page:
[   37.528064] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x106a4c
[   37.529381] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
[   37.530776] page_type: f5(slab)
[   37.531867] raw: 0bfffe0000000000 fff00000c0001780 dead000000000122 0000000000000000
[   37.533371] raw: 0000000000000000 0000000080400040 00000001f5000000 0000000000000000
[   37.534488] page dumped because: kasan: bad access detected
[   37.535139] 
[   37.535475] Memory state around the buggy address:
[   37.536116]  fff00000c6a4c400: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
[   37.538268]  fff00000c6a4c480: 00 00 00 fc fc fc fc fc 00 00 00 fc fc fc fc fc
[   37.539379] >fff00000c6a4c500: 00 00 07 fc fc fc fc fc fa fb fb fb fc fc fc fc
[   37.540278]                                                  ^
[   37.541700]  fff00000c6a4c580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   37.542621]  fff00000c6a4c600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   37.543568] ==================================================================

[   28.354536] ==================================================================
[   28.357540] BUG: KASAN: slab-use-after-free in strnlen+0x73/0x80
[   28.358102] Read of size 1 at addr ffff888102a18a90 by task kunit_try_catch/267
[   28.358648] 
[   28.359515] CPU: 1 UID: 0 PID: 267 Comm: kunit_try_catch Tainted: G    B            N 6.12.0-next-20241122 #1
[   28.360596] Tainted: [B]=BAD_PAGE, [N]=TEST
[   28.360968] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[   28.362150] Call Trace:
[   28.362766]  <TASK>
[   28.363412]  dump_stack_lvl+0x73/0xb0
[   28.363762]  print_report+0xd1/0x640
[   28.364766]  ? __virt_addr_valid+0x1db/0x2d0
[   28.365577]  ? kasan_complete_mode_report_info+0x64/0x200
[   28.366281]  kasan_report+0x102/0x140
[   28.367689]  ? strnlen+0x73/0x80
[   28.368058]  ? strnlen+0x73/0x80
[   28.368974]  __asan_report_load1_noabort+0x18/0x20
[   28.369394]  strnlen+0x73/0x80
[   28.370120]  kasan_strings+0x4cc/0xb60
[   28.370541]  ? __pfx_kasan_strings+0x10/0x10
[   28.371173]  ? __schedule+0xc3e/0x2790
[   28.372044]  ? __pfx_read_tsc+0x10/0x10
[   28.372391]  ? ktime_get_ts64+0x84/0x230
[   28.373755]  kunit_try_run_case+0x1b3/0x490
[   28.374279]  ? __pfx_kunit_try_run_case+0x10/0x10
[   28.374720]  ? _raw_spin_lock_irqsave+0xa2/0x110
[   28.375149]  ? _raw_spin_unlock_irqrestore+0x5f/0x90
[   28.375800]  ? __kthread_parkme+0x82/0x160
[   28.376656]  ? preempt_count_sub+0x50/0x80
[   28.377015]  ? __pfx_kunit_try_run_case+0x10/0x10
[   28.377323]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
[   28.378278]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   28.379363]  kthread+0x257/0x310
[   28.379764]  ? __pfx_kthread+0x10/0x10
[   28.380220]  ret_from_fork+0x41/0x80
[   28.380627]  ? __pfx_kthread+0x10/0x10
[   28.381447]  ret_from_fork_asm+0x1a/0x30
[   28.382186]  </TASK>
[   28.382465] 
[   28.383015] Allocated by task 267:
[   28.384147]  kasan_save_stack+0x3d/0x60
[   28.384539]  kasan_save_track+0x18/0x40
[   28.384968]  kasan_save_alloc_info+0x3b/0x50
[   28.385377]  __kasan_kmalloc+0xb7/0xc0
[   28.385713]  __kmalloc_cache_noprof+0x184/0x410
[   28.386503]  kasan_strings+0xb3/0xb60
[   28.386936]  kunit_try_run_case+0x1b3/0x490
[   28.387224]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   28.387534]  kthread+0x257/0x310
[   28.387933]  ret_from_fork+0x41/0x80
[   28.388416]  ret_from_fork_asm+0x1a/0x30
[   28.390147] 
[   28.390578] Freed by task 267:
[   28.391067]  kasan_save_stack+0x3d/0x60
[   28.391704]  kasan_save_track+0x18/0x40
[   28.392331]  kasan_save_free_info+0x3f/0x60
[   28.392894]  __kasan_slab_free+0x56/0x70
[   28.393277]  kfree+0x123/0x3f0
[   28.394346]  kasan_strings+0x13a/0xb60
[   28.395094]  kunit_try_run_case+0x1b3/0x490
[   28.395487]  kunit_generic_run_threadfn_adapter+0x85/0xf0
[   28.396282]  kthread+0x257/0x310
[   28.396616]  ret_from_fork+0x41/0x80
[   28.397056]  ret_from_fork_asm+0x1a/0x30
[   28.397870] 
[   28.398093] The buggy address belongs to the object at ffff888102a18a80
[   28.398093]  which belongs to the cache kmalloc-32 of size 32
[   28.399512] The buggy address is located 16 bytes inside of
[   28.399512]  freed 32-byte region [ffff888102a18a80, ffff888102a18aa0)
[   28.400412] 
[   28.400788] The buggy address belongs to the physical page:
[   28.402253] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x102a18
[   28.402933] flags: 0x200000000000000(node=0|zone=2)
[   28.403619] page_type: f5(slab)
[   28.404161] raw: 0200000000000000 ffff888100041780 dead000000000122 0000000000000000
[   28.404864] raw: 0000000000000000 0000000080400040 00000001f5000000 0000000000000000
[   28.406069] page dumped because: kasan: bad access detected
[   28.406681] 
[   28.406845] Memory state around the buggy address:
[   28.407529]  ffff888102a18980: fa fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc
[   28.408006]  ffff888102a18a00: 00 00 00 fc fc fc fc fc 00 00 07 fc fc fc fc fc
[   28.409024] >ffff888102a18a80: fa fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
[   28.409722]                          ^
[   28.410479]  ffff888102a18b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   28.411164]  ffff888102a18b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   28.411956] ==================================================================