syzbot


KASAN: use-after-free Read in snd_rawmidi_transmit (2)

Status: upstream: reported on 2025/02/10 01:41
Reported-by: syzbot+3e807bf5fd2a4b2764a9@syzkaller.appspotmail.com
First crash: 34d, last: 34d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in snd_rawmidi_transmit 4 187d 240d 0/3 auto-obsoleted due to no activity on 2024/12/18 18:24
upstream KASAN: use-after-free Read in snd_rawmidi_transmit usb sound C done done 7 1018d 1053d 22/28 fixed on 2023/02/24 13:50

Sample crash report:
==================================================================
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 ffff88807c1a205e by task syz-executor/4172

CPU: 1 PID: 4172 Comm: syz-executor Not tainted 5.15.178-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Call Trace:
 <IRQ>
 __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
 </IRQ>
 <TASK>
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:676
RIP: 0010:arch_test_and_set_bit arch/x86/include/asm/bitops.h:138 [inline]
RIP: 0010:test_and_set_bit include/asm-generic/bitops/instrumented-atomic.h:71 [inline]
RIP: 0010:queue_work_on+0x1f4/0x250 kernel/workqueue.c:1558
Code: 11 e8 a0 b0 2d 00 4d 85 e4 75 16 e8 96 b0 2d 00 eb 15 e8 8f b0 2d 00 e8 5a 7a ec 08 4d 85 e4 74 ea e8 80 b0 2d 00 fb 45 84 ed <0f> 94 c0 48 c7 44 24 20 0e 36 e0 45 48 b9 00 00 00 00 00 fc ff df
RSP: 0018:ffffc90002edf920 EFLAGS: 00000246
RAX: ffffffff8152d510 RBX: 0000000000000000 RCX: ffff88802671bb80
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc90002edf9f0 R08: ffffffff8152d4e6 R09: fffffbfff2131823
R10: 0000000000000000 R11: dffffc0000000001 R12: 0000000000000200
R13: 0000000000000000 R14: 0000000000000046 R15: 1ffff920005dbf28
 queue_work include/linux/workqueue.h:512 [inline]
 synchronize_rcu_expedited+0x4eb/0x740 kernel/rcu/tree_exp.h:856
 namespace_unlock+0x297/0x4d0 fs/namespace.c:1454
 do_umount fs/namespace.c:1677 [inline]
 path_umount+0xea2/0xf50 fs/namespace.c:1759
 ksys_umount fs/namespace.c:1782 [inline]
 __do_sys_umount fs/namespace.c:1787 [inline]
 __se_sys_umount fs/namespace.c:1785 [inline]
 __x64_sys_umount+0x122/0x170 fs/namespace.c:1785
 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:0x7f488b49f117
Code: a8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 0f 1f 44 00 00 31 f6 e9 09 00 00 00 66 0f 1f 84 00 00 00 00 00 b8 a6 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 c7 c2 a8 ff ff ff f7 d8 64 89 02 b8
RSP: 002b:00007ffff18e8d48 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
RAX: ffffffffffffffda RBX: 00007f488b51f08c RCX: 00007f488b49f117
RDX: 0000000000000000 RSI: 0000000000000009 RDI: 00007ffff18e8e00
RBP: 00007ffff18e8e00 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000ffffffff R11: 0000000000000246 R12: 00007ffff18e9e90
R13: 00007f488b51f08c R14: 00000000000250e5 R15: 00007ffff18e9ed0
 </TASK>

Allocated by task 5587:
 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 5587:
 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_ioctl+0x259/0x11e0 sound/core/seq/oss/seq_oss_ioctl.c:80
 odev_ioctl+0xb4/0xe0 sound/core/seq/oss/seq_oss.c:184
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
 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

The buggy address belongs to the object at ffff88807c1a2000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 94 bytes inside of
 4096-byte region [ffff88807c1a2000, ffff88807c1a3000)
The buggy address belongs to the page:
page:ffffea0001f06800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7c1a0
head:ffffea0001f06800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 5587, ts 150737809212, free_ts 150711725909
 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:5465
 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]
 __kmalloc_node+0x1fa/0x390 mm/slub.c:4451
 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+0x92/0x680 sound/core/rawmidi.c:352
 snd_rawmidi_kernel_open+0x1b3/0x240 sound/core/rawmidi.c:392
 midisynth_subscribe+0xe3/0x350 sound/core/seq/seq_midi.c:177
 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+0x207/0x480 sound/core/seq/seq_ports.c:576
 snd_seq_ioctl_subscribe_port+0x31a/0x780 sound/core/seq/seq_clientmgr.c:1490
 snd_seq_oss_midi_open+0x5c7/0x9c0 sound/core/seq/oss/seq_oss_midi.c:374
 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
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
 getname_flags+0xb8/0x4e0 fs/namei.c:138
 user_path_at_empty+0x2a/0x180 fs/namei.c:2882
 user_path_at include/linux/namei.h:57 [inline]
 do_fchmodat fs/open.c:619 [inline]
 __do_sys_chmod fs/open.c:639 [inline]
 __se_sys_chmod fs/open.c:637 [inline]
 __x64_sys_chmod+0xda/0x180 fs/open.c:637
 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

Memory state around the buggy address:
 ffff88807c1a1f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88807c1a1f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88807c1a2000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff88807c1a2080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807c1a2100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
   0:	11 e8                	adc    %ebp,%eax
   2:	a0 b0 2d 00 4d 85 e4 	movabs 0x1675e4854d002db0,%al
   9:	75 16
   b:	e8 96 b0 2d 00       	call   0x2db0a6
  10:	eb 15                	jmp    0x27
  12:	e8 8f b0 2d 00       	call   0x2db0a6
  17:	e8 5a 7a ec 08       	call   0x8ec7a76
  1c:	4d 85 e4             	test   %r12,%r12
  1f:	74 ea                	je     0xb
  21:	e8 80 b0 2d 00       	call   0x2db0a6
  26:	fb                   	sti
  27:	45 84 ed             	test   %r13b,%r13b
* 2a:	0f 94 c0             	sete   %al <-- trapping instruction
  2d:	48 c7 44 24 20 0e 36 	movq   $0x45e0360e,0x20(%rsp)
  34:	e0 45
  36:	48 b9 00 00 00 00 00 	movabs $0xdffffc0000000000,%rcx
  3d:	fc ff df

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/02/10 01:40 linux-5.15.y c16c81c81336 ef44b750 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in snd_rawmidi_transmit
* Struck through repros no longer work on HEAD.