================================================================== BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:643 [inline] BUG: KASAN: use-after-free in string+0x39c/0x3d0 lib/vsprintf.c:725 Read of size 1 at addr ffff888020734dc0 by task udevd/2996 CPU: 1 PID: 2996 Comm: udevd Not tainted 6.1.0-rc8-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:284 [inline] print_report+0x15e/0x461 mm/kasan/report.c:395 kasan_report+0xbf/0x1f0 mm/kasan/report.c:495 string_nocheck lib/vsprintf.c:643 [inline] string+0x39c/0x3d0 lib/vsprintf.c:725 vsnprintf+0xa11/0x16b0 lib/vsprintf.c:2800 add_uevent_var+0x161/0x390 lib/kobject_uevent.c:665 dev_uevent+0x191/0x780 drivers/base/core.c:2421 uevent_show+0x1bc/0x380 drivers/base/core.c:2492 dev_attr_show+0x4f/0x90 drivers/base/core.c:2195 sysfs_kf_seq_show+0x21d/0x3d0 fs/sysfs/file.c:59 seq_read_iter+0x4f9/0x1280 fs/seq_file.c:230 kernfs_fop_read_iter+0x546/0x7a0 fs/kernfs/file.c:275 call_read_iter include/linux/fs.h:2193 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x681/0x930 fs/read_write.c:470 ksys_read+0x12b/0x250 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fd806d258fe Code: c0 e9 e6 fe ff ff 50 48 8d 3d 0e c7 09 00 e8 c9 cf 01 00 66 0f 1f 84 00 00 00 00 00 64 8b 04 25 18 00 00 00 85 c0 75 14 0f 05 <48> 3d 00 f0 ff ff 77 5a c3 66 0f 1f 84 00 00 00 00 00 48 83 ec 28 RSP: 002b:00007ffe027d6758 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000055e671cfdb70 RCX: 00007fd806d258fe RDX: 0000000000001000 RSI: 000055e671d11120 RDI: 000000000000000c RBP: 00007fd806df2380 R08: 000000000000000c R09: 00007fd806df5a60 R10: 0000000000000002 R11: 0000000000000246 R12: 000055e671cfdb70 R13: 0000000000000d68 R14: 00007fd806df1780 R15: 0000000000000d68 Allocated by task 25309: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:371 [inline] ____kasan_kmalloc mm/kasan/common.c:330 [inline] __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:380 kmalloc include/linux/slab.h:553 [inline] raw_ioctl_init+0x152/0x820 drivers/usb/gadget/legacy/raw_gadget.c:460 raw_ioctl+0xbf5/0x27d0 drivers/usb/gadget/legacy/raw_gadget.c:1250 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x197/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 25304: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:511 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x13b/0x1a0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:177 [inline] __cache_free mm/slab.c:3389 [inline] __do_kmem_cache_free mm/slab.c:3585 [inline] __kmem_cache_free+0xcd/0x3b0 mm/slab.c:3592 dev_free+0x9a/0x700 drivers/usb/gadget/legacy/raw_gadget.c:210 kref_put include/linux/kref.h:65 [inline] raw_release+0x21d/0x290 drivers/usb/gadget/legacy/raw_gadget.c:424 __fput+0x27c/0xa90 fs/file_table.c:320 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xb3d/0x2a30 kernel/exit.c:820 do_group_exit+0xd4/0x2a0 kernel/exit.c:950 get_signal+0x21b1/0x2440 kernel/signal.c:2858 arch_do_signal_or_restart+0x86/0x2300 arch/x86/kernel/signal.c:869 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888020734dc0 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff888020734dc0, ffff888020734de0) The buggy address belongs to the physical page: page:ffffea000081cd00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888020734fc1 pfn:0x20734 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea0001f9a588 ffffea0000874f48 ffff888012040100 raw: ffff888020734fc1 ffff888020734000 000000010000003b 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 0x252000(__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_THISNODE), pid 37, tgid 37 (kworker/u4:2), ts 8665270203, free_ts 0 prep_new_page mm/page_alloc.c:2539 [inline] get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4291 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5558 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1363 [inline] cache_grow_begin+0x94/0x390 mm/slab.c:2570 cache_alloc_refill+0x27f/0x380 mm/slab.c:2943 ____cache_alloc mm/slab.c:3019 [inline] ____cache_alloc mm/slab.c:3002 [inline] __do_cache_alloc mm/slab.c:3205 [inline] slab_alloc_node mm/slab.c:3250 [inline] __kmem_cache_alloc_node+0x473/0x510 mm/slab.c:3549 __do_kmalloc_node mm/slab_common.c:954 [inline] __kmalloc_node+0x4d/0xd0 mm/slab_common.c:962 kmalloc_array_node include/linux/slab.h:666 [inline] blk_mq_alloc_hctx block/blk-mq.c:3624 [inline] blk_mq_alloc_and_init_hctx+0xa89/0x1230 block/blk-mq.c:4078 blk_mq_realloc_hw_ctxs+0x43d/0x590 block/blk-mq.c:4111 blk_mq_init_allocated_queue+0x4af/0x1470 block/blk-mq.c:4173 blk_mq_init_queue_data block/blk-mq.c:3982 [inline] blk_mq_init_queue+0xc7/0x150 block/blk-mq.c:3992 scsi_alloc_sdev+0x852/0xd90 drivers/scsi/scsi_scan.c:335 scsi_probe_and_add_lun+0x22be/0x3650 drivers/scsi/scsi_scan.c:1183 __scsi_scan_target+0x21f/0xdb0 drivers/scsi/scsi_scan.c:1665 scsi_scan_channel drivers/scsi/scsi_scan.c:1753 [inline] scsi_scan_channel+0x148/0x1e0 drivers/scsi/scsi_scan.c:1729 scsi_scan_host_selected+0x2e3/0x3b0 drivers/scsi/scsi_scan.c:1782 do_scsi_scan_host+0x1e8/0x260 drivers/scsi/scsi_scan.c:1921 page_owner free stack trace missing Memory state around the buggy address: ffff888020734c80: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ffff888020734d00: 00 00 00 00 fc fc fc fc 00 01 fc fc fc fc fc fc >ffff888020734d80: 00 01 fc fc fc fc fc fc fa fb fb fb fc fc fc fc ^ ffff888020734e00: 00 00 01 fc fc fc fc fc 00 01 fc fc fc fc fc fc ffff888020734e80: fb fb fb fb fc fc fc fc 00 00 01 fc fc fc fc fc ==================================================================