==================================================================
BUG: KASAN: use-after-free in __snd_rawmidi_transmit_peek+0x261/0x360 sound/core/rawmidi.c:1286
Read of size 1 at addr ffff8880797d605f by task syz-executor.0/5754
CPU: 0 PID: 5754 Comm: syz-executor.0 Not tainted 5.18.0-rc5-syzkaller-00016-g107c948d1d3e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
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/0x467 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
snd_usbmidi_error_timer+0x128/0x390 sound/usb/midi.c:362
call_timer_fn+0x1a5/0x6b0 kernel/time/timer.c:1421
expire_timers kernel/time/timer.c:1466 [inline]
__run_timers.part.0+0x679/0xa80 kernel/time/timer.c:1737
__run_timers kernel/time/timer.c:1715 [inline]
run_timer_softirq+0xb3/0x1d0 kernel/time/timer.c:1750
__do_softirq+0x29b/0x9c2 kernel/softirq.c:558
invoke_softirq kernel/softirq.c:432 [inline]
__irq_exit_rcu+0x123/0x180 kernel/softirq.c:637
irq_exit_rcu+0x5/0x20 kernel/softirq.c:649
sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1097
asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:645
RIP: 0010:qlist_free_all+0x6c/0x1b0 mm/kasan/quarantine.c:171
Code: 00 fc ff df c6 04 08 fb e8 f1 70 ff ff 48 85 db 0f 85 98 00 00 00 9c 58 f6 c4 02 0f 85 0b 01 00 00 48 85 db 74 01 fb 48 85 ed <0f> 84 d2 00 00 00 48 89 eb 4d 85 e4 4d 89 e7 74 7d 49 63 87 80 00
RSP: 0018:ffffc900061a79e0 EFLAGS: 00000282
RAX: 0000000000000002 RBX: 0000000000000200 RCX: 1ffffffff1b6fbc1
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffff8880774e3d40 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff817ebcc8 R11: 000000000000003f R12: 0000000000000000
R13: ffff888020490000 R14: ffff888020490000 R15: ffff888010c40700
kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:283
__kasan_slab_alloc+0x97/0xb0 mm/kasan/common.c:446
kasan_slab_alloc include/linux/kasan.h:224 [inline]
slab_post_alloc_hook mm/slab.h:749 [inline]
slab_alloc mm/slab.c:3316 [inline]
__kmem_cache_alloc_lru mm/slab.c:3493 [inline]
kmem_cache_alloc+0x265/0x560 mm/slab.c:3513
kmem_cache_zalloc include/linux/slab.h:704 [inline]
taskstats_tgid_alloc kernel/taskstats.c:562 [inline]
taskstats_exit+0x5c6/0xb50 kernel/taskstats.c:601
do_exit+0x887/0x2a00 kernel/exit.c:780
do_group_exit+0xd2/0x2f0 kernel/exit.c:925
get_signal+0x22df/0x24c0 kernel/signal.c:2864
arch_do_signal_or_restart+0x82/0x20f0 arch/x86/kernel/signal.c:867
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/0x60 kernel/entry/common.c:294
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f16660ade11
Code: 24 0c 89 3c 24 48 89 4c 24 18 e8 aa e7 ff ff 4c 8b 54 24 18 48 8b 54 24 10 41 89 c0 8b 74 24 0c 8b 3c 24 b8 e6 00 00 00 0f 05 <44> 89 c7 48 89 04 24 e8 e3 e7 ff ff 48 8b 04 24 eb 97 66 2e 0f 1f
RSP: 002b:00007ffde19933f0 EFLAGS: 00000293 ORIG_RAX: 00000000000000e6
RAX: fffffffffffffdfc RBX: 00007f166619bf60 RCX: 00007f16660ade11
RDX: 00007ffde1993430 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 00007f166619d960 R08: 0000000000000000 R09: 00007ffde19b6080
R10: 0000000000000000 R11: 0000000000000293 R12: 000000000002dd08
R13: 00007ffde1993540 R14: 00007ffde1993560 R15: 0000000000000032
Allocated by task 5759:
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+0xa6/0xd0 mm/kasan/common.c:524
kmalloc_node include/linux/slab.h:604 [inline]
kvmalloc_node+0x3e/0x190 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+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/0x11e0 fs/open.c:824
do_open fs/namei.c:3476 [inline]
path_openat+0x1c71/0x2910 fs/namei.c:3609
do_filp_open+0x1aa/0x400 fs/namei.c:3636
do_sys_openat2+0x16d/0x4c0 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+0x13f/0x1f0 fs/open.c:1240
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+0x44/0xae
Freed by task 5759:
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+0x13d/0x180 mm/kasan/common.c:328
kasan_slab_free include/linux/kasan.h:200 [inline]
__cache_free mm/slab.c:3439 [inline]
kfree+0x113/0x310 mm/slab.c:3810
kvfree+0x42/0x50 mm/util.c:622
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_reset+0x422/0x880 sound/core/seq/oss/seq_oss_synth.c:406
snd_seq_oss_reset+0x6f/0x290 sound/core/seq/oss/seq_oss_init.c:435
snd_seq_oss_release+0x78/0x1a0 sound/core/seq/oss/seq_oss_init.c:412
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:164
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop kernel/entry/common.c:169 [inline]
exit_to_user_mode_prepare+0x23c/0x250 kernel/entry/common.c:201
__syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:294
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
The buggy address belongs to the object at ffff8880797d6000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 95 bytes inside of
4096-byte region [ffff8880797d6000, ffff8880797d7000)
The buggy address belongs to the physical page:
page:ffffea0001e5f580 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x797d6
head:ffffea0001e5f580 order:1 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0001c92f08 ffffea0001ecbf88 ffff888010c40900
raw: 0000000000000000 ffff8880797d6000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0x3420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 5759, tgid 5754 (syz-executor.0), ts 186337698637, free_ts 186180468597
prep_new_page mm/page_alloc.c:2441 [inline]
get_page_from_freelist+0xba2/0x3e00 mm/page_alloc.c:4182
__alloc_pages+0x1b2/0x500 mm/page_alloc.c:5408
__alloc_pages_node include/linux/gfp.h:587 [inline]
kmem_getpages mm/slab.c:1378 [inline]
cache_grow_begin+0x75/0x350 mm/slab.c:2584
cache_alloc_refill+0x27f/0x380 mm/slab.c:2957
____cache_alloc mm/slab.c:3040 [inline]
____cache_alloc mm/slab.c:3023 [inline]
slab_alloc_node mm/slab.c:3241 [inline]
kmem_cache_alloc_node_trace+0x518/0x5b0 mm/slab.c:3625
__do_kmalloc_node mm/slab.c:3647 [inline]
__kmalloc_node+0x38/0x60 mm/slab.c:3655
kmalloc_node include/linux/slab.h:604 [inline]
kvmalloc_node+0x3e/0x190 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+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
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+0x549/0xd20 mm/page_alloc.c:1406
free_unref_page_prepare mm/page_alloc.c:3328 [inline]
free_unref_page+0x19/0x6a0 mm/page_alloc.c:3423
slab_destroy mm/slab.c:1630 [inline]
slabs_destroy+0x89/0xc0 mm/slab.c:1650
cache_flusharray mm/slab.c:3411 [inline]
___cache_free+0x34e/0x670 mm/slab.c:3474
qlink_free mm/kasan/quarantine.c:157 [inline]
qlist_free_all+0x4f/0x1b0 mm/kasan/quarantine.c:176
kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:283
____kasan_kmalloc mm/kasan/common.c:481 [inline]
__kasan_kmalloc+0xba/0xd0 mm/kasan/common.c:524
kasan_kmalloc include/linux/kasan.h:234 [inline]
kmem_cache_alloc_trace+0x1ea/0x4a0 mm/slab.c:3583
kmalloc include/linux/slab.h:581 [inline]
kzalloc include/linux/slab.h:714 [inline]
snd_seq_port_connect+0x5d/0x540 sound/core/seq/seq_ports.c:565
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_reset+0x48e/0x880 sound/core/seq/oss/seq_oss_synth.c:407
snd_seq_oss_reset+0x6f/0x290 sound/core/seq/oss/seq_oss_init.c:435
snd_seq_oss_release+0x78/0x1a0 sound/core/seq/oss/seq_oss_init.c:412
odev_release+0x4f/0x70 sound/core/seq/oss/seq_oss.c:144
Memory state around the buggy address:
ffff8880797d5f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880797d5f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880797d6000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880797d6080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880797d6100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess), 3 bytes skipped:
0: df c6 ffreep %st(6)
2: 04 08 add $0x8,%al
4: fb sti
5: e8 f1 70 ff ff callq 0xffff70fb
a: 48 85 db test %rbx,%rbx
d: 0f 85 98 00 00 00 jne 0xab
13: 9c pushfq
14: 58 pop %rax
15: f6 c4 02 test $0x2,%ah
18: 0f 85 0b 01 00 00 jne 0x129
1e: 48 85 db test %rbx,%rbx
21: 74 01 je 0x24
23: fb sti
24: 48 85 ed test %rbp,%rbp
* 27: 0f 84 d2 00 00 00 je 0xff <-- trapping instruction
2d: 48 89 eb mov %rbp,%rbx
30: 4d 85 e4 test %r12,%r12
33: 4d 89 e7 mov %r12,%r15
36: 74 7d je 0xb5
38: 49 rex.WB
39: 63 .byte 0x63
3a: 87 .byte 0x87
3b: 80 .byte 0x80