================================================================== BUG: KASAN: use-after-free in __snd_rawmidi_transmit_peek+0x261/0x360 sound/core/rawmidi.c:1286 Read of size 1 at addr ffff88807c4d604c by task kworker/1:1H/52 CPU: 1 PID: 52 Comm: kworker/1:1H Not tainted 5.18.0-syzkaller-10643-g9d004b2f4fea #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+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313 print_report mm/kasan/report.c:429 [inline] kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491 __snd_rawmidi_transmit_peek+0x261/0x360 sound/core/rawmidi.c:1286 snd_rawmidi_transmit+0x8d/0xf0 sound/core/rawmidi.c:1411 snd_usbmidi_standard_output+0x264/0xc10 sound/usb/midi.c:650 snd_usbmidi_do_output+0x200/0x510 sound/usb/midi.c:311 process_one_work+0x996/0x1610 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2e9/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302 Allocated by task 6607: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:436 [inline] ____kasan_kmalloc mm/kasan/common.c:515 [inline] ____kasan_kmalloc mm/kasan/common.c:474 [inline] __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524 kmalloc_node include/linux/slab.h:623 [inline] kvmalloc_node+0x3e/0x190 mm/util.c:613 kvmalloc include/linux/slab.h:750 [inline] kvzalloc include/linux/slab.h:758 [inline] snd_rawmidi_runtime_create sound/core/rawmidi.c:162 [inline] open_substream+0x340/0x8b0 sound/core/rawmidi.c:306 rawmidi_open_priv+0x591/0x6f0 sound/core/rawmidi.c:357 snd_rawmidi_kernel_open+0x1b5/0x270 sound/core/rawmidi.c:392 midisynth_use+0xee/0x270 sound/core/seq/seq_midi.c:215 subscribe_port sound/core/seq/seq_ports.c:412 [inline] check_and_subscribe_port+0x89a/0xb80 sound/core/seq/seq_ports.c:495 snd_seq_port_connect+0x382/0x540 sound/core/seq/seq_ports.c:581 snd_seq_ioctl_subscribe_port+0x1fc/0x400 sound/core/seq/seq_clientmgr.c:1492 snd_seq_kernel_client_ctl+0x102/0x1e0 sound/core/seq/seq_clientmgr.c:2369 snd_seq_oss_midi_open+0x582/0x6e0 sound/core/seq/oss/seq_oss_midi.c:359 snd_seq_oss_synth_setup_midi+0x12d/0x530 sound/core/seq/oss/seq_oss_synth.c:269 snd_seq_oss_open+0x8c3/0xa80 sound/core/seq/oss/seq_oss_init.c:260 odev_open+0x6c/0x90 sound/core/seq/oss/seq_oss.c:128 soundcore_open+0x44e/0x620 sound/sound_core.c:593 chrdev_open+0x266/0x770 fs/char_dev.c:414 do_dentry_open+0x4a1/0x11f0 fs/open.c:824 do_open fs/namei.c:3477 [inline] path_openat+0x1c71/0x2910 fs/namei.c:3610 do_filp_open+0x1aa/0x400 fs/namei.c:3637 do_sys_openat2+0x16d/0x4c0 fs/open.c:1254 do_sys_open fs/open.c:1270 [inline] __do_sys_openat fs/open.c:1286 [inline] __se_sys_openat fs/open.c:1281 [inline] __x64_sys_openat+0x13f/0x1f0 fs/open.c:1281 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Freed by task 6607: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1727 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1753 slab_free mm/slub.c:3507 [inline] kfree+0xd6/0x4d0 mm/slub.c:4555 kvfree+0x42/0x50 mm/util.c:655 snd_rawmidi_runtime_free sound/core/rawmidi.c:176 [inline] close_substream.part.0+0x185/0x720 sound/core/rawmidi.c:528 close_substream sound/core/rawmidi.c:507 [inline] rawmidi_release_priv+0x192/0x270 sound/core/rawmidi.c:547 snd_rawmidi_kernel_release+0x39/0xd0 sound/core/rawmidi.c:564 midisynth_unuse+0x45/0x80 sound/core/seq/seq_midi.c:244 unsubscribe_port sound/core/seq/seq_ports.c:437 [inline] __delete_and_unsubscribe_port+0x270/0x4c0 sound/core/seq/seq_ports.c:537 snd_seq_port_disconnect+0x41c/0x5d0 sound/core/seq/seq_ports.c:616 snd_seq_ioctl_unsubscribe_port+0x1fc/0x400 sound/core/seq/seq_clientmgr.c:1537 snd_seq_kernel_client_ctl+0x102/0x1e0 sound/core/seq/seq_clientmgr.c:2369 snd_seq_oss_midi_close+0x44f/0x4d0 sound/core/seq/oss/seq_oss_midi.c:404 snd_seq_oss_synth_cleanup+0x32c/0x480 sound/core/seq/oss/seq_oss_synth.c:307 snd_seq_oss_release+0x80/0x1a0 sound/core/seq/oss/seq_oss_init.c:414 odev_release+0x4f/0x70 sound/core/seq/oss/seq_oss.c:144 __fput+0x277/0x9d0 fs/file_table.c:317 task_work_run+0xdd/0x1a0 kernel/task_work.c:177 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xaff/0x2a00 kernel/exit.c:795 do_group_exit+0xd2/0x2f0 kernel/exit.c:925 get_signal+0x22df/0x24c0 kernel/signal.c:2875 arch_do_signal_or_restart+0x82/0x20f0 arch/x86/kernel/signal.c:869 exit_to_user_mode_loop kernel/entry/common.c:166 [inline] exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:201 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline] syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:294 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x46/0xb0 The buggy address belongs to the object at ffff88807c4d6000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 76 bytes inside of 4096-byte region [ffff88807c4d6000, ffff88807c4d7000) The buggy address belongs to the physical page: page:ffffea0001f13400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7c4d0 head:ffffea0001f13400 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888010c42140 raw: 0000000000000000 0000000080040004 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 0x1d2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 2972, tgid 2972 (udevd), ts 204154810605, free_ts 203977179083 prep_new_page mm/page_alloc.c:2456 [inline] get_page_from_freelist+0x1290/0x3b70 mm/page_alloc.c:4198 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5426 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2272 alloc_slab_page mm/slub.c:1797 [inline] allocate_slab+0x26c/0x3c0 mm/slub.c:1942 new_slab mm/slub.c:2002 [inline] ___slab_alloc+0x985/0xd90 mm/slub.c:3002 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3089 slab_alloc_node mm/slub.c:3180 [inline] slab_alloc mm/slub.c:3222 [inline] __kmalloc+0x318/0x350 mm/slub.c:4413 kmalloc include/linux/slab.h:605 [inline] tomoyo_realpath_from_path+0xc3/0x620 security/tomoyo/realpath.c:254 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x21b/0x400 security/tomoyo/file.c:822 security_inode_getattr+0xcf/0x140 security/security.c:1344 vfs_getattr fs/stat.c:157 [inline] vfs_statx+0x16a/0x390 fs/stat.c:232 vfs_fstatat+0x8c/0xb0 fs/stat.c:255 __do_sys_newfstatat+0x91/0x110 fs/stat.c:425 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1371 [inline] free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1421 free_unref_page_prepare mm/page_alloc.c:3343 [inline] free_unref_page+0x19/0x6a0 mm/page_alloc.c:3438 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2521 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0xa2/0xc0 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] __kmem_cache_alloc_lru mm/slub.c:3229 [inline] kmem_cache_alloc+0x204/0x3b0 mm/slub.c:3239 getname_flags.part.0+0x50/0x4f0 fs/namei.c:139 getname_flags+0x9a/0xe0 include/linux/audit.h:323 user_path_at_empty+0x2b/0x60 fs/namei.c:2851 do_readlinkat+0xcd/0x2f0 fs/stat.c:456 __do_sys_readlink fs/stat.c:489 [inline] __se_sys_readlink fs/stat.c:486 [inline] __x64_sys_readlink+0x74/0xb0 fs/stat.c:486 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Memory state around the buggy address: ffff88807c4d5f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807c4d5f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88807c4d6000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807c4d6080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807c4d6100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================