KMSAN: kernel-infoleak in kvm_write_guest_page

20 views
Skip to first unread message

syzbot

unread,
Nov 7, 2018, 1:58:06 PM11/7/18
to k...@vger.kernel.org, linux-...@vger.kernel.org, pbon...@redhat.com, rkr...@redhat.com, syzkall...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 7438a3b20295 kmsan: print user address when reporting info..
git tree: https://github.com/google/kmsan.git/master
console output: https://syzkaller.appspot.com/x/log.txt?x=10d782f5400000
kernel config: https://syzkaller.appspot.com/x/.config?x=8df5fc509a1b351b
dashboard link: https://syzkaller.appspot.com/bug?extid=a8ef68d71211ba264f56
compiler: clang version 8.0.0 (trunk 343298)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15f09133400000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15a39e05400000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+a8ef68...@syzkaller.appspotmail.com

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: KMSAN: kernel-infoleak in __copy_to_user include/linux/uaccess.h:121
[inline]
BUG: KMSAN: kernel-infoleak in __kvm_write_guest_page
arch/x86/kvm/../../../virt/kvm/kvm_main.c:1849 [inline]
BUG: KMSAN: kernel-infoleak in kvm_write_guest_page+0x373/0x500
arch/x86/kvm/../../../virt/kvm/kvm_main.c:1861
CPU: 1 PID: 6274 Comm: syz-executor149 Not tainted 4.19.0+ #78
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+0x32d/0x480 lib/dump_stack.c:113
kmsan_report+0x19f/0x300 mm/kmsan/kmsan.c:911
kmsan_internal_check_memory+0x35f/0x450 mm/kmsan/kmsan.c:993
kmsan_copy_to_user+0x7c/0xe0 mm/kmsan/kmsan_hooks.c:552
__copy_to_user include/linux/uaccess.h:121 [inline]
__kvm_write_guest_page arch/x86/kvm/../../../virt/kvm/kvm_main.c:1849
[inline]
kvm_write_guest_page+0x373/0x500
arch/x86/kvm/../../../virt/kvm/kvm_main.c:1861
kvm_write_guest+0x1e1/0x360 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1883
kvm_pv_clock_pairing arch/x86/kvm/x86.c:6793 [inline]
kvm_emulate_hypercall+0x1c96/0x21b0 arch/x86/kvm/x86.c:6866
handle_vmcall+0x41/0x50 arch/x86/kvm/vmx.c:7487
vmx_handle_exit+0x1e81/0xbac0 arch/x86/kvm/vmx.c:10128
vcpu_enter_guest arch/x86/kvm/x86.c:7667 [inline]
vcpu_run arch/x86/kvm/x86.c:7730 [inline]
kvm_arch_vcpu_ioctl_run+0xac32/0x11d80 arch/x86/kvm/x86.c:7930
kvm_vcpu_ioctl+0xfb1/0x1f90 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2590
do_vfs_ioctl+0xf77/0x2d30 fs/ioctl.c:46
ksys_ioctl fs/ioctl.c:702 [inline]
__do_sys_ioctl fs/ioctl.c:709 [inline]
__se_sys_ioctl+0x1da/0x270 fs/ioctl.c:707
__x64_sys_ioctl+0x4a/0x70 fs/ioctl.c:707
do_syscall_64+0xcf/0x110 arch/x86/entry/common.c:291
entry_SYSCALL_64_after_hwframe+0x63/0xe7
RIP: 0033:0x442b39
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 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 1b 0c fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffcb4e05478 EFLAGS: 00000217 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000442b39
RDX: 0000000000000000 RSI: 000000000000ae80 RDI: 0000000000000007
RBP: 00000000006cd018 R08: 0000000020000100 R09: 0000000020000100
R10: 0000000000000000 R11: 0000000000000217 R12: 0000000000403be0
R13: 0000000000403c70 R14: 0000000000000000 R15: 0000000000000000

Local variable description: ----clock_pairing.i@kvm_emulate_hypercall
Variable was created at:
kvm_emulate_hypercall+0x60/0x21b0 arch/x86/kvm/x86.c:6827
handle_vmcall+0x41/0x50 arch/x86/kvm/vmx.c:7487

Bytes 28-63 of 64 are uninitialized
Memory access of size 64 starts at ffff8801aac5f3d8
Data copied to user address 0000000020000000
==================================================================


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with
syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

Liran Alon

