syzbot


KASAN: use-after-free Read in snd_seq_ioctl_get_subscription

Status: fixed on 2019/06/14 18:22
Subsystems: sound
[Documentation on labels]
Reported-by: syzbot+9437020c82413d00222d@syzkaller.appspotmail.com
Fix commit: 2eabc5ec8ab4 ALSA: seq: Fix race of get-subscription call vs port-delete ioctls
First crash: 2037d, last: 2002d
Discussions (9)
Title Replies (including bot) Last reply
[PATCH 4.9 000/117] 4.9.183-stable review 121 (121) 2019/06/22 00:44
[PATCH 4.19 00/75] 4.19.53-stable review 83 (83) 2019/06/20 01:46
[PATCH 4.14 00/53] 4.14.128-stable review 62 (62) 2019/06/19 13:40
[PATCH 5.1 000/115] 5.1.12-stable review 132 (132) 2019/06/19 12:16
[PATCH AUTOSEL 5.1 01/60] x86/uaccess, kcov: Disable stack protector 42 (42) 2019/06/15 22:26
[PATCH AUTOSEL 4.9 01/17] x86/uaccess, kcov: Disable stack protector 17 (17) 2019/06/04 23:24
[PATCH AUTOSEL 4.14 01/24] x86/uaccess, kcov: Disable stack protector 24 (24) 2019/06/04 23:24
[PATCH AUTOSEL 4.19 01/36] x86/uaccess, kcov: Disable stack protector 26 (26) 2019/06/04 23:23
KASAN: use-after-free Read in snd_seq_ioctl_get_subscription 0 (1) 2018/10/01 07:28

Sample crash report:
RSP: 002b:00000000f5f030cc EFLAGS: 00000296 ORIG_RAX: 00000000000000bb
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 0000000000000005
==================================================================
RDX: 0000000000000000 RSI: 0000000000000007 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
BUG: KASAN: use-after-free in snd_seq_ioctl_get_subscription+0x241/0x250 sound/core/seq/seq_clientmgr.c:1913
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
Read of size 80 at addr ffff8801d89bd180 by task syz-executor4/31957
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

CPU: 0 PID: 31957 Comm: syz-executor4 Not tainted 4.19.0+ #218
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+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load_n_noabort+0xf/0x20 mm/kasan/report.c:443
 snd_seq_ioctl_get_subscription+0x241/0x250 sound/core/seq/seq_clientmgr.c:1913
 snd_seq_ioctl+0x253/0x440 sound/core/seq/seq_clientmgr.c:2138
 snd_seq_ioctl_compat+0x16c/0x2d0 sound/core/seq/seq_compat.c:123
 __do_compat_sys_ioctl fs/compat_ioctl.c:1052 [inline]
 __se_compat_sys_ioctl fs/compat_ioctl.c:998 [inline]
 __ia32_compat_sys_ioctl+0x20e/0x630 fs/compat_ioctl.c:998
 do_syscall_32_irqs_on arch/x86/entry/common.c:326 [inline]
 do_fast_syscall_32+0x34d/0xfb2 arch/x86/entry/common.c:397
cgroup: fork rejected by pids controller in /syz2
 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139
RIP: 0023:0xf7f70a29
Code: 85 d2 74 02 89 0a 5b 5d c3 8b 04 24 c3 8b 14 24 c3 8b 3c 24 c3 90 90 90 90 90 90 90 90 90 90 90 90 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 eb 0d 90 90 90 90 90 90 90 90 90 90 90 90
RSP: 002b:00000000f5f4b0cc EFLAGS: 00000296 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00000000c0505350
RDX: 0000000020000140 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 31953:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620
 kmalloc include/linux/slab.h:546 [inline]
 kzalloc include/linux/slab.h:741 [inline]
 snd_seq_port_connect+0xe0/0x760 sound/core/seq/seq_ports.c:571
 snd_seq_ioctl_subscribe_port+0x1e1/0x320 sound/core/seq/seq_clientmgr.c:1458
 snd_seq_ioctl+0x253/0x440 sound/core/seq/seq_clientmgr.c:2138
 snd_seq_ioctl_compat+0x16c/0x2d0 sound/core/seq/seq_compat.c:123
 __do_compat_sys_ioctl fs/compat_ioctl.c:1052 [inline]
 __se_compat_sys_ioctl fs/compat_ioctl.c:998 [inline]
 __ia32_compat_sys_ioctl+0x20e/0x630 fs/compat_ioctl.c:998
CPU: 1 PID: 31950 Comm: syz-executor1 Not tainted 4.19.0+ #218
 do_syscall_32_irqs_on arch/x86/entry/common.c:326 [inline]
 do_fast_syscall_32+0x34d/0xfb2 arch/x86/entry/common.c:397
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139
Call Trace:

 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
