syzbot


KASAN: use-after-free Write in check_and_subscribe_port

Status: fixed on 2019/06/24 23:41
Subsystems: sound
[Documentation on labels]
Reported-by: syzbot+20ab495fadf081e8a2b0@syzkaller.appspotmail.com
Fix commit: 7c32ae35fbf9 ALSA: seq: Cover unsubscribe_port() in list_mutex
First crash: 1676d, last: 1676d
Discussions (2)
Title Replies (including bot) Last reply
Reminder: 9 open syzbot bugs in sound subsystem 1 (1) 2019/06/24 05:07
KASAN: use-after-free Write in check_and_subscribe_port 0 (1) 2019/05/07 09:42

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __list_add include/linux/list.h:64 [inline]
BUG: KASAN: use-after-free in list_add_tail include/linux/list.h:93 [inline]
BUG: KASAN: use-after-free in check_and_subscribe_port+0x7bd/0x860 sound/core/seq/seq_ports.c:524
Write of size 8 at addr ffff88809587bba0 by task syz-executor.2/19168

CPU: 0 PID: 19168 Comm: syz-executor.2 Not tainted 5.1.0-rc7+ #95
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
 kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 __asan_report_store8_noabort+0x17/0x20 mm/kasan/generic_report.c:137
 __list_add include/linux/list.h:64 [inline]
 list_add_tail include/linux/list.h:93 [inline]
 check_and_subscribe_port+0x7bd/0x860 sound/core/seq/seq_ports.c:524
 snd_seq_port_connect+0x388/0x510 sound/core/seq/seq_ports.c:587
 snd_seq_ioctl_subscribe_port+0x1e5/0x310 sound/core/seq/seq_clientmgr.c:1458
 snd_seq_ioctl+0x224/0x3e0 sound/core/seq/seq_clientmgr.c:2138
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:509 [inline]
 do_vfs_ioctl+0xd6e/0x1390 fs/ioctl.c:696
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
 __do_sys_ioctl fs/ioctl.c:720 [inline]
 __se_sys_ioctl fs/ioctl.c:718 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x458da9
Code: ad b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 7b b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f6a5c605c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000458da9
RDX: 0000000020000000 RSI: 0000000040505330 RDI: 0000000000000003
RBP: 000000000073bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f6a5c6066d4
R13: 00000000004cc598 R14: 00000000004d5ee8 R15: 00000000ffffffff

Allocated by task 19168:
 save_stack+0x45/0xd0 mm/kasan/common.c:75
 set_track mm/kasan/common.c:87 [inline]
 __kasan_kmalloc mm/kasan/common.c:497 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:470
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:511
 kmem_cache_alloc_trace+0x151/0x760 mm/slab.c:3622
 kmalloc include/linux/slab.h:547 [inline]
 kzalloc include/linux/slab.h:742 [inline]
 snd_seq_port_connect+0x60/0x510 sound/core/seq/seq_ports.c:571
 snd_seq_ioctl_subscribe_port+0x1e5/0x310 sound/core/seq/seq_clientmgr.c:1458
 snd_seq_ioctl+0x224/0x3e0 sound/core/seq/seq_clientmgr.c:2138
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:509 [inline]
 do_vfs_ioctl+0xd6e/0x1390 fs/ioctl.c:696
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
 __do_sys_ioctl fs/ioctl.c:720 [inline]
 __se_sys_ioctl fs/ioctl.c:718 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 19167:
 save_stack+0x45/0xd0 mm/kasan/common.c:75
 set_track mm/kasan/common.c:87 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:459
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:467
 __cache_free mm/slab.c:3499 [inline]
 kfree+0xcf/0x230 mm/slab.c:3822
 snd_seq_port_disconnect+0x209/0x280 sound/core/seq/seq_ports.c:632
 snd_seq_ioctl_unsubscribe_port+0x1e5/0x310 sound/core/seq/seq_clientmgr.c:1499
 snd_seq_ioctl+0x224/0x3e0 sound/core/seq/seq_clientmgr.c:2138
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:509 [inline]
 do_vfs_ioctl+0xd6e/0x1390 fs/ioctl.c:696
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
 __do_sys_ioctl fs/ioctl.c:720 [inline]
 __se_sys_ioctl fs/ioctl.c:718 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809587bb40
 which belongs to the cache kmalloc-128 of size 128
The buggy address is located 96 bytes inside of
 128-byte region [ffff88809587bb40, ffff88809587bbc0)
The buggy address belongs to the page:
page:ffffea0002561ec0 count:1 mapcount:0 mapping:ffff8880aa400640 index:0xffff88809587bd80
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea0002949788 ffffea0002906888 ffff8880aa400640
raw: ffff88809587bd80 ffff88809587b000 000000010000000f 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809587ba80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809587bb00: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff88809587bb80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                               ^
 ffff88809587bc00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809587bc80: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/04/30 22:37 upstream bf3bd966dfd7 618456b4 .config console log report ci-upstream-kasan-gce
* Struck through repros no longer work on HEAD.