==================================================================
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+0x39a/0x410 sound/core/rawmidi.c:1411
Read of size 1 at addr ffff888075b90026 by task dhcpcd/3837
CPU: 1 PID: 3837 Comm: dhcpcd Not tainted 5.15.179-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
print_address_description+0x63/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
__snd_rawmidi_transmit_peek sound/core/rawmidi.c:1286 [inline]
snd_rawmidi_transmit+0x39a/0x410 sound/core/rawmidi.c:1411
snd_usbmidi_standard_output+0x1eb/0xf20 sound/usb/midi.c:650
snd_usbmidi_do_output+0x206/0x520 sound/usb/midi.c:311
snd_usbmidi_error_timer+0x2a3/0x580 sound/usb/midi.c:362
call_timer_fn+0x16d/0x560 kernel/time/timer.c:1451
expire_timers kernel/time/timer.c:1496 [inline]
__run_timers+0x67c/0x890 kernel/time/timer.c:1767
run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1780
handle_softirqs+0x3a7/0x930 kernel/softirq.c:558
__do_softirq kernel/softirq.c:592 [inline]
invoke_softirq kernel/softirq.c:432 [inline]
__irq_exit_rcu+0x157/0x240 kernel/softirq.c:641
irq_exit_rcu+0x5/0x20 kernel/softirq.c:653
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:__zone_watermark_ok+0x1ae/0x3f0 mm/page_alloc.c:3919
Code: 48 83 c2 68 48 83 c5 68 48 83 44 24 10 68 49 83 c6 68 48 83 44 24 18 68 49 83 c4 68 49 83 ff 0b 0f 84 8d 01 00 00 41 83 ff 0c <48> 89 14 24 0f 83 5d 01 00 00 4c 8d 6c 1d 00 48 8d bc 13 a0 01 00
RSP: 0018:ffffc900034bf630 EFLAGS: 00000297
RAX: ffff88813fffb870 RBX: 0000000000000208 RCX: dffffc0000000000
RDX: ffff88813fffb700 RSI: 0000000000000008 RDI: ffff88813fffbd90
RBP: ffff88813fffb840 R08: dffffc0000000000 R09: ffffed1027fff7b3
R10: 0000000000000000 R11: dffffc0000000001 R12: ffff88813fffb880
R13: 0000000000000005 R14: ffff88813fffb850 R15: 0000000000000005
zone_watermark_fast+0x171/0x240 mm/page_alloc.c:3976
get_page_from_freelist+0x4cb/0x3d40 mm/page_alloc.c:4146
__alloc_pages+0x272/0x700 mm/page_alloc.c:5466
__alloc_pages_node include/linux/gfp.h:570 [inline]
alloc_pages_node include/linux/gfp.h:584 [inline]
kmalloc_large_node+0x7c/0x180 mm/slub.c:4421
__kmalloc_node+0x22d/0x390 mm/slub.c:4437
kmalloc_node include/linux/slab.h:614 [inline]
kvmalloc_node+0x80/0x140 mm/util.c:619
kvmalloc include/linux/mm.h:805 [inline]
kvzalloc include/linux/mm.h:813 [inline]
proc_sys_call_handler+0x3d0/0x8a0 fs/proc/proc_sysctl.c:571
call_read_iter include/linux/fs.h:2166 [inline]
new_sync_read fs/read_write.c:404 [inline]
vfs_read+0xa93/0xe10 fs/read_write.c:485
ksys_read+0x1a2/0x2c0 fs/read_write.c:623
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7fe29845fb6a
Code: 00 3d 00 00 41 00 75 0d 50 48 8d 3d 2d 08 0a 00 e8 ea 7d 01 00 31 c0 e9 07 ff ff ff 64 8b 04 25 18 00 00 00 85 c0 75 1b 0f 05 <48> 3d 00 f0 ff ff 76 6c 48 8b 15 8f a2 0d 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffcd34402e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00000000000100a0 RCX: 00007fe29845fb6a
RDX: 00000000000100a0 RSI: 00007ffcd3440388 RDI: 0000000000000012
RBP: 0000000000000012 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: ffffffffffffffff
R13: 00007ffcd3440388 R14: 00007ffcd3440388 R15: 0000000000000000
Allocated by task 10117:
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+0xba/0xf0 mm/kasan/common.c:513
kasan_kmalloc include/linux/kasan.h:264 [inline]
__kmalloc_node+0x199/0x390 mm/slub.c:4455
kmalloc_node include/linux/slab.h:614 [inline]
kvmalloc_node+0x80/0x140 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+0x2a4/0x6d0 sound/core/rawmidi.c:306
rawmidi_open_priv+0xc2/0x680 sound/core/rawmidi.c:357
snd_rawmidi_kernel_open+0x1b3/0x240 sound/core/rawmidi.c:392
midisynth_use+0xe7/0x2a0 sound/core/seq/seq_midi.c:221
subscribe_port sound/core/seq/seq_ports.c:412 [inline]
check_and_subscribe_port+0x604/0xab0 sound/core/seq/seq_ports.c:495
snd_seq_port_connect+0x284/0x480 sound/core/seq/seq_ports.c:581
snd_seq_ioctl_subscribe_port+0x31a/0x780 sound/core/seq/seq_clientmgr.c:1490
snd_seq_oss_midi_open+0x425/0x9c0 sound/core/seq/oss/seq_oss_midi.c:365
snd_seq_oss_synth_setup_midi+0x114/0x500 sound/core/seq/oss/seq_oss_synth.c:269
snd_seq_oss_open+0x942/0x1010 sound/core/seq/oss/seq_oss_init.c:261
odev_open+0x5f/0x90 sound/core/seq/oss/seq_oss.c:128
chrdev_open+0x54a/0x630 fs/char_dev.c:414
do_dentry_open+0x807/0xfb0 fs/open.c:826
do_open fs/namei.c:3608 [inline]
path_openat+0x2705/0x2f20 fs/namei.c:3742
do_filp_open+0x21c/0x460 fs/namei.c:3769
do_sys_openat2+0x13b/0x4f0 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+0x243/0x290 fs/open.c:1280
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
Freed by task 10117:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
____kasan_slab_free+0xd8/0x120 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+0xdd/0x160 mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kfree+0xf1/0x270 mm/slub.c:4559
snd_rawmidi_runtime_free sound/core/rawmidi.c:176 [inline]
close_substream+0x390/0x600 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+0x2c5/0x470 sound/core/seq/seq_ports.c:537
snd_seq_port_disconnect+0x4ab/0x5d0 sound/core/seq/seq_ports.c:616
snd_seq_ioctl_unsubscribe_port+0x31a/0x780 sound/core/seq/seq_clientmgr.c:1535
snd_seq_oss_midi_close+0x348/0x760 sound/core/seq/oss/seq_oss_midi.c:413
snd_seq_oss_synth_reset+0x3c2/0xa20 sound/core/seq/oss/seq_oss_synth.c:406
snd_seq_oss_reset+0x57/0x240 sound/core/seq/oss/seq_oss_init.c:436
snd_seq_oss_release+0xea/0x300 sound/core/seq/oss/seq_oss_init.c:413
odev_release+0x52/0x70 sound/core/seq/oss/seq_oss.c:144
__fput+0x3fe/0x8e0 fs/file_table.c:311
task_work_run+0x129/0x1a0 kernel/task_work.c:188
tracehook_notify_resume include/linux/tracehook.h:189 [inline]
exit_to_user_mode_loop+0x106/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+0x5d/0x240 kernel/entry/common.c:307
do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x66/0xd0
The buggy address belongs to the object at ffff888075b90000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 38 bytes inside of
4096-byte region [ffff888075b90000, ffff888075b91000)
The buggy address belongs to the page:
page:ffffea0001d6e400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x75b90
head:ffffea0001d6e400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888017442140
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 0x1d2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 3545, ts 666119139864, free_ts 665948262394
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192
__alloc_pages+0x272/0x700 mm/page_alloc.c:5466
alloc_slab_page mm/slub.c:1775 [inline]
allocate_slab mm/slub.c:1912 [inline]
new_slab+0xbb/0x4b0 mm/slub.c:1975
___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
__slab_alloc mm/slub.c:3095 [inline]
slab_alloc_node mm/slub.c:3186 [inline]
slab_alloc mm/slub.c:3228 [inline]
__kmalloc+0x1c9/0x300 mm/slub.c:4403
kmalloc include/linux/slab.h:596 [inline]
tomoyo_realpath_from_path+0xd8/0x5e0 security/tomoyo/realpath.c:254
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_path_number_perm+0x225/0x810 security/tomoyo/file.c:723
tomoyo_path_mknod+0x172/0x1b0 security/tomoyo/tomoyo.c:239
security_path_mknod+0xf1/0x150 security/security.c:1147
may_o_create fs/namei.c:3284 [inline]
lookup_open fs/namei.c:3425 [inline]
open_last_lookups fs/namei.c:3532 [inline]
path_openat+0xc78/0x2f20 fs/namei.c:3739
do_filp_open+0x21c/0x460 fs/namei.c:3769
do_sys_openat2+0x13b/0x4f0 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+0x243/0x290 fs/open.c:1280
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
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+0xc34/0xcf0 mm/page_alloc.c:3317
free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
free_slab mm/slub.c:2015 [inline]
discard_slab mm/slub.c:2021 [inline]
__unfreeze_partials+0x1b7/0x210 mm/slub.c:2507
put_cpu_partial+0x132/0x1a0 mm/slub.c:2587
do_slab_free mm/slub.c:3487 [inline]
___cache_free+0xe3/0x100 mm/slub.c:3506
qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
__kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
kasan_slab_alloc include/linux/kasan.h:254 [inline]
slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
slab_alloc_node mm/slub.c:3220 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
vm_area_dup+0x1e/0xb0 kernel/fork.c:358
__split_vma+0xb4/0x420 mm/mmap.c:2718
mprotect_fixup+0x675/0x7d0 mm/mprotect.c:477
do_mprotect_pkey+0x75b/0xa50 mm/mprotect.c:636
__do_sys_mprotect mm/mprotect.c:662 [inline]
__se_sys_mprotect mm/mprotect.c:659 [inline]
__x64_sys_mprotect+0x7c/0x90 mm/mprotect.c:659
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
Memory state around the buggy address:
ffff888075b8ff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888075b8ff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888075b90000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888075b90080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888075b90100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
0: 48 83 c2 68 add $0x68,%rdx
4: 48 83 c5 68 add $0x68,%rbp
8: 48 83 44 24 10 68 addq $0x68,0x10(%rsp)
e: 49 83 c6 68 add $0x68,%r14
12: 48 83 44 24 18 68 addq $0x68,0x18(%rsp)
18: 49 83 c4 68 add $0x68,%r12
1c: 49 83 ff 0b cmp $0xb,%r15
20: 0f 84 8d 01 00 00 je 0x1b3
26: 41 83 ff 0c cmp $0xc,%r15d
* 2a: 48 89 14 24 mov %rdx,(%rsp) <-- trapping instruction
2e: 0f 83 5d 01 00 00 jae 0x191
34: 4c 8d 6c 1d 00 lea 0x0(%rbp,%rbx,1),%r13
39: 48 rex.W
3a: 8d .byte 0x8d
3b: bc 13 a0 01 00 mov $0x1a013,%esp