syzbot


KASAN: use-after-free Read in remove_proc_entry

Status: auto-obsoleted due to no activity on 2023/07/19 17:13
Reported-by: syzbot+59678f42c88abb627188@syzkaller.appspotmail.com
First crash: 536d, last: 536d

Sample crash report:
usb 3-1: USB disconnect, device number 7
------------[ cut here ]------------
==================================================================
BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:642 [inline]
BUG: KASAN: use-after-free in string+0x218/0x2b0 lib/vsprintf.c:724
Read of size 1 at addr ffff88805f01b5e4 by task kworker/0:54/7299

CPU: 0 PID: 7299 Comm: kworker/0:54 Not tainted 5.15.103-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: usb_hub_wq hub_event
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 string_nocheck lib/vsprintf.c:642 [inline]
 string+0x218/0x2b0 lib/vsprintf.c:724
 vsnprintf+0x11fc/0x1c70 lib/vsprintf.c:2806
 vprintk_store+0x3ba/0x1300 kernel/printk/printk.c:2158
 vprintk_emit+0x83/0x150 kernel/printk/printk.c:2252
 __warn_printk+0xda/0x120 kernel/panic.c:713
 remove_proc_entry+0x556/0x5c0 fs/proc/generic.c:718
 scsi_proc_hostdir_rm+0xe4/0x130 drivers/scsi/scsi_proc.c:127
 scsi_remove_host+0x15e/0x690 drivers/scsi/hosts.c:183
 quiesce_and_remove_host drivers/usb/storage/usb.c:867 [inline]
 usb_stor_disconnect+0x14a/0x1f0 drivers/usb/storage/usb.c:1087
 usb_unbind_interface+0x1cd/0x840 drivers/usb/core/driver.c:458
 __device_release_driver drivers/base/dd.c:1224 [inline]
 device_release_driver_internal+0x50e/0x7f0 drivers/base/dd.c:1257
 bus_remove_device+0x2e5/0x400 drivers/base/bus.c:529
 device_del+0x6e2/0xbd0 drivers/base/core.c:3582
 usb_disable_device+0x3b8/0x840 drivers/usb/core/message.c:1419
 usb_disconnect+0x33c/0x8c0 drivers/usb/core/hub.c:2231
 hub_port_connect drivers/usb/core/hub.c:5202 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5502 [inline]
 port_event drivers/usb/core/hub.c:5648 [inline]
 hub_event+0x1e63/0x56d0 drivers/usb/core/hub.c:5730
 process_one_work+0x90d/0x1270 kernel/workqueue.c:2306
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2453
 kthread+0x3f6/0x4f0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
 </TASK>

Allocated by task 3613:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 __kasan_slab_alloc+0x8e/0xc0 mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0xf3/0x2e0 mm/slub.c:3233
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 __proc_create+0x419/0x9f0 fs/proc/generic.c:426
 proc_create_reg fs/proc/generic.c:553 [inline]
 proc_create_data+0x124/0x2b0 fs/proc/generic.c:573
 scsi_proc_host_add+0x134/0x230 drivers/scsi/scsi_proc.c:148
 scsi_add_host_with_dma+0x62a/0x990 drivers/scsi/hosts.c:293
 scsi_add_host include/scsi/scsi_host.h:773 [inline]
 usb_stor_probe2+0x938/0xd60 drivers/usb/storage/usb.c:1056
 isd200_probe+0x185/0x1e0 drivers/usb/storage/isd200.c:1555
 usb_probe_interface+0x5c0/0xaf0 drivers/usb/core/driver.c:396
 really_probe+0x24e/0xb60 drivers/base/dd.c:595
 __driver_probe_device+0x1c3/0x3f0 drivers/base/dd.c:750
 driver_probe_device+0x50/0x420 drivers/base/dd.c:780
 __device_attach_driver+0x2b9/0x500 drivers/base/dd.c:902
 bus_for_each_drv+0x183/0x200 drivers/base/bus.c:427
 __device_attach+0x359/0x570 drivers/base/dd.c:974
 bus_probe_device+0xba/0x1e0 drivers/base/bus.c:487
 device_add+0xb48/0xfd0 drivers/base/core.c:3394
 usb_set_configuration+0x19dd/0x2020 drivers/usb/core/message.c:2170
 usb_generic_driver_probe+0x84/0x140 drivers/usb/core/generic.c:238
 usb_probe_device+0x130/0x260 drivers/usb/core/driver.c:293
 really_probe+0x24e/0xb60 drivers/base/dd.c:595
 __driver_probe_device+0x1c3/0x3f0 drivers/base/dd.c:750
 driver_probe_device+0x50/0x420 drivers/base/dd.c:780
 __device_attach_driver+0x2b9/0x500 drivers/base/dd.c:902
 bus_for_each_drv+0x183/0x200 drivers/base/bus.c:427
 __device_attach+0x359/0x570 drivers/base/dd.c:974
 bus_probe_device+0xba/0x1e0 drivers/base/bus.c:487
 device_add+0xb48/0xfd0 drivers/base/core.c:3394
 usb_new_device+0xc17/0x18d0 drivers/usb/core/hub.c:2568
 hub_port_connect drivers/usb/core/hub.c:5358 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5502 [inline]
 port_event drivers/usb/core/hub.c:5648 [inline]
 hub_event+0x2dd8/0x56d0 drivers/usb/core/hub.c:5730
 process_one_work+0x90d/0x1270 kernel/workqueue.c:2306
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2453
 kthread+0x3f6/0x4f0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Freed by task 3613:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kmem_cache_free+0x91/0x260 mm/slub.c:3515
 remove_proc_entry+0x446/0x5c0 fs/proc/generic.c:721
 scsi_proc_host_rm+0x13e/0x1b0 drivers/scsi/scsi_proc.c:168
 scsi_remove_host+0x139/0x690 drivers/scsi/hosts.c:182
 quiesce_and_remove_host drivers/usb/storage/usb.c:867 [inline]
 usb_stor_disconnect+0x14a/0x1f0 drivers/usb/storage/usb.c:1087
 usb_unbind_interface+0x1cd/0x840 drivers/usb/core/driver.c:458
 __device_release_driver drivers/base/dd.c:1224 [inline]
 device_release_driver_internal+0x50e/0x7f0 drivers/base/dd.c:1257
 bus_remove_device+0x2e5/0x400 drivers/base/bus.c:529
 device_del+0x6e2/0xbd0 drivers/base/core.c:3582
 usb_disable_device+0x3b8/0x840 drivers/usb/core/message.c:1419
 usb_disconnect+0x33c/0x8c0 drivers/usb/core/hub.c:2231
 hub_port_connect drivers/usb/core/hub.c:5202 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5502 [inline]
 port_event drivers/usb/core/hub.c:5648 [inline]
 hub_event+0x1e63/0x56d0 drivers/usb/core/hub.c:5730
 process_one_work+0x90d/0x1270 kernel/workqueue.c:2306
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2453
 kthread+0x3f6/0x4f0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

