Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-11 Thread Wanpeng Li
2018-02-09 20:42 GMT+08:00 Paolo Bonzini : > On 09/02/2018 04:22, Xiao Guangrong wrote: >>> >> >> That is a good question... :) >> >> This case (with KVM_MEMSLOT_INVALID is set) can be easily constructed, >> userspace should avoid this case by itself (avoiding vCPU accessing the >> memslot which is

Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-11 Thread Wanpeng Li
2018-02-11 11:20 GMT+08:00 Xiao Guangrong : > > > On 02/09/2018 08:42 PM, Paolo Bonzini wrote: >> >> On 09/02/2018 04:22, Xiao Guangrong wrote: >>> >>> That is a good question... :) >>> >>> This case (with KVM_MEMSLOT_INVALID is set) can be easily constructed, >>> userspace should avoid t

Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-10 Thread Xiao Guangrong
On 02/09/2018 08:42 PM, Paolo Bonzini wrote: On 09/02/2018 04:22, Xiao Guangrong wrote: That is a good question... :) This case (with KVM_MEMSLOT_INVALID is set) can be easily constructed, userspace should avoid this case by itself (avoiding vCPU accessing the memslot which is being update

Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-09 Thread Paolo Bonzini
On 09/02/2018 04:22, Xiao Guangrong wrote: >> > > That is a good question... :) > > This case (with KVM_MEMSLOT_INVALID is set) can be easily constructed, > userspace should avoid this case by itself (avoiding vCPU accessing the > memslot which is being updated). If it happens, it's a operation i

Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-08 Thread Xiao Guangrong
On 02/08/2018 06:31 PM, Paolo Bonzini wrote: On 08/02/2018 09:57, Xiao Guangrong wrote: Maybe it should return RET_PF_EMULATE, which would cause an emulation failure and then an exit with KVM_EXIT_INTERNAL_ERROR. So the root cause is that a running vCPU accessing the memory whose memslot is

Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-08 Thread Paolo Bonzini
On 08/02/2018 09:57, Xiao Guangrong wrote: >> Maybe it should return RET_PF_EMULATE, which would cause an emulation >> failure and then an exit with KVM_EXIT_INTERNAL_ERROR. > > So the root cause is that a running vCPU accessing the memory whose memslot > is being updated (met the condition KVM_ME

Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-08 Thread Xiao Guangrong
On 02/07/2018 10:16 PM, Paolo Bonzini wrote: On 07/02/2018 07:25, Wanpeng Li wrote: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 786cd00..445e702 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7458,6 +7458,11 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, st

Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-07 Thread Wanpeng Li
2018-02-07 22:16 GMT+08:00 Paolo Bonzini : > On 07/02/2018 07:25, Wanpeng Li wrote: >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index 786cd00..445e702 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x86.c >> @@ -7458,6 +7458,11 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu

Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-07 Thread Paolo Bonzini
On 07/02/2018 07:25, Wanpeng Li wrote: > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 786cd00..445e702 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -7458,6 +7458,11 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, > struct kvm_run *kvm_run) >

Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-06 Thread Dmitry Vyukov
On Wed, Feb 7, 2018 at 7:25 AM, Wanpeng Li wrote: > From: Wanpeng Li > > Reported by syzkaller: > >WARNING: CPU: 6 PID: 2434 at arch/x86/kvm/vmx.c:6660 > handle_ept_misconfig+0x54/0x1e0 [kvm_intel] >CPU: 6 PID: 2434 Comm: repro_test Not tainted 4.15.0+ #4 >RIP: 0010:handle_ept_miscon

[PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-06 Thread Wanpeng Li
From: Wanpeng Li Reported by syzkaller: WARNING: CPU: 6 PID: 2434 at arch/x86/kvm/vmx.c:6660 handle_ept_misconfig+0x54/0x1e0 [kvm_intel] CPU: 6 PID: 2434 Comm: repro_test Not tainted 4.15.0+ #4 RIP: 0010:handle_ept_misconfig+0x54/0x1e0 [kvm_intel] Call Trace: vmx_handle_exit+0xb