android_kernel_samsung_a7y1.../arch/x86
Paolo Bonzini 5a6562b694 KVM: fail KVM_SET_VCPU_EVENTS with invalid exception number
commit 78e546c824fa8f96d323b7edd6f5cad5b74af057 upstream

This cannot be returned by KVM_GET_VCPU_EVENTS, so it is okay to return
EINVAL.  It causes a WARN from exception_type:

    WARNING: CPU: 3 PID: 16732 at arch/x86/kvm/x86.c:345 exception_type+0x49/0x50 [kvm]()
    CPU: 3 PID: 16732 Comm: a.out Tainted: G        W       4.4.6-300.fc23.x86_64 #1
    Hardware name: LENOVO 2325F51/2325F51, BIOS G2ET32WW (1.12 ) 05/30/2012
     0000000000000286 000000006308a48b ffff8800bec7fcf8 ffffffff813b542e
     0000000000000000 ffffffffa0966496 ffff8800bec7fd30 ffffffff810a40f2
     ffff8800552a8000 0000000000000000 00000000002c267c 0000000000000001
    Call Trace:
     [<ffffffff813b542e>] dump_stack+0x63/0x85
     [<ffffffff810a40f2>] warn_slowpath_common+0x82/0xc0
     [<ffffffff810a423a>] warn_slowpath_null+0x1a/0x20
     [<ffffffffa0924809>] exception_type+0x49/0x50 [kvm]
     [<ffffffffa0934622>] kvm_arch_vcpu_ioctl_run+0x10a2/0x14e0 [kvm]
     [<ffffffffa091c04d>] kvm_vcpu_ioctl+0x33d/0x620 [kvm]
     [<ffffffff81241248>] do_vfs_ioctl+0x298/0x480
     [<ffffffff812414a9>] SyS_ioctl+0x79/0x90
     [<ffffffff817a04ee>] entry_SYSCALL_64_fastpath+0x12/0x71
    ---[ end trace b1a0391266848f50 ]---

Testcase (beautified/reduced from syzkaller output):

    #include <unistd.h>
    #include <sys/syscall.h>
    #include <string.h>
    #include <stdint.h>
    #include <fcntl.h>
    #include <sys/ioctl.h>
    #include <linux/kvm.h>

    long r[31];

    int main()
    {
        memset(r, -1, sizeof(r));
        r[2] = open("/dev/kvm", O_RDONLY);
        r[3] = ioctl(r[2], KVM_CREATE_VM, 0);
        r[7] = ioctl(r[3], KVM_CREATE_VCPU, 0);

        struct kvm_vcpu_events ve = {
                .exception.injected = 1,
                .exception.nr = 0xd4
        };
        r[27] = ioctl(r[7], KVM_SET_VCPU_EVENTS, &ve);
        r[30] = ioctl(r[7], KVM_RUN, 0);
        return 0;
    }

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Zubin Mithra <zsm@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-06 16:38:35 +02:00
..
boot x86/build: Specify elf_i386 linker emulation explicitly for i386 objects 2020-04-06 14:56:37 +02:00
configs A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
crypto crypto: x86/poly1305 - fix overflow during partial reduction 2020-04-06 15:51:38 +02:00
entry x86/vdso: Drop implicit common-page-size linker flag 2020-04-06 15:07:16 +02:00
ia32 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
include xen: Prevent buffer overflow in privcmd ioctl 2020-04-06 15:11:37 +02:00
kernel x86/kprobes: Verify stack frame on kretprobe 2020-04-06 15:56:59 +02:00
kvm KVM: fail KVM_SET_VCPU_EVENTS with invalid exception number 2020-04-06 16:38:35 +02:00
lguest A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
lib A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
math-emu A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mm A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
net A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
oprofile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
pci A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
platform A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
power A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
purgatory A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ras A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
realmode x86/build: Specify elf_i386 linker emulation explicitly for i386 objects 2020-04-06 14:56:37 +02:00
tools A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
um A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
video A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
xen A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kbuild A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig x86/smp: Enforce CONFIG_HOTPLUG_CPU when SMP=y 2020-04-06 13:01:35 +02:00
Kconfig.cpu A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig.debug A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile_32.cpu A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile.um A750FXXU4CTBC 2020-03-27 21:51:54 +05:30