On Thu, Jan 17, 2019 at 11:56 AM Jim Mattson <jmattson@xxxxxxxxxx> wrote: > > 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. > > Reported-by: Felix Wilhelm <fwilhelm@xxxxxxxxxx> > Signed-off-by: Jim Mattson <jmattson@xxxxxxxxxx> > Reviewed-by: Drew Schmitt <dasch@xxxxxxxxxx> > Reviewed-by: Marc Orr <marcorr@xxxxxxxxxx> > Reviewed-by: Peter Shier <pshier@xxxxxxxxxx> > --- > arch/x86/kvm/vmx/nested.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > index 2616bd2c7f2c..3bb49ad91d0c 100644 > --- a/arch/x86/kvm/vmx/nested.c > +++ b/arch/x86/kvm/vmx/nested.c > @@ -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, > -- > 2.20.1.97.g81188d93c3-goog Ping.