================================================================== 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+0x392/0x400 sound/core/rawmidi.c:1411 Read of size 1 at addr ffff88805f09e072 by task syz.3.1438/9663 CPU: 1 PID: 9663 Comm: syz.3.1438 Not tainted 5.15.186-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 Call Trace: dump_stack_lvl+0x168/0x230 lib/dump_stack.c:106 print_address_description+0x60/0x2d0 mm/kasan/report.c:248 __kasan_report mm/kasan/report.c:434 [inline] kasan_report+0xdf/0x130 mm/kasan/report.c:451 __snd_rawmidi_transmit_peek sound/core/rawmidi.c:1286 [inline] snd_rawmidi_transmit+0x392/0x400 sound/core/rawmidi.c:1411 snd_usbmidi_standard_output+0x1e4/0xdd0 sound/usb/midi.c:718 snd_usbmidi_do_output+0x21e/0x560 sound/usb/midi.c:311 snd_usbmidi_error_timer+0x312/0x660 sound/usb/midi.c:362 call_timer_fn+0x16c/0x530 kernel/time/timer.c:1451 expire_timers kernel/time/timer.c:1496 [inline] __run_timers+0x525/0x7c0 kernel/time/timer.c:1767 run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1780 handle_softirqs+0x328/0x820 kernel/softirq.c:576 __do_softirq kernel/softirq.c:610 [inline] invoke_softirq kernel/softirq.c:450 [inline] __irq_exit_rcu+0x12f/0x220 kernel/softirq.c:659 irq_exit_rcu+0x5/0x20 kernel/softirq.c:671 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1108 [inline] sysvec_apic_timer_interrupt+0xa0/0xc0 arch/x86/kernel/apic/apic.c:1108 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:676 RIP: 0010:lock_acquire+0x1f2/0x3f0 kernel/locking/lockdep.c:5627 Code: 00 9c 8f 84 24 80 00 00 00 f6 84 24 81 00 00 00 02 0f 85 f6 00 00 00 41 f7 c6 00 02 00 00 74 01 fb 48 c7 44 24 60 0e 36 e0 45 <4b> c7 44 3d 00 00 00 00 00 66 43 c7 44 3d 09 00 00 43 c6 44 3d 0b RSP: 0018:ffffc9000343f900 EFLAGS: 00000206 RAX: 0000000000000001 RBX: 0000000000000000 RCX: fe717dcdd4d05700 RDX: 0000000000000000 RSI: ffffffff8a0b2460 RDI: ffffffff8a59ab80 RBP: ffffc9000343fa20 R08: dffffc0000000000 R09: fffffbfff1ff741f R10: fffffbfff1ff741f R11: 1ffffffff1ff741e R12: ffff88801e4c1628 R13: 1ffff92000687f2c R14: 0000000000000246 R15: dffffc0000000000 __might_fault+0xb3/0x110 mm/memory.c:5357 _copy_from_user+0x29/0x170 lib/usercopy.c:14 copy_from_user include/linux/uaccess.h:192 [inline] __copy_msghdr_from_user net/socket.c:2318 [inline] copy_msghdr_from_user net/socket.c:2369 [inline] recvmsg_copy_msghdr net/socket.c:2621 [inline] ___sys_recvmsg+0x129/0x4f0 net/socket.c:2693 do_recvmmsg+0x344/0x7a0 net/socket.c:2791 __sys_recvmmsg net/socket.c:2870 [inline] __do_sys_recvmmsg net/socket.c:2893 [inline] __se_sys_recvmmsg net/socket.c:2886 [inline] __x64_sys_recvmmsg+0x18d/0x240 net/socket.c:2886 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 RIP: 0033:0x7f204b9ce929 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f2049815038 EFLAGS: 00000246 ORIG_RAX: 000000000000012b RAX: ffffffffffffffda RBX: 00007f204bbf6080 RCX: 00007f204b9ce929 RDX: 0000000000010106 RSI: 00002000000000c0 RDI: 0000000000000003 RBP: 00007f204ba50b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f204bbf6080 R15: 00007ffe87439378 Allocated by task 9620: 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_kmalloc mm/kasan/common.c:513 [inline] __kasan_kmalloc+0xb5/0xf0 mm/kasan/common.c:522 kmalloc_node include/linux/slab.h:627 [inline] kvmalloc_node+0x84/0x130 mm/util.c:619 kvmalloc include/linux/mm.h:805 [inline] kvzalloc include/linux/mm.h:813 [inline] snd_rawmidi_runtime_create sound/core/rawmidi.c:162 [inline] open_substream+0x29d/0x6c0 sound/core/rawmidi.c:306 rawmidi_open_priv+0xc4/0x660 sound/core/rawmidi.c:357 snd_rawmidi_kernel_open+0x1a2/0x240 sound/core/rawmidi.c:392 midisynth_use+0xd8/0x260 sound/core/seq/seq_midi.c:221 subscribe_port sound/core/seq/seq_ports.c:412 [inline] check_and_subscribe_port+0x669/0xb30 sound/core/seq/seq_ports.c:495 snd_seq_port_connect+0x256/0x430 sound/core/seq/seq_ports.c:581 snd_seq_ioctl_subscribe_port+0x32c/0x6f0 sound/core/seq/seq_clientmgr.c:1490 snd_seq_oss_midi_open+0x3a4/0x7c0 sound/core/seq/oss/seq_oss_midi.c:365 snd_seq_oss_synth_setup_midi+0x129/0x520 sound/core/seq/oss/seq_oss_synth.c:269 snd_seq_oss_open+0x87a/0xe40 sound/core/seq/oss/seq_oss_init.c:261 odev_open+0x63/0x90 sound/core/seq/oss/seq_oss.c:128 chrdev_open+0x597/0x670 fs/char_dev.c:414 do_dentry_open+0x7ff/0xf80 fs/open.c:826 do_open fs/namei.c:3608 [inline] path_openat+0x2682/0x2f30 fs/namei.c:3742 do_filp_open+0x1b3/0x3e0 fs/namei.c:3769 do_sys_openat2+0x142/0x4a0 fs/open.c:1253 do_sys_open fs/open.c:1269 [inline] __do_sys_openat fs/open.c:1285 [inline] __se_sys_openat fs/open.c:1280 [inline] __x64_sys_openat+0x135/0x160 fs/open.c:1280 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 Freed by task 9620: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:46 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360 ____kasan_slab_free+0xd5/0x110 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+0xea/0x170 mm/slub.c:1731 slab_free mm/slub.c:3499 [inline] kfree+0xef/0x2a0 mm/slub.c:4559 snd_rawmidi_runtime_free sound/core/rawmidi.c:176 [inline] close_substream+0x360/0x5a0 sound/core/rawmidi.c:528 rawmidi_release_priv+0xe9/0x170 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+0x280/0x430 sound/core/seq/seq_ports.c:537 snd_seq_port_disconnect+0x4f5/0x620 sound/core/seq/seq_ports.c:616 snd_seq_ioctl_unsubscribe_port+0x32c/0x6f0 sound/core/seq/seq_clientmgr.c:1535 snd_seq_oss_midi_close+0x2fc/0x620 sound/core/seq/oss/seq_oss_midi.c:413 snd_seq_oss_synth_reset+0x3e9/0x960 sound/core/seq/oss/seq_oss_synth.c:406 snd_seq_oss_reset+0x56/0x240 sound/core/seq/oss/seq_oss_init.c:436 snd_seq_oss_release+0xe8/0x2c0 sound/core/seq/oss/seq_oss_init.c:413 odev_release+0x52/0x70 sound/core/seq/oss/seq_oss.c:144 __fput+0x234/0x930 fs/file_table.c:311 task_work_run+0x125/0x1a0 kernel/task_work.c:188 tracehook_notify_resume include/linux/tracehook.h:189 [inline] exit_to_user_mode_loop+0x10f/0x130 kernel/entry/common.c:181 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline] syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:307 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x66/0xd0 The buggy address belongs to the object at ffff88805f09e000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 114 bytes inside of 4096-byte region [ffff88805f09e000, ffff88805f09f000) The buggy address belongs to the page: page:ffffea00017c2600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5f098 head:ffffea00017c2600 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffffea0001e86800 0000000300000003 ffff888016842140 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 0x1d2a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 7, ts 488026167144, free_ts 485829600302 prep_new_page mm/page_alloc.c:2426 [inline] get_page_from_freelist+0x1b77/0x1c60 mm/page_alloc.c:4192 __alloc_pages+0x1e1/0x470 mm/page_alloc.c:5474 alloc_slab_page mm/slub.c:1775 [inline] allocate_slab mm/slub.c:1912 [inline] new_slab+0xc0/0x4b0 mm/slub.c:1975 ___slab_alloc+0x81e/0xdf0 mm/slub.c:3008 __slab_alloc mm/slub.c:3095 [inline] slab_alloc_node mm/slub.c:3186 [inline] __kmalloc_node_track_caller+0x1fc/0x3a0 mm/slub.c:4958 kmalloc_reserve net/core/skbuff.c:356 [inline] __alloc_skb+0x22c/0x750 net/core/skbuff.c:427 alloc_skb include/linux/skbuff.h:1162 [inline] nsim_dev_trap_skb_build drivers/net/netdevsim/dev.c:664 [inline] nsim_dev_trap_report drivers/net/netdevsim/dev.c:721 [inline] nsim_dev_trap_report_work+0x2a1/0xb40 drivers/net/netdevsim/dev.c:762 process_one_work+0x863/0x1000 kernel/workqueue.c:2310 worker_thread+0xaa8/0x12a0 kernel/workqueue.c:2457 kthread+0x436/0x520 kernel/kthread.c:334 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287 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+0x637/0x6c0 mm/page_alloc.c:3317 free_unref_page+0x94/0x280 mm/page_alloc.c:3396 free_slab mm/slub.c:2015 [inline] discard_slab mm/slub.c:2021 [inline] __unfreeze_partials+0x1a5/0x200 mm/slub.c:2507 put_cpu_partial+0x12d/0x190 mm/slub.c:2587 qlist_free_all+0x35/0x90 mm/kasan/quarantine.c:176 kasan_quarantine_reduce+0x150/0x160 mm/kasan/quarantine.c:283 __kasan_slab_alloc+0x2f/0xd0 mm/kasan/common.c:444 kasan_slab_alloc include/linux/kasan.h:254 [inline] slab_post_alloc_hook+0x4c/0x380 mm/slab.h:519 slab_alloc_node mm/slub.c:3220 [inline] slab_alloc mm/slub.c:3228 [inline] kmem_cache_alloc_trace+0x103/0x2a0 mm/slub.c:3245 kmalloc include/linux/slab.h:604 [inline] kzalloc include/linux/slab.h:735 [inline] kernfs_fop_open+0x3da/0xbf0 fs/kernfs/file.c:628 do_dentry_open+0x7ff/0xf80 fs/open.c:826 do_open fs/namei.c:3608 [inline] path_openat+0x2682/0x2f30 fs/namei.c:3742 do_filp_open+0x1b3/0x3e0 fs/namei.c:3769 do_sys_openat2+0x142/0x4a0 fs/open.c:1253 do_sys_open fs/open.c:1269 [inline] __do_sys_openat fs/open.c:1285 [inline] __se_sys_openat fs/open.c:1280 [inline] __x64_sys_openat+0x135/0x160 fs/open.c:1280 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 Memory state around the buggy address: ffff88805f09df00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88805f09df80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88805f09e000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88805f09e080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88805f09e100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ---------------- Code disassembly (best guess): 0: 00 9c 8f 84 24 80 00 add %bl,0x802484(%rdi,%rcx,4) 7: 00 00 add %al,(%rax) 9: f6 84 24 81 00 00 00 testb $0x2,0x81(%rsp) 10: 02 11: 0f 85 f6 00 00 00 jne 0x10d 17: 41 f7 c6 00 02 00 00 test $0x200,%r14d 1e: 74 01 je 0x21 20: fb sti 21: 48 c7 44 24 60 0e 36 movq $0x45e0360e,0x60(%rsp) 28: e0 45 * 2a: 4b c7 44 3d 00 00 00 movq $0x0,0x0(%r13,%r15,1) <-- trapping instruction 31: 00 00 33: 66 43 c7 44 3d 09 00 movw $0x0,0x9(%r13,%r15,1) 3a: 00 3b: 43 rex.XB 3c: c6 .byte 0xc6 3d: 44 rex.R 3e: 3d .byte 0x3d 3f: 0b .byte 0xb