syzbot


KASAN: use-after-free Read in delete_and_unsubscribe_port

Status: fixed on 2020/09/01 18:34
Reported-by: syzbot+a433a888645ae4eb2f6c@syzkaller.appspotmail.com
Fix commit: ccafbed8b2f6 ALSA: seq: oss: Serialize ioctls
First crash: 921d, last: 921d

Fix bisection: fixed by (bisect log) :
commit ccafbed8b2f6a9d9298534b39e76da9cb40ff717
Author: Takashi Iwai <tiwai@suse.de>
Date: Tue Aug 4 18:58:15 2020 +0000

  ALSA: seq: oss: Serialize ioctls

similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in delete_and_unsubscribe_port 1 1504d 1500d 0/24 auto-closed as invalid on 2019/06/23 16:41
upstream KASAN: use-after-free Read in delete_and_unsubscribe_port (2) syz done 4 917d 942d 17/24 fixed on 2020/09/16 22:51

Sample crash report:
IPv6: ADDRCONF(NETDEV_CHANGE): batadv_slave_1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth1_to_batadv: link becomes ready
Bluetooth: hci0 command 0x0409 tx timeout
Bluetooth: hci0 command 0x041b tx timeout
==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:183 [inline]
BUG: KASAN: use-after-free in list_empty include/linux/list.h:203 [inline]
BUG: KASAN: use-after-free in delete_and_unsubscribe_port+0x3c7/0x4a0 sound/core/seq/seq_ports.c:548
Read of size 8 at addr ffff88809ba7bae0 by task syz-executor.0/7545

CPU: 0 PID: 7545 Comm: syz-executor.0 Not tainted 4.14.190-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x1b2/0x283 lib/dump_stack.c:58
 print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
 kasan_report_error.cold+0x8a/0x194 mm/kasan/report.c:351
 kasan_report mm/kasan/report.c:409 [inline]
 __asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:430
 __read_once_size include/linux/compiler.h:183 [inline]
 list_empty include/linux/list.h:203 [inline]
 delete_and_unsubscribe_port+0x3c7/0x4a0 sound/core/seq/seq_ports.c:548
 snd_seq_port_disconnect+0x3e9/0x500 sound/core/seq/seq_ports.c:630
 snd_seq_ioctl_unsubscribe_port+0x1d4/0x370 sound/core/seq/seq_clientmgr.c:1505
 snd_seq_kernel_client_ctl+0xcb/0x110 sound/core/seq/seq_clientmgr.c:2360
 snd_seq_oss_midi_close+0x29c/0x400 sound/core/seq/oss/seq_oss_midi.c:418
 snd_seq_oss_synth_reset+0x39d/0x830 sound/core/seq/oss/seq_oss_synth.c:419
 snd_seq_oss_reset+0x64/0x250 sound/core/seq/oss/seq_oss_init.c:448
 snd_seq_oss_ioctl+0x9a5/0xc30 sound/core/seq/oss/seq_oss_ioctl.c:106
 odev_ioctl+0x4f/0x90 sound/core/seq/oss/seq_oss.c:187
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x45cc79
RSP: 002b:00007f4936687c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000000154c0 RCX: 000000000045cc79
RDX: 0000000000000000 RSI: 0000000000005100 RDI: 0000000000000003
RBP: 000000000078c078 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000078c04c
R13: 00007ffe5e5e566f R14: 00007f49366889c0 R15: 000000000078c04c

Allocated by task 7543:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
 kmem_cache_alloc_trace+0x131/0x3d0 mm/slab.c:3618
 kmalloc include/linux/slab.h:488 [inline]
 kzalloc include/linux/slab.h:661 [inline]
 snd_seq_port_connect+0x5d/0x4d0 sound/core/seq/seq_ports.c:571
 snd_seq_ioctl_subscribe_port+0x1d4/0x370 sound/core/seq/seq_clientmgr.c:1464
 snd_seq_kernel_client_ctl+0xcb/0x110 sound/core/seq/seq_clientmgr.c:2360
 snd_seq_oss_midi_open+0x485/0x590 sound/core/seq/oss/seq_oss_midi.c:377
 snd_seq_oss_synth_setup_midi+0x104/0x4d0 sound/core/seq/oss/seq_oss_synth.c:282
 snd_seq_oss_open+0x7a0/0x920 sound/core/seq/oss/seq_oss_init.c:274
 odev_open+0x62/0x80 sound/core/seq/oss/seq_oss.c:138
 soundcore_open+0x3ee/0x5a0 sound/sound_core.c:640
 chrdev_open+0x23c/0x6d0 fs/char_dev.c:423
 do_dentry_open+0x44b/0xec0 fs/open.c:777
 vfs_open+0x105/0x220 fs/open.c:888
 do_last fs/namei.c:3428 [inline]
 path_openat+0x628/0x2970 fs/namei.c:3569
 do_filp_open+0x179/0x3c0 fs/namei.c:3603
 do_sys_open+0x296/0x410 fs/open.c:1081
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 7544:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xc9/0x250 mm/slab.c:3815
 snd_seq_port_disconnect+0x3f1/0x500 sound/core/seq/seq_ports.c:632
 snd_seq_ioctl_unsubscribe_port+0x1d4/0x370 sound/core/seq/seq_clientmgr.c:1505
 snd_seq_kernel_client_ctl+0xcb/0x110 sound/core/seq/seq_clientmgr.c:2360
 snd_seq_oss_midi_close+0x29c/0x400 sound/core/seq/oss/seq_oss_midi.c:418
 snd_seq_oss_synth_reset+0x39d/0x830 sound/core/seq/oss/seq_oss_synth.c:419
 snd_seq_oss_reset+0x64/0x250 sound/core/seq/oss/seq_oss_init.c:448
 snd_seq_oss_ioctl+0x9a5/0xc30 sound/core/seq/oss/seq_oss_ioctl.c:106
 odev_ioctl+0x4f/0x90 sound/core/seq/oss/seq_oss.c:187
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

The buggy address belongs to the object at ffff88809ba7ba80
 which belongs to the cache kmalloc-128 of size 128
The buggy address is located 96 bytes inside of
 128-byte region [ffff88809ba7ba80, ffff88809ba7bb00)
The buggy address belongs to the page:
page:ffffea00026e9ec0 count:1 mapcount:0 mapping:ffff88809ba7b000 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff88809ba7b000 0000000000000000 0000000100000015
raw: ffffea00026d52e0 ffff88812fe50548 ffff88812fe52640 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809ba7b980: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
 ffff88809ba7ba00: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
>ffff88809ba7ba80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff88809ba7bb00: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff88809ba7bb80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Crashes (2):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci2-linux-4-14 2020/07/30 12:41 linux-4.14.y e5a54aa2d312 b0947553 .config console log report syz
ci2-linux-4-14 2020/07/30 12:25 linux-4.14.y e5a54aa2d312 b0947553 .config console log report syz
* Struck through repros no longer work on HEAD.