Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Peter Gonda <pgonda@google.com>, Borislav Petkov <bp@suse.de>
Cc: Dionna Glaze <dionnaglaze@google.com>,
	Michael Roth <michael.roth@amd.com>,
	Haowen Bai <baihaowen@meizu.com>,
	Yang Yingliang <yangyingliang@huawei.com>,
	Marc Orr <marcorr@google.com>,
	David Rientjes <rientjes@google.com>,
	Ashish Kalra <Ashish.Kalra@amd.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH V4] virt: sev: Prevent IV reuse in SNP guest driver
Date: Wed, 16 Nov 2022 10:58:33 -0600	[thread overview]
Message-ID: <bc070ef7-8168-f1fc-f5ec-aeac204f2ef6@amd.com> (raw)
In-Reply-To: <CAMkAt6qQmkufbuotzMA4bMJaA4uBFMdk8w7a3X+OH3JaOdFepA@mail.gmail.com>

On 11/16/22 10:23, Peter Gonda wrote:
> On Wed, Nov 16, 2022 at 5:20 AM Borislav Petkov <bp@suse.de> wrote:
>>
>> On Tue, Nov 15, 2022 at 02:47:31PM -0700, Peter Gonda wrote:
>>>>> +      * certificate data buffer retry the same guest request without the
>>>>> +      * extended data request.
>>>>> +      */
>>>>> +     if (exit_code == SVM_VMGEXIT_EXT_GUEST_REQUEST &&
>>>>> +         err == SNP_GUEST_REQ_INVALID_LEN) {
>>>>> +             const unsigned int certs_npages = snp_dev->input.data_npages;
>>>>> +
>>>>> +             exit_code = SVM_VMGEXIT_GUEST_REQUEST;
>>>>> +             rc = snp_issue_guest_request(exit_code, &snp_dev->input, &err);
>>>>> +
>>>>> +             err = SNP_GUEST_REQ_INVALID_LEN;
>>>>
>>>> Huh, why are we overwriting err here?
>>>
>>> I have added a comment for the next revision.
>>>
>>> We are overwriting err here so that userspace is alerted that they
>>> supplied a buffer too small.
>>
>> Sure but you're not checking rc either. What if that reissue fails for
>> whatever other reason? -EIO for example...
> 
> If we get any error here we have to wipe the VMPCK here so I thought

More accurate to say that you will wipe the VMPCK, since the value of rc 
is checked a bit further down in the code and the -EIO (or other non-zero) 
will be result in a call to snp_disable_vmpck() and rc being propagated 
back to the user as an ioctl() return code.

Might be worth a comment above that second snp_issue_guest_request() 
explaining that.

> this always override @err was OK.
> 
> I can update this to only override @err if after the secondary
> SVM_VMGEXIT_GUEST_REQUEST rc and err are OK. Thoughts?

I think it's ok to set it no matter what, but I don't have a strong 
opinion either way.

Thanks,
Tom

> 
>>
>> --
>> Regards/Gruss,
>>      Boris.
>>
>> SUSE Software Solutions Germany GmbH
>> GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
>> (HRB 36809, AG Nürnberg)

  reply	other threads:[~2022-11-16 16:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03 15:23 [PATCH V4] virt: sev: Prevent IV reuse in SNP guest driver Peter Gonda
2022-11-04 17:39 ` Tom Lendacky
2022-11-11 16:46 ` Borislav Petkov
2022-11-14 21:11   ` Peter Gonda
2022-11-15 21:36     ` Borislav Petkov
2022-11-15 21:48       ` Peter Gonda
2022-11-15 21:47   ` Peter Gonda
2022-11-16 12:20     ` Borislav Petkov
2022-11-16 16:23       ` Peter Gonda
2022-11-16 16:58         ` Tom Lendacky [this message]
2022-11-16 17:10           ` Peter Gonda
2022-11-16 17:28             ` Borislav Petkov
2022-11-16 17:57               ` Peter Gonda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bc070ef7-8168-f1fc-f5ec-aeac204f2ef6@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=Ashish.Kalra@amd.com \
    --cc=baihaowen@meizu.com \
    --cc=bp@suse.de \
    --cc=dionnaglaze@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcorr@google.com \
    --cc=michael.roth@amd.com \
    --cc=pgonda@google.com \
    --cc=rientjes@google.com \
    --cc=yangyingliang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox