================================================================== 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 ffff88807a5fe069 by task kworker/1:1H/108 CPU: 1 PID: 108 Comm: kworker/1:1H Not tainted 5.18.0-syzkaller-04943-g7e062cda7d90 #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 6129: 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:4465 kmalloc_node include/linux/slab.h:611 [inline] kvmalloc_node+0x6e/0x160 mm/util.c:612 kvmalloc include/linux/slab.h:738 [inline] kvzalloc include/linux/slab.h:746 [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:3477 [inline] path_openat+0x26c0/0x2ec0 fs/namei.c:3610 do_filp_open+0x277/0x4f0 fs/namei.c:3637 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+0x46/0xb0 Freed by task 6129: 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:1727 [inline] slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1753 slab_free mm/slub.c:3507 [inline] kfree+0xc6/0x210 mm/slub.c:4555 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_reset+0x3b6/0x9d0 sound/core/seq/oss/seq_oss_synth.c:406 snd_seq_oss_reset+0x5b/0x240 sound/core/seq/oss/seq_oss_init.c:435 snd_seq_oss_release+0xe9/0x300 sound/core/seq/oss/seq_oss_init.c:412 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:177 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/0x60 kernel/entry/common.c:294 entry_SYSCALL_64_after_hwframe+0x46/0xb0 The buggy address belongs to the object at ffff88807a5fe000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 105 bytes inside of 4096-byte region [ffff88807a5fe000, ffff88807a5ff000) The buggy address belongs to the physical page: page:ffffea0001e97e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7a5f8 head:ffffea0001e97e00 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 dead000000000100 dead000000000122 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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 3934, tgid 3927 (syz-executor.5), ts 134862797409, free_ts 134854921029 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_slab_page+0x70/0xf0 mm/slub.c:1797 allocate_slab+0x5e/0x520 mm/slub.c:1942 new_slab mm/slub.c:2002 [inline] ___slab_alloc+0x41e/0xcd0 mm/slub.c:3002 __slab_alloc mm/slub.c:3089 [inline] slab_alloc_node mm/slub.c:3180 [inline] __kmalloc_node+0x2c0/0x400 mm/slub.c:4461 kmalloc_node include/linux/slab.h:611 [inline] kvmalloc_node+0x6e/0x160 mm/util.c:612 kvmalloc include/linux/slab.h:738 [inline] kvmalloc_array include/linux/slab.h:756 [inline] __ptr_ring_init_queue_alloc include/linux/ptr_ring.h:471 [inline] ptr_ring_init include/linux/ptr_ring.h:489 [inline] skb_array_init include/linux/skb_array.h:182 [inline] pfifo_fast_init+0x119/0x6a0 net/sched/sch_generic.c:860 qdisc_create_dflt+0x140/0x2a0 net/sched/sch_generic.c:1007 mq_init+0x2d7/0x6e0 net/sched/sch_mq.c:90 qdisc_create_dflt+0x140/0x2a0 net/sched/sch_generic.c:1007 attach_default_qdiscs net/sched/sch_generic.c:1163 [inline] dev_activate+0x182/0x1020 net/sched/sch_generic.c:1216 __dev_open+0x3f1/0x510 net/core/dev.c:1439 __dev_change_flags+0x1e0/0x6d0 net/core/dev.c:8531 dev_change_flags+0x85/0x190 net/core/dev.c:8602 dev_ifsioc+0x176/0x11e0 net/core/dev_ioctl.c:327 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1356 [inline] free_pcp_prepare+0x812/0x900 mm/page_alloc.c:1406 free_unref_page_prepare mm/page_alloc.c:3328 [inline] free_unref_page+0x7d/0x390 mm/page_alloc.c:3423 free_slab mm/slub.c:2041 [inline] discard_slab mm/slub.c:2047 [inline] __unfreeze_partials+0x1ab/0x200 mm/slub.c:2521 put_cpu_partial+0x116/0x180 mm/slub.c:2597 do_slab_free mm/slub.c:3495 [inline] ___cache_free+0x118/0x1a0 mm/slub.c:3514 qlist_free_all+0x2b/0x70 mm/kasan/quarantine.c:176 kasan_quarantine_reduce+0x169/0x180 mm/kasan/quarantine.c:283 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:446 kasan_slab_alloc include/linux/kasan.h:224 [inline] slab_post_alloc_hook mm/slab.h:750 [inline] slab_alloc_node mm/slub.c:3214 [inline] slab_alloc mm/slub.c:3222 [inline] __kmalloc+0x1bd/0x370 mm/slub.c:4413 kmalloc_array include/linux/slab.h:628 [inline] kcalloc include/linux/slab.h:659 [inline] ext4_find_extent+0x342/0xd90 fs/ext4/extents.c:905 ext4_ext_map_blocks+0x225/0x6890 fs/ext4/extents.c:4097 ext4_map_blocks+0xa30/0x1cb0 fs/ext4/inode.c:643 ext4_convert_unwritten_extents+0x2ed/0x6e0 fs/ext4/extents.c:4807 ext4_convert_unwritten_io_end_vec+0x11c/0x1d0 fs/ext4/extents.c:4846 ext4_end_io_end fs/ext4/page-io.c:186 [inline] ext4_do_flush_completed_IO fs/ext4/page-io.c:259 [inline] ext4_end_io_rsv_work+0x380/0x6f0 fs/ext4/page-io.c:273 process_one_work+0x81c/0xd10 kernel/workqueue.c:2289 Memory state around the buggy address: ffff88807a5fdf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807a5fdf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88807a5fe000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807a5fe080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807a5fe100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================