The buggy address belongs to the object at ffff88805f01b500
 which belongs to the cache proc_dir_entry of size 256
The buggy address is located 228 bytes inside of
 256-byte region [ffff88805f01b500, ffff88805f01b600)
The buggy address belongs to the page:
page:ffffea00017c06c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88805f01b280 pfn:0x5f01b
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea00012c44c0 0000000300000003 ffff8881406f4640
raw: ffff88805f01b280 00000000800c0007 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 8978, ts 362254235433, free_ts 361328996430
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x32dd/0x3470 mm/page_alloc.c:4159
 __alloc_pages+0x272/0x790 mm/page_alloc.c:5421
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0x1e1/0x2e0 mm/slub.c:3233
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 __proc_create+0x419/0x9f0 fs/proc/generic.c:426
 proc_create_reg+0x8c/0x110 fs/proc/generic.c:553
 proc_create_net_data+0xc3/0x1f0 fs/proc/proc_net.c:110
 if6_proc_net_init+0x55/0x70 net/ipv6/addrconf.c:4402
 ops_init+0x356/0x600 net/core/net_namespace.c:135
 setup_net+0x358/0x9e0 net/core/net_namespace.c:329
 copy_net_ns+0x395/0x5d0 net/core/net_namespace.c:473
 create_new_namespaces+0x425/0x7a0 kernel/nsproxy.c:110
 copy_namespaces+0x365/0x3b0 kernel/nsproxy.c:178
 copy_process+0x1841/0x3ef0 kernel/fork.c:2201
 kernel_clone+0x210/0xa50 kernel/fork.c:2601
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xcb7/0xd70 mm/page_alloc.c:3317
 free_unref_page_list+0x1f7/0x970 mm/page_alloc.c:3433
 release_pages+0x1bb9/0x1f40 mm/swap.c:963
 tlb_batch_pages_flush mm/mmu_gather.c:49 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:240 [inline]
 tlb_flush_mmu mm/mmu_gather.c:247 [inline]
 tlb_finish_mmu+0x177/0x320 mm/mmu_gather.c:338
 exit_mmap+0x3cd/0x670 mm/mmap.c:3188
 __mmput+0x112/0x3b0 kernel/fork.c:1118
 exit_mm+0x688/0x7f0 kernel/exit.c:548
 do_exit+0x626/0x2480 kernel/exit.c:859
 __do_sys_exit kernel/exit.c:963 [inline]
 __se_sys_exit kernel/exit.c:961 [inline]
 __x64_sys_exit+0x3c/0x40 kernel/exit.c:961
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
 ffff88805f01b480: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88805f01b500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88805f01b580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff88805f01b600: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff88805f01b680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/03/21 17:12 linux-5.15.y 8020ae3c051d 8b4eb097 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in remove_proc_entry
* Struck through repros no longer work on HEAD.