[syzbot] KASAN: use-after-free Read in snd_rawmidi_transmit

19 views
Skip to first unread message

syzbot

unread,
Apr 28, 2022, 1:11:33 AM4/28/22
to alsa-...@alsa-project.org, cod...@diwic.se, colin...@intel.com, linux-...@vger.kernel.org, pe...@perex.cz, syzkall...@googlegroups.com, ti...@suse.com
Hello,

syzbot found the following issue on:

HEAD commit: 45ab9400e73f Merge tag 'perf-tools-fixes-for-v5.18-2022-04..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=115cb458f00000
kernel config: https://syzkaller.appspot.com/x/.config?x=d1843173f299d1e8
dashboard link: https://syzkaller.appspot.com/bug?extid=39e3268af9968f153591
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+39e326...@syzkaller.appspotmail.com

==================================================================
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 ffff88804ece205e by task kworker/0:1H/9

CPU: 0 PID: 9 Comm: kworker/0:1H Not tainted 5.18.0-rc3-syzkaller-00196-g45ab9400e73f #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events_highpri snd_usbmidi_out_work
Call Trace:
<TASK>
__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
</TASK>

Allocated by task 7013:
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:4462
kmalloc_node include/linux/slab.h:604 [inline]
kvmalloc_node+0x6d/0x100 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+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:3476 [inline]
path_openat+0x26c0/0x2ec0 fs/namei.c:3609
do_filp_open+0x277/0x4f0 fs/namei.c:3636
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+0x44/0xae

Freed by task 7013:
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:1728 [inline]
slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1754
slab_free mm/slub.c:3510 [inline]
kfree+0xc6/0x210 mm/slub.c:4552
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:164
get_signal+0x15d9/0x1780 kernel/signal.c:2641
arch_do_signal_or_restart+0x8d/0x750 arch/x86/kernel/signal.c:867
exit_to_user_mode_loop+0x74/0x160 kernel/entry/common.c:166
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/0x70 kernel/entry/common.c:294
entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff88804ece2000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 94 bytes inside of
4096-byte region [ffff88804ece2000, ffff88804ece3000)

The buggy address belongs to the physical page:
page:ffffea00013b3800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4ece0
head:ffffea00013b3800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea00014fe200 dead000000000002 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 4945, tgid 4938 (syz-executor.5), ts 180879892415, free_ts 180837137303
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:1799
allocate_slab+0x5e/0x560 mm/slub.c:1944
new_slab mm/slub.c:2004 [inline]
___slab_alloc+0x41e/0xcd0 mm/slub.c:3005
__slab_alloc mm/slub.c:3092 [inline]
slab_alloc_node mm/slub.c:3183 [inline]
slab_alloc mm/slub.c:3225 [inline]
kmem_cache_alloc_trace+0x25c/0x310 mm/slub.c:3256
kmalloc include/linux/slab.h:581 [inline]
kzalloc include/linux/slab.h:714 [inline]
ipv4_mib_init_net+0x2da/0x4d0 net/ipv4/af_inet.c:1772
ops_init+0x313/0x430 net/core/net_namespace.c:134
setup_net+0x4bb/0xc10 net/core/net_namespace.c:325
copy_net_ns+0x359/0x5b0 net/core/net_namespace.c:471
create_new_namespaces+0x4db/0x8e0 kernel/nsproxy.c:110
copy_namespaces+0x333/0x390 kernel/nsproxy.c:178
copy_process+0x18e9/0x3f70 kernel/fork.c:2237
kernel_clone+0x22f/0x7a0 kernel/fork.c:2639
__do_sys_clone kernel/fork.c:2756 [inline]
__se_sys_clone kernel/fork.c:2740 [inline]
__x64_sys_clone+0x289/0x310 kernel/fork.c:2740
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
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:2043 [inline]
discard_slab mm/slub.c:2049 [inline]
__unfreeze_partials+0x1ab/0x200 mm/slub.c:2523
put_cpu_partial+0x116/0x180 mm/slub.c:2599
do_slab_free mm/slub.c:3498 [inline]
___cache_free+0x118/0x1a0 mm/slub.c:3517
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:749 [inline]
slab_alloc_node mm/slub.c:3217 [inline]
slab_alloc mm/slub.c:3225 [inline]
__kmem_cache_alloc_lru mm/slub.c:3232 [inline]
kmem_cache_alloc+0x199/0x2f0 mm/slub.c:3242
getname_flags+0xb8/0x4e0 fs/namei.c:138
user_path_at_empty+0x2a/0x1a0 fs/namei.c:2850
do_readlinkat+0x11b/0x3b0 fs/stat.c:456
__do_sys_readlink fs/stat.c:489 [inline]
__se_sys_readlink fs/stat.c:486 [inline]
__x64_sys_readlink+0x7b/0x90 fs/stat.c:486
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+0x44/0xae

