================================================================== BUG: KASAN: use-after-free in __snd_rawmidi_transmit_peek sound/core/rawmidi.c:1286 [inline] BUG: KASAN: use-after-free in snd_rawmidi_transmit+0x3f3/0x420 sound/core/rawmidi.c:1411 Read of size 1 at addr ffff88802478206a by task kworker/0:1H/9 CPU: 0 PID: 9 Comm: kworker/0:1H Not tainted 5.18.0-rc7-syzkaller-00181-geaea45fc0e7b #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events_highpri snd_usbmidi_out_work Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106 print_address_description+0x65/0x4b0 mm/kasan/report.c:313 print_report+0xf4/0x210 mm/kasan/report.c:429 kasan_report+0xfb/0x130 mm/kasan/report.c:491 __snd_rawmidi_transmit_peek sound/core/rawmidi.c:1286 [inline] snd_rawmidi_transmit+0x3f3/0x420 sound/core/rawmidi.c:1411 snd_usbmidi_standard_output+0x202/0xf30 sound/usb/midi.c:650 snd_usbmidi_do_output+0x20e/0x530 sound/usb/midi.c:311 process_one_work+0x81c/0xd10 kernel/workqueue.c:2289 worker_thread+0xb14/0x1330 kernel/workqueue.c:2436 kthread+0x266/0x300 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 Allocated by task 7049: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:436 [inline] ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:515 kasan_kmalloc include/linux/kasan.h:234 [inline] __kmalloc_node+0x262/0x400 mm/slub.c:4462 kmalloc_node include/linux/slab.h:604 [inline] kvmalloc_node+0x6e/0x160 mm/util.c:580 kvmalloc include/linux/slab.h:731 [inline] kvzalloc include/linux/slab.h:739 [inline] snd_rawmidi_runtime_create sound/core/rawmidi.c:162 [inline] open_substream+0x2a1/0x6d0 sound/core/rawmidi.c:306 rawmidi_open_priv+0xc2/0x6a0 sound/core/rawmidi.c:357 snd_rawmidi_kernel_open+0x1e3/0x280 sound/core/rawmidi.c:392 midisynth_use+0xf9/0x2b0 sound/core/seq/seq_midi.c:215 subscribe_port sound/core/seq/seq_ports.c:412 [inline] check_and_subscribe_port+0x633/0xac0 sound/core/seq/seq_ports.c:495 snd_seq_port_connect+0x27e/0x480 sound/core/seq/seq_ports.c:581 snd_seq_ioctl_subscribe_port+0x394/0x750 sound/core/seq/seq_clientmgr.c:1492 snd_seq_oss_midi_open+0x44b/0x9b0 sound/core/seq/oss/seq_oss_midi.c:359 snd_seq_oss_synth_setup_midi+0x126/0x530 sound/core/seq/oss/seq_oss_synth.c:269 snd_seq_oss_open+0x96d/0x1020 sound/core/seq/oss/seq_oss_init.c:260 odev_open+0x5e/0x90 sound/core/seq/oss/seq_oss.c:128 chrdev_open+0x5fb/0x680 fs/char_dev.c:414 do_dentry_open+0x77f/0xfd0 fs/open.c:824 do_open fs/namei.c:3476 [inline] path_openat+0x26c0/0x2ec0 fs/namei.c:3609 do_filp_open+0x277/0x4f0 fs/namei.c:3636 do_sys_openat2+0x13b/0x500 fs/open.c:1213 do_sys_open fs/open.c:1229 [inline] __do_sys_openat fs/open.c:1245 [inline] __se_sys_openat fs/open.c:1240 [inline] __x64_sys_openat+0x243/0x290 fs/open.c:1240 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 7049: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4c/0x70 mm/kasan/common.c:45 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:370 ____kasan_slab_free+0xd8/0x110 mm/kasan/common.c:366 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1728 [inline] slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1754 slab_free mm/slub.c:3510 [inline] kfree+0xc6/0x210 mm/slub.c:4552 snd_rawmidi_runtime_free sound/core/rawmidi.c:176 [inline] close_substream+0x38a/0x5f0 sound/core/rawmidi.c:528 rawmidi_release_priv+0xf1/0x180 sound/core/rawmidi.c:547 snd_rawmidi_kernel_release+0x42/0xa0 sound/core/rawmidi.c:564 unsubscribe_port sound/core/seq/seq_ports.c:437 [inline] __delete_and_unsubscribe_port+0x15c/0x330 sound/core/seq/seq_ports.c:537 snd_seq_port_disconnect+0x533/0x660 sound/core/seq/seq_ports.c:616 snd_seq_ioctl_unsubscribe_port+0x394/0x750 sound/core/seq/seq_clientmgr.c:1537 snd_seq_oss_midi_close+0x33f/0x740 sound/core/seq/oss/seq_oss_midi.c:404 snd_seq_oss_synth_cleanup+0x141/0x570 sound/core/seq/oss/seq_oss_synth.c:307 snd_seq_oss_release+0xf1/0x300 sound/core/seq/oss/seq_oss_init.c:414 odev_release+0x52/0x70 sound/core/seq/oss/seq_oss.c:144 __fput+0x3b9/0x820 fs/file_table.c:317 task_work_run+0x146/0x1c0 kernel/task_work.c:164 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0x134/0x160 kernel/entry/common.c:169 exit_to_user_mode_prepare+0xad/0x110 kernel/entry/common.c:201 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline] syscall_exit_to_user_mode+0x2e/0x70 kernel/entry/common.c:294 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff888024782000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 106 bytes inside of 4096-byte region [ffff888024782000, ffff888024783000) The buggy address belongs to the physical page: page:ffffea000091e000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x24780 head:ffffea000091e000 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 0000000000000000 dead000000000001 ffff888011442140 raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, tgid 1 (swapper/0), ts 9358326260, free_ts 0 prep_new_page mm/page_alloc.c:2441 [inline] get_page_from_freelist+0x72e/0x7a0 mm/page_alloc.c:4182 __alloc_pages+0x26c/0x5f0 mm/page_alloc.c:5408 alloc_page_interleave+0x22/0x1c0 mm/mempolicy.c:2104 alloc_slab_page+0x70/0xf0 mm/slub.c:1799 allocate_slab+0x5e/0x560 mm/slub.c:1944 new_slab mm/slub.c:2004 [inline] ___slab_alloc+0x41e/0xcd0 mm/slub.c:3005 __slab_alloc mm/slub.c:3092 [inline] slab_alloc_node mm/slub.c:3183 [inline] slab_alloc mm/slub.c:3225 [inline] kmem_cache_alloc_trace+0x25c/0x310 mm/slub.c:3256 kmalloc include/linux/slab.h:581 [inline] kzalloc include/linux/slab.h:714 [inline] kobject_uevent_env+0x33a/0x8e0 lib/kobject_uevent.c:524 rx_queue_add_kobject net/core/net-sysfs.c:1061 [inline] net_rx_queue_update_kobjects+0x24f/0x4c0 net/core/net-sysfs.c:1101 register_queue_kobjects net/core/net-sysfs.c:1761 [inline] netdev_register_kobject+0x222/0x310 net/core/net-sysfs.c:2012 register_netdevice+0x1331/0x19a0 net/core/dev.c:9961 register_netdev+0x37/0x50 net/core/dev.c:10087 rose_proto_init+0x177/0x630 net/rose/af_rose.c:1531 do_one_initcall+0xbd/0x2b0 init/main.c:1298 do_initcall_level+0x168/0x218 init/main.c:1371 do_initcalls+0x4b/0x8c init/main.c:1387 page_owner free stack trace missing Memory state around the buggy address: ffff888024781f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888024781f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888024782000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888024782080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888024782100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================