syzbot


KASAN: slab-out-of-bounds Read in kvm_clear_dirty_log_protect

Status: fixed on 2019/03/06 07:43
Subsystems: kvm
[Documentation on labels]
Reported-by: syzbot+028366e52c9ace67deb3@syzkaller.appspotmail.com
Fix commit: 98938aa8edd6 KVM: validate userspace input in kvm_clear_dirty_log_protect()
First crash: 2030d, last: 2018d
Discussions (2)
Title Replies (including bot) Last reply
[PATCH] KVM: validate userspace input in kvm_clear_dirty_log_protect() 5 (5) 2019/01/14 09:10
KASAN: slab-out-of-bounds Read in kvm_clear_dirty_log_protect 0 (1) 2019/01/02 11:11

Sample crash report:
IPVS: ftp: loaded support on port[0] = 21
L1TF CPU bug present and SMT on, data leak possible. See CVE-2018-3646 and https://www.kernel.org/doc/html/latest/admin-guide/l1tf.html for details.
==================================================================
BUG: KASAN: slab-out-of-bounds in kvm_clear_dirty_log_protect+0x8cf/0x970 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1262
Read of size 8 at addr ffff8880a13e5810 by task syz-executor650/7975

CPU: 0 PID: 7975 Comm: syz-executor650 Not tainted 4.20.0+ #3
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+0x1db/0x2d0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
 kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
 kvm_clear_dirty_log_protect+0x8cf/0x970 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1262
 kvm_vm_ioctl_clear_dirty_log+0xff/0x260 arch/x86/kvm/x86.c:4468
 kvm_vm_ioctl+0xc19/0x1fe0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3127
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:509 [inline]
 do_vfs_ioctl+0x107b/0x17d0 fs/ioctl.c:696
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
 __do_sys_ioctl fs/ioctl.c:720 [inline]
 __se_sys_ioctl fs/ioctl.c:718 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
 do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440b09
Code: 23 02 00 85 c0 b8 00 00 00 00 48 0f 44 c3 5b c3 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 0b 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00000000007dff68 EFLAGS: 00000217 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000004a28d8 RCX: 0000000000440b09
RDX: 0000000020000080 RSI: 00000000c018aec0 RDI: 0000000000000004
RBP: 00000000004a28d8 R08: 0000000120080522 R09: 0000000120080522
R10: 0000000120080522 R11: 0000000000000217 R12: 00000000004022a0
R13: 0000000000402330 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7975:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 kasan_kmalloc mm/kasan/common.c:482 [inline]
 kasan_kmalloc+0xcf/0xe0 mm/kasan/common.c:455
 __do_kmalloc_node mm/slab.c:3671 [inline]
 __kmalloc_node+0x4e/0x70 mm/slab.c:3678
 kmalloc_node include/linux/slab.h:588 [inline]
 kvmalloc_node+0x68/0x100 mm/util.c:416
 kvmalloc include/linux/mm.h:602 [inline]
 kvzalloc include/linux/mm.h:610 [inline]
 kvm_create_dirty_bitmap arch/x86/kvm/../../../virt/kvm/kvm_main.c:792 [inline]
 __kvm_set_memory_region+0x1da1/0x2c40 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1018
 kvm_set_memory_region+0x2f/0x60 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1084
 kvm_vm_ioctl_set_memory_region arch/x86/kvm/../../../virt/kvm/kvm_main.c:1096 [inline]
 kvm_vm_ioctl+0xafa/0x1fe0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3108
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:509 [inline]
 do_vfs_ioctl+0x107b/0x17d0 fs/ioctl.c:696
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
 __do_sys_ioctl fs/ioctl.c:720 [inline]
 __se_sys_ioctl fs/ioctl.c:718 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
 do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 4309:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:444
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:452
 __cache_free mm/slab.c:3485 [inline]
 kfree+0xcf/0x230 mm/slab.c:3804
 single_release+0x95/0xc0 fs/seq_file.c:597
 __fput+0x3c5/0xb10 fs/file_table.c:278
 ____fput+0x16/0x20 fs/file_table.c:309
 task_work_run+0x1f4/0x2b0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop+0x32a/0x3b0 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_64+0x696/0x800 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880a13e5800
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 16 bytes inside of
 32-byte region [ffff8880a13e5800, ffff8880a13e5820)
The buggy address belongs to the page:
page:ffffea000284f940 count:1 mapcount:0 mapping:ffff88812c3f01c0 index:0xffff8880a13e5fc1
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea00027e3c48 ffff88812c3f1238 ffff88812c3f01c0
raw: ffff8880a13e5fc1 ffff8880a13e5000 0000000100000033 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a13e5700: 00 00 fc fc fc fc fc fc 00 00 fc fc fc fc fc fc
 ffff8880a13e5780: 00 00 fc fc fc fc fc fc fb fb fb fb fc fc fc fc
>ffff8880a13e5800: 00 00 fc fc fc fc fc fc fb fb fb fb fc fc fc fc
                         ^
 ffff8880a13e5880: 00 00 fc fc fc fc fc fc 00 00 fc fc fc fc fc fc
 ffff8880a13e5900: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
==================================================================

