public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Michael Roth <michael.roth@amd.com>
Subject: Re: [PATCH] KVM: SEV: Reject non-positive effective lengths during LAUNCH_UPDATE
Date: Mon, 8 Sep 2025 16:54:21 -0700	[thread overview]
Message-ID: <aL9srWU7gnKJzeig@google.com> (raw)
In-Reply-To: <b55f2ab4-da7c-5fed-adab-ceca54282ddb@amd.com>

On Mon, Sep 08, 2025, Tom Lendacky wrote:
> On 8/26/25 18:37, Sean Christopherson wrote:
> > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> > index f4381878a9e5..746a57bf1f71 100644
> > --- a/arch/x86/kvm/svm/sev.c
> > +++ b/arch/x86/kvm/svm/sev.c
> > @@ -2360,6 +2360,8 @@ static int snp_launch_update(struct kvm *kvm, struct kvm_sev_cmd *argp)
> >  		return -EINVAL;
> >  
> >  	npages = params.len / PAGE_SIZE;
> > +	if (npages <= 0)
> > +		return -EINVAL;
> 
> Would it make sense to include a !params.len in the giant if check just
> above this, e.g.:
> 
> 	if (!params.len || !PAGE_ALIGNED(params.len) || ...
> 
> ?
> 
> That way everything related to checking "params" remains in the one
> statement.

Oh, yeah, duh.  I overlooked that the only way for npages to be '0' is if
params.len is '0', because the PAGE_ALIGNED() check will handed len == 1-4095.

Will send a v2.  Thanks Tom!

      reply	other threads:[~2025-09-08 23:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-26 23:37 [PATCH] KVM: SEV: Reject non-positive effective lengths during LAUNCH_UPDATE Sean Christopherson
2025-09-08 21:35 ` Tom Lendacky
2025-09-08 23:54   ` Sean Christopherson [this message]

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=aL9srWU7gnKJzeig@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=thomas.lendacky@amd.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