KASAN: use-after-free Read in snd_pcm_oss_get_formats

25 views
Skip to first unread message

syzbot

unread,
Mar 9, 2018, 3:59:05 PM3/9/18
to alsa-...@alsa-project.org, linux-...@vger.kernel.org, mi...@kernel.org, o-ta...@sakamocchi.jp, pe...@perex.cz, syzkall...@googlegroups.com, ti...@suse.com, vi...@zeniv.linux.org.uk
Hello,

syzbot hit the following crash on upstream commit
1b88accf6a659c46d5c8e68912896f112bf882bb (Thu Mar 8 01:49:33 2018 +0000)
Merge tag 'for_linus' of
git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

So far this crash happened 3 times on upstream.
C reproducer is attached.
syzkaller reproducer is attached.
Raw console output is attached.
compiler: gcc (GCC) 7.1.1 20170620
.config is attached.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+409070...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed. See footer for
details.
If you forward the report, please keep this part and the footer.

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
==================================================================


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzk...@googlegroups.com.

syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is
merged
into any tree, please reply to this email with:
#syz fix: exact-commit-title
If you want to test a patch for this bug, please reply with:
#syz test: git://repo/address.git branch
and provide the patch inline or as an attachment.
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug
report.
Note: all commands must start from beginning of the line in the email body.
raw.log.txt
repro.syz.txt
repro.c.txt
config.txt

Takashi Iwai

unread,
Mar 11, 2018, 5:45:46 PM3/11/18
to syzbot, alsa-...@alsa-project.org, syzkall...@googlegroups.com, mi...@kernel.org, pe...@perex.cz, o-ta...@sakamocchi.jp, linux-...@vger.kernel.org, vi...@zeniv.linux.org.uk
Doh, this is a so-clear UAF, shining brightly in the code.
Will submit / merge the fix patch.


thanks,

Takashi
Reply all
Reply to author
Forward
0 new messages