Skip to content

Commit

Permalink
kvm: nVMX: Fix kernel panics induced by illegal INVEPT/INVVPID types
Browse files Browse the repository at this point in the history
Bitwise shifts by amounts greater than or equal to the width of the left
operand are undefined. A malicious guest can exploit this to crash a
32-bit host, due to the BUG_ON(1)'s in handle_{invept,invvpid}.

Signed-off-by: Jim Mattson <jmattson@google.com>
Message-Id: <1477496318-17681-1-git-send-email-jmattson@google.com>
[Change 1UL to 1, to match the range check on the shift count. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Jim Mattson authored and Paolo Bonzini committed Oct 27, 2016
1 parent 58e3948 commit 85c856b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/x86/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7659,7 +7659,7 @@ static int handle_invept(struct kvm_vcpu *vcpu)

types = (vmx->nested.nested_vmx_ept_caps >> VMX_EPT_EXTENT_SHIFT) & 6;

if (!(types & (1UL << type))) {
if (type >= 32 || !(types & (1 << type))) {
nested_vmx_failValid(vcpu,
VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID);
skip_emulated_instruction(vcpu);
Expand Down Expand Up @@ -7722,7 +7722,7 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)

types = (vmx->nested.nested_vmx_vpid_caps >> 8) & 0x7;

if (!(types & (1UL << type))) {
if (type >= 32 || !(types & (1 << type))) {
nested_vmx_failValid(vcpu,
VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID);
skip_emulated_instruction(vcpu);
Expand Down

0 comments on commit 85c856b

Please sign in to comment.