Memory state around the buggy address:
ffff88804ece1f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88804ece1f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88804ece2000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88804ece2080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88804ece2100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Jun 1, 2022, 4:37:21 AM6/1/22
to alsa-dev...@alsa-project.org, alsa-...@alsa-project.org, cod...@diwic.se, colin...@intel.com, linux-...@vger.kernel.org, pe...@perex.cz, syzkall...@googlegroups.com, ti...@suse.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 2a5699b0de4e Merge tag 'leds-5.19-rc1' of git://git.kernel..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=13df4d13f00000
kernel config: https://syzkaller.appspot.com/x/.config?x=f915857c44e13980
dashboard link: https://syzkaller.appspot.com/bug?extid=39e3268af9968f153591
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=119d1fcbf00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17716bedf00000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+39e326...@syzkaller.appspotmail.com

==================================================================
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 ffff888074d3c07f by task kworker/1:1H/756

CPU: 1 PID: 756 Comm: kworker/1:1H Not tainted 5.18.0-syzkaller-11650-g2a5699b0de4e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events_highpri snd_usbmidi_out_work
Call Trace:
<TASK>
__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
</TASK>

Allocated by task 3983:
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:623 [inline]
kvmalloc_node+0x6e/0x160 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+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+0x789/0x1040 fs/open.c:848
do_open fs/namei.c:3527 [inline]
path_openat+0x26c0/0x2ec0 fs/namei.c:3660
do_filp_open+0x277/0x4f0 fs/namei.c:3687
do_sys_openat2+0x13b/0x500 fs/open.c:1278
do_sys_open fs/open.c:1294 [inline]
__do_sys_openat fs/open.c:1310 [inline]
__se_sys_openat fs/open.c:1305 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1305
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 3983:
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
ptrace_notify+0x29f/0x350 kernel/signal.c:2372
ptrace_report_syscall include/linux/ptrace.h:427 [inline]
ptrace_report_syscall_exit include/linux/ptrace.h:489 [inline]
syscall_exit_work+0x8c/0xe0 kernel/entry/common.c:249
syscall_exit_to_user_mode_prepare+0x62/0x80 kernel/entry/common.c:276
__syscall_exit_to_user_mode_work kernel/entry/common.c:281 [inline]
syscall_exit_to_user_mode+0xa/0x60 kernel/entry/common.c:294
entry_SYSCALL_64_after_hwframe+0x46/0xb0

The buggy address belongs to the object at ffff888074d3c000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 127 bytes inside of
4096-byte region [ffff888074d3c000, ffff888074d3d000)

The buggy address belongs to the physical page:
page:ffffea0001d34e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x74d38
head:ffffea0001d34e00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 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 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3983, tgid 3982 (syz-executor242), ts 217737880306, free_ts 217582307012
prep_new_page mm/page_alloc.c:2456 [inline]
get_page_from_freelist+0x72b/0x7a0 mm/page_alloc.c:4198
__alloc_pages+0x259/0x560 mm/page_alloc.c:5426
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]
slab_alloc mm/slub.c:3222 [inline]
__kmalloc+0x2ba/0x370 mm/slub.c:4413
kmalloc include/linux/slab.h:605 [inline]
tomoyo_realpath_from_path+0xd8/0x5f0 security/tomoyo/realpath.c:254
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_check_open_permission+0x22f/0x490 security/tomoyo/file.c:771
security_file_open+0x50/0x560 security/security.c:1645
do_dentry_open+0x34a/0x1040 fs/open.c:835
do_open fs/namei.c:3527 [inline]
path_openat+0x26c0/0x2ec0 fs/namei.c:3660
do_filp_open+0x277/0x4f0 fs/namei.c:3687
do_sys_openat2+0x13b/0x500 fs/open.c:1278
do_sys_open fs/open.c:1294 [inline]
__do_sys_openat fs/open.c:1310 [inline]
__se_sys_openat fs/open.c:1305 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1305
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
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+0x812/0x900 mm/page_alloc.c:1421
free_unref_page_prepare mm/page_alloc.c:3343 [inline]
free_unref_page+0x7d/0x390 mm/page_alloc.c:3438
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:187
kasan_quarantine_reduce+0x169/0x180 mm/kasan/quarantine.c:294
__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]
__kmalloc_node+0x1f3/0x400 mm/slub.c:4461
kmalloc_node include/linux/slab.h:623 [inline]
kvmalloc_node+0x6e/0x160 mm/util.c:613
kvmalloc include/linux/slab.h:750 [inline]
seq_buf_alloc fs/seq_file.c:38 [inline]
seq_read_iter+0x1f6/0xd30 fs/seq_file.c:210
call_read_iter include/linux/fs.h:2054 [inline]
new_sync_read fs/read_write.c:401 [inline]
vfs_read+0xa01/0xd10 fs/read_write.c:482
ksys_read+0x19b/0x2c0 fs/read_write.c:620
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

