Skip to contentSkip to conversation

KVM: nVMX: Fix size checks in vmx_set_nested_state

PATCH Jim Mattson 2 participants 2 messages Apr 30, 2019 6 messages not in the archive KVM

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CALMp9eT9=rXr38KG8_TmpG-FDHWZ6vGKiiAxKXfKHwZ=nyhDmQ@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CALMp9eSiML06n+zoWoeArfXaTiP6tiWwqg4UVXSc=_sTjUE0jA@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CALMp9eQriJMW-xx3PcGSFMPTwbpaPQ7Fe_YzAJ1uHiGsRat84Q@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CALMp9eQcLALJZgpnYfhRCLa4bYxskLHLHWXV2+p6uQKZyOXXxQ@mail.gmail.com

#6 lore raw
Quoted 49 lines · Jim Mattson
Quoted 47 lines · Jim Mattson
Quoted 44 lines · Krish Sadhukhan
Quoted 40 lines · Jim Mattson
Quoted 39 lines · Jim Mattson
Quoted 36 lines · Jim Mattson

The size checks in vmx_nested_state are wrong because the calculations are made based on the size of a pointer to a struct kvm_nested_state rather than the size of a struct kvm_nested_state.

---
  arch/x86/kvm/vmx/nested.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/nested.c +2 -3
index 2616bd2c7f2c..3bb49ad91d0c 100644
@@ -5351,7 +5351,7 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
                 return ret;
 
         /* Empty 'VMXON' state is permitted */
-       if (kvm_state->size < sizeof(kvm_state) + sizeof(*vmcs12))
+       if (kvm_state->size < sizeof(*kvm_state) + sizeof(*vmcs12))
                 return 0;
 
         if (kvm_state->vmx.vmcs_pa != -1ull) {
@@ -5395,7 +5395,7 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
             vmcs12->vmcs_link_pointer != -1ull) {
                 struct vmcs12 *shadow_vmcs12 = get_shadow_vmcs12(vcpu);
 
-               if (kvm_state->size < sizeof(kvm_state) + 2 * sizeof(*vmcs12))
+               if (kvm_state->size < sizeof(*kvm_state) + 2 * sizeof(*vmcs12))
                         return -EINVAL;
 
                 if (copy_from_user(shadow_vmcs12,
--
Quoted 1 line

2.20.1.97.g81188d93c3-goog

Ping.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Ping again?

Ping again, just for grins.

Ping.

This seems pretty straightforward. Am I missing something?

maintainer
#7 lore raw
Quoted 50 lines · Jim Mattson
Quoted 49 lines · Jim Mattson
Quoted 47 lines · Jim Mattson
Quoted 44 lines · Krish Sadhukhan
Quoted 40 lines · Jim Mattson
Quoted 39 lines · Jim Mattson
Quoted 36 lines · Jim Mattson

The size checks in vmx_nested_state are wrong because the calculations are made based on the size of a pointer to a struct kvm_nested_state rather than the size of a struct kvm_nested_state.

---
  arch/x86/kvm/vmx/nested.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/nested.c +2 -3
index 2616bd2c7f2c..3bb49ad91d0c 100644
@@ -5351,7 +5351,7 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
                 return ret;
 
         /* Empty 'VMXON' state is permitted */
-       if (kvm_state->size < sizeof(kvm_state) + sizeof(*vmcs12))
+       if (kvm_state->size < sizeof(*kvm_state) + sizeof(*vmcs12))
                 return 0;
 
         if (kvm_state->vmx.vmcs_pa != -1ull) {
@@ -5395,7 +5395,7 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
             vmcs12->vmcs_link_pointer != -1ull) {
                 struct vmcs12 *shadow_vmcs12 = get_shadow_vmcs12(vcpu);
 
-               if (kvm_state->size < sizeof(kvm_state) + 2 * sizeof(*vmcs12))
+               if (kvm_state->size < sizeof(*kvm_state) + 2 * sizeof(*vmcs12))
                         return -EINVAL;
 
                 if (copy_from_user(shadow_vmcs12,
--
Quoted 1 line

2.20.1.97.g81188d93c3-goog

Ping.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Ping again?

Ping again, just for grins.

Ping.

This seems pretty straightforward. Am I missing something?

Nope, I just missed it again and again. I've queued it now.

Paolo