KASAN: use-after-free Write in snd_rawmidi_kernel_write1

Status: auto-closed as invalid on 2020/08/12 12:40
First crash: 1410d, last: 1410d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Write in snd_rawmidi_kernel_write1 C done 1 1379d 1409d 1/1 fixed on 2020/06/15 08:02
upstream KASAN: use-after-free Write in snd_rawmidi_kernel_write1 sound 1 628d 626d 0/26 auto-obsoleted due to no activity on 2022/10/03 20:00

Sample crash report:
BUG: KASAN: use-after-free in _copy_from_user+0xaf/0x100 lib/usercopy.c:12
Write of size 4096 at addr ffff88808809ae00 by task syz-executor.3/29636

CPU: 1 PID: 29636 Comm: syz-executor.3 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:0x45c889
RSP: 002b:00007fa98a058c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fa98a0596d4 RCX: 000000000045c889
RDX: 0000000020000339 RSI: 00000000200001c0 RDI: 0000000000000003
RBP: 000000000076bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 0000000000000c4e R14: 00000000004ca0d5 R15: 000000000076bf0c

Allocated by task 29636:
 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
 kmem_cache_alloc_trace+0x14d/0x7b0 mm/slab.c:3618
 kmalloc include/linux/slab.h:488 [inline]
 snd_rawmidi_runtime_create sound/core/rawmidi.c:128 [inline]
 open_substream+0x324/0x7d0 sound/core/rawmidi.c:267
 rawmidi_open_priv+0x44b/0x580 sound/core/rawmidi.c:318
 snd_rawmidi_open+0x3b9/0x9b1 sound/core/rawmidi.c:417
 snd_open+0x1f7/0x3b0 sound/core/sound.c:175
 chrdev_open+0x1fc/0x540 fs/char_dev.c:423
 do_dentry_open+0x732/0xe90 fs/open.c:777
 vfs_open+0x105/0x220 fs/open.c:888
 do_last fs/namei.c:3428 [inline]
 path_openat+0x8ca/0x3c50 fs/namei.c:3569
 do_filp_open+0x18e/0x250 fs/namei.c:3603
 do_sys_open+0x29d/0x3f0 fs/open.c:1081
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292

Freed by task 29641:
 save_stack+0x32/0xa0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xcb/0x260 mm/slab.c:3815
 snd_rawmidi_output_params+0x286/0x440 sound/core/rawmidi.c:663
 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

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

Memory state around the buggy address:
 ffff88808809ad00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88808809ad80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88808809ae00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808809ae80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808809af00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ebt_among: dst integrity fail: 155

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