Re: [PATCH v7 01/72] KVM: SVM: nested: Don't allocate VMCB structures on stack

From: Michael Roth
Date: Thu Nov 05 2020 - 19:32:37 EST


On Thu, Nov 05, 2020 at 05:38:12PM +0100, Borislav Petkov wrote:
> On Thu, Nov 05, 2020 at 10:24:37AM -0600, Michael Roth wrote:
> > > out_set_gif:
> > > svm_set_gif(svm, !!(kvm_state->flags & KVM_STATE_NESTED_GIF_SET));
> > > - return 0;
> > > +
> > > + ret = 0;
> > > +out_free:
> > > + kfree(save);
> > > + kfree(ctl);
> >
> > This change seems to trigger a crash via smm-test.c (and state-test.c) KVM
> > selftest when we call vcpu_load_state->KVM_SET_NESTED_STATE. I think what's
> > happening is we are hitting the 'goto out_set_gif;'
>
> No out_set_gif upstream anymore after
>
> d5cd6f340145 ("KVM: nSVM: Avoid freeing uninitialized pointers in svm_set_nested_state()")
>
> and it looks like you hit the issue this patch is fixing.
>
> Can you test with the above commit cherrypicked ontop of your what looks
> like 5.9.1-ish tree?
>
> If that fixes it, we should route this patch to stable.

Hi Boris,

I can confirm that patch fixes the issue. It is indeed a 5.9.1 tree, but
looks like the SEV-ES patches didn't go in until v5.10-rc1 (this tree
had a backport of them), so stable trees shouldn't be affected.

Thanks!

-Mike

>
> Thx.
>
> --
> Regards/Gruss,
> Boris.
>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpeople.kernel.org%2Ftglx%2Fnotes-about-netiquette&data=04%7C01%7Cmichael.roth%40amd.com%7Cfdf6f0dd23ed48449e1e08d881a93909%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637401911116171669%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=yvG6Gtb%2FVJnjMTXsOBApU83DCuKx3%2FRAID6f3TpEy7w%3D&reserved=0