Crashes (54):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/01/01 13:37 upstream e1ef035d272e 3d85f48c .config console log report syz C ci-upstream-kasan-gce
2019/01/01 11:01 upstream f12e840c819b 3d85f48c .config console log report syz C ci-upstream-kasan-gce
2019/01/01 14:14 upstream e1ef035d272e 3d85f48c .config console log report syz ci-upstream-kasan-gce-selinux-root
2019/01/01 14:01 upstream e1ef035d272e 3d85f48c .config console log report syz ci-upstream-kasan-gce-smack-root
2019/01/01 13:58 upstream e1ef035d272e 3d85f48c .config console log report syz ci-upstream-kasan-gce-selinux-root
2019/01/01 13:46 upstream e1ef035d272e 3d85f48c .config console log report syz ci-upstream-kasan-gce-smack-root
2019/01/01 10:59 upstream f12e840c819b 3d85f48c .config console log report syz ci-upstream-kasan-gce-root
2019/01/01 12:22 linux-next 6a1d293238c1 3d85f48c .config console log report syz ci-upstream-linux-next-kasan-gce-root
2019/01/01 12:07 linux-next 6a1d293238c1 3d85f48c .config console log report syz ci-upstream-linux-next-kasan-gce-root
2019/01/12 12:56 upstream 4b3c31c8d4dd c3f3344c .config console log report ci-upstream-kasan-gce-smack-root
2019/01/12 05:11 upstream de6629eb262e c3f3344c .config console log report ci-upstream-kasan-gce
2019/01/11 21:39 upstream de6629eb262e c3f3344c .config console log report ci-upstream-kasan-gce
2019/01/10 19:57 upstream ba422731316d db9b6579 .config console log report ci-upstream-kasan-gce-smack-root
2019/01/10 01:39 upstream 4064e47c8281 45c0c1b1 .config console log report ci-upstream-kasan-gce
2019/01/09 19:28 upstream a88cc8da0279 45c0c1b1 .config console log report ci-upstream-kasan-gce
2019/01/09 03:52 upstream 7b5585136713 010ed08b .config console log report ci-upstream-kasan-gce-root
2019/01/09 03:48 upstream 7b5585136713 010ed08b .config console log report ci-upstream-kasan-gce-selinux-root
2019/01/09 01:51 upstream 7b5585136713 010ed08b .config console log report ci-upstream-kasan-gce-selinux-root
2019/01/09 01:50 upstream 7b5585136713 010ed08b .config console log report ci-upstream-kasan-gce-root
2019/01/09 01:48 upstream 7b5585136713 010ed08b .config console log report ci-upstream-kasan-gce
2019/01/08 13:13 upstream 3bd6e94bec12 37dd2683 .config console log report ci-upstream-kasan-gce
2019/01/08 10:15 upstream 3bd6e94bec12 37dd2683 .config console log report ci-upstream-kasan-gce-root
2019/01/08 10:14 upstream 3bd6e94bec12 37dd2683 .config console log report ci-upstream-kasan-gce
2019/01/07 21:37 upstream 3bd6e94bec12 69d69aa9 .config console log report ci-upstream-kasan-gce
2019/01/07 09:19 upstream 574823bfab82 ee332608 .config console log report ci-upstream-kasan-gce-selinux-root
2019/01/07 09:19 upstream 574823bfab82 ee332608 .config console log report ci-upstream-kasan-gce
2019/01/07 09:17 upstream 574823bfab82 ee332608 .config console log report ci-upstream-kasan-gce-root
2019/01/06 19:09 upstream b5aef86e089a 94f8adb5 .config console log report ci-upstream-kasan-gce-smack-root
2019/01/06 09:14 upstream f1c2f8857c5a 53be0a37 .config console log report ci-upstream-kasan-gce
2019/01/05 08:58 upstream 3fed6ae4b027 53be0a37 .config console log report ci-upstream-kasan-gce
2019/01/05 08:42 upstream 3fed6ae4b027 53be0a37 .config console log report ci-upstream-kasan-gce-root
2019/01/05 08:41 upstream 3fed6ae4b027 53be0a37 .config console log report ci-upstream-kasan-gce-smack-root
2019/01/04 19:20 upstream 96d4f267e40f 0127e3ba .config console log report ci-upstream-kasan-gce
2019/01/03 19:35 upstream 645ff1e8e704 66fcd29b .config console log report ci-upstream-kasan-gce
2019/01/02 16:14 upstream 8e143b90e4d4 f0491811 .config console log report ci-upstream-kasan-gce
2019/01/02 05:52 upstream 28e8c4bc8eb4 3d85f48c .config console log report ci-upstream-kasan-gce-selinux-root
2019/01/02 05:49 upstream 28e8c4bc8eb4 3d85f48c .config console log report ci-upstream-kasan-gce-smack-root
2019/01/02 05:49 upstream 28e8c4bc8eb4 3d85f48c .config console log report ci-upstream-kasan-gce-root
2019/01/01 16:47 upstream e1ef035d272e 3d85f48c .config console log report ci-upstream-kasan-gce
2019/01/01 10:42 upstream f12e840c819b 3d85f48c .config console log report ci-upstream-kasan-gce
2019/01/01 10:41 upstream f12e840c819b 3d85f48c .config console log report ci-upstream-kasan-gce-root
2019/01/01 10:41 upstream f12e840c819b 3d85f48c .config console log report ci-upstream-kasan-gce-selinux-root
2019/01/12 02:21 upstream de6629eb262e c3f3344c .config console log report ci-upstream-kasan-gce-386
2019/01/13 17:53 linux-next b808822a75a3 c3f3344c .config console log report ci-upstream-linux-next-kasan-gce-root
2019/01/12 18:04 linux-next b808822a75a3 c3f3344c .config console log report ci-upstream-linux-next-kasan-gce-root
2019/01/12 10:20 linux-next b808822a75a3 c3f3344c .config console log report ci-upstream-linux-next-kasan-gce-root
2019/01/09 01:49 linux-next 139287cc2cc0 010ed08b .config console log report ci-upstream-linux-next-kasan-gce-root
2019/01/02 05:48 linux-next 6a1d293238c1 3d85f48c .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.