Freed by task 31946:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3817
 fail_dump lib/fault-inject.c:51 [inline]
 should_fail.cold.4+0xa/0x17 lib/fault-inject.c:149
 clear_subscriber_list+0x1ba/0x390 sound/core/seq/seq_ports.c:254
 port_delete+0x7c/0x1b0 sound/core/seq/seq_ports.c:270
 snd_seq_delete_all_ports+0x5fb/0x940 sound/core/seq/seq_ports.c:333
 seq_free_client1.part.9+0xcb/0x270 sound/core/seq/seq_clientmgr.c:262
 seq_free_client1 sound/core/seq/seq_clientmgr.c:256 [inline]
 seq_free_client+0x82/0x100 sound/core/seq/seq_clientmgr.c:285
 snd_seq_release+0x51/0xe0 sound/core/seq/seq_clientmgr.c:366
 __fput+0x385/0xa30 fs/file_table.c:278
 ____fput+0x15/0x20 fs/file_table.c:309
 task_work_run+0x1e8/0x2a0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop+0x318/0x380 arch/x86/entry/common.c:166
 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
 do_syscall_32_irqs_on arch/x86/entry/common.c:341 [inline]
 do_fast_syscall_32+0xcd5/0xfb2 arch/x86/entry/common.c:397
 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139

The buggy address belongs to the object at ffff8801d89bd180
 which belongs to the cache kmalloc-128 of size 128
The buggy address is located 0 bytes inside of
 128-byte region [ffff8801d89bd180, ffff8801d89bd200)
The buggy address belongs to the page:
page:ffffea0007626f40 count:1 mapcount:0 mapping:ffff8801da800640 index:0xffff8801d89bd600
flags: 0x2fffc0000000200(slab)
raw: 02fffc0000000200 ffffea0006e19508 ffffea0006ee86c8 ffff8801da800640
 __should_failslab+0x124/0x180 mm/failslab.c:32
raw: ffff8801d89bd600 ffff8801d89bd000 0000000100000014 0000000000000000
 should_failslab+0x9/0x14 mm/slab_common.c:1578
page dumped because: kasan: bad access detected
 slab_pre_alloc_hook mm/slab.h:423 [inline]
 slab_alloc mm/slab.c:3378 [inline]
 kmem_cache_alloc+0x2be/0x730 mm/slab.c:3552

 anon_vma_alloc mm/rmap.c:82 [inline]
 __anon_vma_prepare+0x3b3/0x6c0 mm/rmap.c:190
Memory state around the buggy address:
 ffff8801d89bd080: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8801d89bd100: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 anon_vma_prepare include/linux/rmap.h:153 [inline]
 do_huge_pmd_anonymous_page+0x15b7/0x2040 mm/huge_memory.c:675
>ffff8801d89bd180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8801d89bd200: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8801d89bd280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================
 create_huge_pmd mm/memory.c:3656 [inline]
 __handle_mm_fault+0x3c97/0x5be0 mm/memory.c:3860
 handle_mm_fault+0x54f/0xc70 mm/memory.c:3926
 do_user_addr_fault arch/x86/mm/fault.c:1423 [inline]
 __do_page_fault+0x5e8/0xe60 arch/x86/mm/fault.c:1489
 do_page_fault+0xf2/0x7e0 arch/x86/mm/fault.c:1520
 page_fault+0x1e/0x30 arch/x86/entry/entry_64.S:1139
RIP: 0010:__put_user_4+0x1c/0x30 arch/x86/lib/putuser.S:68
Code: 1f 00 c3 90 66 2e 0f 1f 84 00 00 00 00 00 65 48 8b 1c 25 40 ee 01 00 48 8b 9b 18 14 00 00 48 83 eb 03 48 39 d9 73 3c 0f 1f 00 <89> 01 31 c0 0f 1f 00 c3 66 90 66 2e 0f 1f 84 00 00 00 00 00 65 48
RSP: 0018:ffff88018db9fca8 EFLAGS: 00010293
RAX: 0000000000000004 RBX: 00007fffffffeffd RCX: 0000000020000280
RDX: 000000000000005b RSI: ffffffff81b17e03 RDI: 0000000000000286
RBP: ffff88018db9fda0 R08: 1ffff10031b73f72 R09: 0000000000000008
R10: 0000000000000001 R11: ffff8801ce4dc680 R12: 0000000000000004
R13: 0000000020000280 R14: 0000000000000002 R15: dffffc0000000000
 __do_sys_socketpair net/socket.c:1458 [inline]
 __se_sys_socketpair net/socket.c:1455 [inline]
 __ia32_sys_socketpair+0x96/0xf0 net/socket.c:1455
 do_syscall_32_irqs_on arch/x86/entry/common.c:326 [inline]
 do_fast_syscall_32+0x34d/0xfb2 arch/x86/entry/common.c:397
 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139
RIP: 0023:0xf7f18a29
Code: 85 d2 74 02 89 0a 5b 5d c3 8b 04 24 c3 8b 14 24 c3 8b 3c 24 c3 90 90 90 90 90 90 90 90 90 90 90 90 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 eb 0d 90 90 90 90 90 90 90 90 90 90 90 90
RSP: 002b:00000000f5f140cc EFLAGS: 00000296 ORIG_RAX: 0000000000000168
RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 0000000000000002
RDX: 0000000000000001 RSI: 0000000020000280 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/11/02 13:08 upstream e468f5c06b5e 1f38e9ae .config console log report ci-upstream-kasan-gce-386
2018/09/29 10:41 upstream e704966c45e4 41e4b329 .config console log report ci-upstream-kasan-gce-386
* Struck through repros no longer work on HEAD.