KASAN: slab-out-of-bounds Write in snd_rawmidi_kernel_write1

Status: fixed on 2020/06/13 23:18
Fix commit: 8645ac3684a7 ALSA: rawmidi: Fix racy buffer resize under concurrent accesses
First crash: 1028d, last: 998d

Fix bisection: fixed by (bisect log) :
commit 8645ac3684a70e4e8a21c7c407c07a1a4316beec
Author: Takashi Iwai <>
Date: Thu May 7 11:44:56 2020 +0000

  ALSA: rawmidi: Fix racy buffer resize under concurrent accesses

Sample crash report:
BUG: KASAN: slab-out-of-bounds in _copy_from_user+0xaf/0x100 lib/usercopy.c:12
Write of size 4096 at addr ffff888093062ec0 by task syz-executor760/7129

CPU: 1 PID: 7129 Comm: syz-executor760 Not tainted 4.14.176-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+0x13e/0x194 lib/dump_stack.c:58
 print_address_description.cold+0x7c/0x1e2 mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report mm/kasan/report.c:409 [inline]
 kasan_report.cold+0xa9/0x2ae mm/kasan/report.c:393
 _copy_from_user+0xaf/0x100 lib/usercopy.c:12
 copy_from_user include/linux/uaccess.h:147 [inline]
 snd_rawmidi_kernel_write1+0x2e3/0x680 sound/core/rawmidi.c:1283
 snd_rawmidi_write+0x275/0x970 sound/core/rawmidi.c:1348
 __vfs_write+0xe4/0x630 fs/read_write.c:480
 vfs_write+0x192/0x4e0 fs/read_write.c:544
 SYSC_write fs/read_write.c:590 [inline]
 SyS_write+0xf2/0x210 fs/read_write.c:582
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
RIP: 0033:0x44af19
RSP: 002b:00007f47c691fdb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00000000006dcc28 RCX: 000000000044af19
RDX: 0000000020000339 RSI: 00000000200001c0 RDI: 0000000000000003
RBP: 00000000006dcc20 R08: 0000000000000000 R09: 0000000000000000
R10: 00007f47c6920700 R11: 0000000000000246 R12: 00000000006dcc2c
R13: 00007ffdafa2281f R14: 00007f47c69209c0 R15: 20c49ba5e353f7cf

Allocated by task 7131:
 save_stack+0x32/0xa0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc mm/kasan/kasan.c:551 [inline]
 kasan_kmalloc+0xbf/0xe0 mm/kasan/kasan.c:529
 __do_kmalloc mm/slab.c:3720 [inline]
 __kmalloc+0x15b/0x7c0 mm/slab.c:3729
 kmalloc include/linux/slab.h:493 [inline]
 snd_rawmidi_output_params+0x176/0x440 sound/core/rawmidi.c:653
 snd_rawmidi_ioctl+0x51c/0x620 sound/core/rawmidi.c:764
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xfe0 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

Freed by task 0:
(stack is not available)

The buggy address belongs to the object at ffff888093062ec0
 which belongs to the cache kmalloc-4096 of size 4096
The buggy address is located 0 bytes inside of
 4096-byte region [ffff888093062ec0, ffff888093063ec0)
The buggy address belongs to the page:
page:ffffea00024c1880 count:1 mapcount:0 mapping:ffff888093062ec0 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffff888093062ec0 0000000000000000 0000000100000001
raw: ffffea000250f2a0 ffff88812fe54a48 ffff88812fe56dc0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888093063580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888093063600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888093063680: 00 00 00 00 00 00 00 00 00 00 00 00 02 fc fc fc
 ffff888093063700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888093063780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc

Crashes (1):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci2-linux-4-14 2020/04/14 15:05 linux-4.14.y c10b57a567e4 3f3c5574 .config console log report syz C
* Struck through repros no longer work on HEAD.