syzbot


KASAN: use-after-free Read in snd_pcm_oss_get_formats

Status: fixed on 2018/03/23 18:14
Subsystems: sound
[Documentation on labels]
Reported-by: syzbot+4090700a4f13fccaf648@syzkaller.appspotmail.com
Fix commit: 01c0b4265cc1 ALSA: pcm: Fix UAF in snd_pcm_oss_get_formats()
First crash: 2409d, last: 2409d
Discussions (6)
Title Replies (including bot) Last reply
[PATCH 4.4 000/134] 4.4.123-stable review 177 (177) 2018/04/06 07:07
[PATCH 3.18 00/68] 3.18.101-stable review 81 (81) 2018/03/22 16:39
[PATCH 4.9 000/241] 4.9.89-stable review 259 (259) 2018/03/22 08:18
[PATCH 4.15 00/52] 4.15.12-stable review 62 (62) 2018/03/21 12:29
[PATCH 4.14 00/41] 4.14.29-stable review 48 (48) 2018/03/21 11:08
KASAN: use-after-free Read in snd_pcm_oss_get_formats 1 (2) 2018/03/10 22:10

Sample crash report:
IPVS: ftp: loaded support on port[0] = 21
audit: type=1400 audit(1520612143.836:8): avc:  denied  { map } for  pid=4259 comm="syzkaller191035" path="/dev/dsp1" dev="devtmpfs" ino=1250 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=system_u:object_r:sound_device_t:s0 tclass=chr_file permissive=1
IPVS: ftp: loaded support on port[0] = 21
IPVS: ftp: loaded support on port[0] = 21
==================================================================
BUG: KASAN: use-after-free in snd_mask_test include/sound/pcm_params.h:141 [inline]
BUG: KASAN: use-after-free in snd_pcm_oss_get_formats+0x320/0x380 sound/core/oss/pcm_oss.c:1770
Read of size 4 at addr ffff8801bace4024 by task syzkaller191035/4271

CPU: 0 PID: 4271 Comm: syzkaller191035 Not tainted 4.16.0-rc4+ #346
IPVS: ftp: loaded support on port[0] = 21
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+0x194/0x24d lib/dump_stack.c:53
IPVS: ftp: loaded support on port[0] = 21
 print_address_description+0x73/0x250 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report+0x23c/0x360 mm/kasan/report.c:412
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
 snd_mask_test include/sound/pcm_params.h:141 [inline]
 snd_pcm_oss_get_formats+0x320/0x380 sound/core/oss/pcm_oss.c:1770
 snd_pcm_oss_set_format sound/core/oss/pcm_oss.c:1784 [inline]
 snd_pcm_oss_ioctl+0x1e2f/0x39f0 sound/core/oss/pcm_oss.c:2515
IPVS: ftp: loaded support on port[0] = 21
IPVS: ftp: loaded support on port[0] = 21
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x4499e9
RSP: 002b:00007fa1872a5da8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000006dbc24 RCX: 00000000004499e9
RDX: 0000000020000080 RSI: 00800000c0045005 RDI: 0000000000000003
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dbc20
R13: 7073642f7665642f R14: 00800000c0045005 R15: 0000000000000003

Allocated by task 4271:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:552
 kmem_cache_alloc_trace+0x136/0x740 mm/slab.c:3607
 kmalloc include/linux/slab.h:512 [inline]
 snd_pcm_oss_get_formats+0x1c7/0x380 sound/core/oss/pcm_oss.c:1760
 snd_pcm_oss_set_format sound/core/oss/pcm_oss.c:1784 [inline]
 snd_pcm_oss_ioctl+0x1e2f/0x39f0 sound/core/oss/pcm_oss.c:2515
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 4271:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:520
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:527
 __cache_free mm/slab.c:3485 [inline]
 kfree+0xd9/0x260 mm/slab.c:3800
 snd_pcm_oss_get_formats+0x216/0x380 sound/core/oss/pcm_oss.c:1766
 snd_pcm_oss_set_format sound/core/oss/pcm_oss.c:1784 [inline]
 snd_pcm_oss_ioctl+0x1e2f/0x39f0 sound/core/oss/pcm_oss.c:2515
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8801bace4000
 which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 36 bytes inside of
 1024-byte region [ffff8801bace4000, ffff8801bace4400)
The buggy address belongs to the page:
page:ffffea0006eb3900 count:1 mapcount:0 mapping:ffff8801bace4000 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffff8801bace4000 0000000000000000 0000000100000007
raw: ffffea000761d7a0 ffffea0006eb39a0 ffff8801dac00ac0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801bace3f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8801bace3f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8801bace4000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff8801bace4080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801bace4100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/03/09 16:17 upstream 1b88accf6a65 36d1c454 .config console log report syz C ci-upstream-kasan-gce
2018/03/09 16:45 upstream 1b88accf6a65 36d1c454 .config console log report syz ci-upstream-kasan-gce-386
2018/03/09 16:03 upstream 1b88accf6a65 36d1c454 .config console log report ci-upstream-kasan-gce
* Struck through repros no longer work on HEAD.