unread,
Nov 7, 2018, 5:13:34 PM11/7/18
to syzbot, k...@vger.kernel.org, linux-...@vger.kernel.org, pbon...@redhat.com, rkr...@redhat.com, syzkall...@googlegroups.com


> On 7 Nov 2018, at 20:58, syzbot <syzbot+a8ef68...@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit: 7438a3b20295 kmsan: print user address when reporting info..
> git tree: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_google_kmsan.git_master&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=Jk6Q8nNzkQ6LJ6g42qARkg6ryIDGQr-yKXPNGZbpTx0&m=_zu2xJguqdkES0k8nx8UlglUdOiAHk72aWKl44bi2Sw&s=fcwxYfHP71V16E_WRx7hgde6KeNMFBzprI2k6PzzZEo&e=
> console output: https://urldefense.proofpoint.com/v2/url?u=https-3A__syzkaller.appspot.com_x_log.txt-3Fx-3D10d782f5400000&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=Jk6Q8nNzkQ6LJ6g42qARkg6ryIDGQr-yKXPNGZbpTx0&m=_zu2xJguqdkES0k8nx8UlglUdOiAHk72aWKl44bi2Sw&s=G8EVFBcgaTj-Rg8XsqlSgOVE7Hjg9gU5JEG7hA0ry1I&e=
> kernel config: https://urldefense.proofpoint.com/v2/url?u=https-3A__syzkaller.appspot.com_x_.config-3Fx-3D8df5fc509a1b351b&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=Jk6Q8nNzkQ6LJ6g42qARkg6ryIDGQr-yKXPNGZbpTx0&m=_zu2xJguqdkES0k8nx8UlglUdOiAHk72aWKl44bi2Sw&s=yxSBwzSyc6oRH7v1EJAKQMbq9VghK3Nme98FwYd8iJA&e=
> dashboard link: https://urldefense.proofpoint.com/v2/url?u=https-3A__syzkaller.appspot.com_bug-3Fextid-3Da8ef68d71211ba264f56&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=Jk6Q8nNzkQ6LJ6g42qARkg6ryIDGQr-yKXPNGZbpTx0&m=_zu2xJguqdkES0k8nx8UlglUdOiAHk72aWKl44bi2Sw&s=FqvBbzpE2srFcjavB0i99ekCvznCaHFOuWgIwYzmrXs&e=
> compiler: clang version 8.0.0 (trunk 343298)
> syz repro: https://urldefense.proofpoint.com/v2/url?u=https-3A__syzkaller.appspot.com_x_repro.syz-3Fx-3D15f09133400000&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=Jk6Q8nNzkQ6LJ6g42qARkg6ryIDGQr-yKXPNGZbpTx0&m=_zu2xJguqdkES0k8nx8UlglUdOiAHk72aWKl44bi2Sw&s=0JDFhFc1yLDbhcyTkAE1NO9PulBlKC3ZAsRaieLSDWg&e=
> C reproducer: https://urldefense.proofpoint.com/v2/url?u=https-3A__syzkaller.appspot.com_x_repro.c-3Fx-3D15a39e05400000&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=Jk6Q8nNzkQ6LJ6g42qARkg6ryIDGQr-yKXPNGZbpTx0&m=_zu2xJguqdkES0k8nx8UlglUdOiAHk72aWKl44bi2Sw&s=FSZ1iQgxwIrifJ7X_cwC7-L4zPR3qH5jVMEFYpP2770&e=
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+a8ef68...@syzkaller.appspotmail.com
>
> L1TF CPU bug present and SMT on, data leak possible. See CVE-2018-3646 and https://urldefense.proofpoint.com/v2/url?u=https-3A__www.kernel.org_doc_html_latest_admin-2Dguide_l1tf.html&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=Jk6Q8nNzkQ6LJ6g42qARkg6ryIDGQr-yKXPNGZbpTx0&m=_zu2xJguqdkES0k8nx8UlglUdOiAHk72aWKl44bi2Sw&s=RlJUg93Uo3_bn1O3eehqy8r8h6IXBRoE0YNsIVFQY2A&e= for details.
The info-leak here seems to be pretty obvious.
kvm_pv_clock_pairing() copies entire “clock_pairing” var to guest using kvm_write_guest(),
but it doesn’t initialize clock_pairing.pad[] bytes (which is exactly bytes 28-63).

I will submit a patch to fix this…

-Liran




Reply all
Reply to author
Forward
0 new messages