Memory state around the buggy address:
ffff888074d3bf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888074d3bf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888074d3c000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888074d3c080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888074d3c100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Hillf Danton

unread,
Jun 1, 2022, 10:05:41 AM6/1/22
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Wed, 01 Jun 2022 01:37:20 -0700
To fix the uaf, cancel work in the close path.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2a5699b0de4e

--- x/sound/usb/midi.c
+++ y/sound/usb/midi.c
@@ -1145,6 +1145,11 @@ static int snd_usbmidi_output_open(struc

static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream)
{
+ if (substream->runtime &&
+ substream->runtime->private_data) {
+ struct usbmidi_out_port *port = substream->runtime->private_data;
+ cancel_work_sync(&port->ep->work);
+ }
return substream_open(substream, 0, 0);
}

--

syzbot

unread,
Jun 1, 2022, 11:35:09 AM6/1/22
to alsa-dev...@alsa-project.org, alsa-...@alsa-project.org, anthony....@intel.com, cod...@diwic.se, colin...@intel.com, hda...@sina.com, linux-...@vger.kernel.org, naama...@linux.intel.com, pe...@perex.cz, sasha....@intel.com, syzkall...@googlegroups.com, ti...@suse.com
syzbot has bisected this issue to:

commit d098538ed4e8a6c09f86cf243f406c1451066040
Author: Sasha Neftin <sasha....@intel.com>
Date: Mon Mar 21 06:05:10 2022 +0000

igc: Remove igc_set_spd_dplx method

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=16458313f00000
start commit: 2a5699b0de4e Merge tag 'leds-5.19-rc1' of git://git.kernel..
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=15458313f00000
console output: https://syzkaller.appspot.com/x/log.txt?x=11458313f00000
Reported-by: syzbot+39e326...@syzkaller.appspotmail.com
Fixes: d098538ed4e8 ("igc: Remove igc_set_spd_dplx method")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

syzbot

unread,
Jun 1, 2022, 11:58:07 AM6/1/22
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+39e326...@syzkaller.appspotmail.com

Tested on:

commit: 2a5699b0 Merge tag 'leds-5.19-rc1' of git://git.kernel..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel config: https://syzkaller.appspot.com/x/.config?x=f915857c44e13980
dashboard link: https://syzkaller.appspot.com/bug?extid=39e3268af9968f153591
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=1578ed47f00000

Note: testing is done by a robot and is best-effort only.

syzbot

unread,
Jul 1, 2022, 3:21:17 PM7/1/22
to alsa-dev...@alsa-project.org, alsa-...@alsa-project.org, anthony....@intel.com, cle...@ladisch.de, cod...@diwic.se, colin...@intel.com, hda...@sina.com, linux-...@vger.kernel.org, naama...@linux.intel.com, pe...@perex.cz, sasha....@intel.com, syzkall...@googlegroups.com, ti...@suse.com, ti...@suse.de
syzbot suspects this issue was fixed by commit:

commit 0125de38122f0f66bf61336158d12a1aabfe6425
Author: Takashi Iwai <ti...@suse.de>
Date: Wed May 25 13:12:03 2022 +0000

ALSA: usb-audio: Cancel pending work at closing a MIDI substream

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1180b25c080000
start commit: 2a5699b0de4e Merge tag 'leds-5.19-rc1' of git://git.kernel..
git tree: upstream
If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: ALSA: usb-audio: Cancel pending work at closing a MIDI substream

Dmitry Vyukov

unread,
Jul 4, 2022, 3:51:28 AM7/4/22
to syzbot, alsa-dev...@alsa-project.org, alsa-...@alsa-project.org, anthony....@intel.com, cle...@ladisch.de, cod...@diwic.se, colin...@intel.com, hda...@sina.com, linux-...@vger.kernel.org, naama...@linux.intel.com, pe...@perex.cz, sasha....@intel.com, syzkall...@googlegroups.com, ti...@suse.com, ti...@suse.de
Looks reasonable:
Reply all
Reply to author
Forward
0 new messages