From: Tom Lendacky <thomas.lendacky@amd.com>
To: Peter Gonda <pgonda@google.com>
Cc: kvm@vger.kernel.org, Andy Nguyen <theflow@google.com>,
David Rientjes <rientjes@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
stable@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: sev: Fix int overflow in send|recieve_update_data ioctls
Date: Tue, 10 Jan 2023 11:16:30 -0600 [thread overview]
Message-ID: <d6c2455c-aff5-a135-2610-53dd6b586b59@amd.com> (raw)
In-Reply-To: <CAMkAt6q_E-+VV=KOs9LbDzawirWR7M4xL2pCF9fR2kMuBuFM-A@mail.gmail.com>
On 1/10/23 10:44, Peter Gonda wrote:
>>>
>>> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
>>> index 273cba809328..9451de72f917 100644
>>> --- a/arch/x86/kvm/svm/sev.c
>>> +++ b/arch/x86/kvm/svm/sev.c
>>> @@ -1294,7 +1294,7 @@ static int sev_send_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp)
>>>
>>> /* Check if we are crossing the page boundary */
>>> offset = params.guest_uaddr & (PAGE_SIZE - 1);
>>> - if ((params.guest_len + offset > PAGE_SIZE))
>>> + if (params.guest_len > PAGE_SIZE || (params.guest_len + offset > PAGE_SIZE))
>>
>> I see the original if statement had double parentheses, which looks
>> strange. Should this if (and the one below) be:
>>
>> if (params.guest_len > PAGE_SIZE || (params.guest_len + offset) > PAGE_SIZE)
>
> Isn't the order of operations here: '+' and then '>'. So is the patch
> correct and matches the old conditional? I am fine adding additional
But what was the purpose of them in the old conditional? They weren't
necessary.
But, yes, that order of operations is correct and those are both before
'||'. So the extra parentheses around the second condition check are still
strange then, right?
Given that, then:
if (params.guest_len > PAGE_SIZE || params.guest_len + offset > PAGE_SIZE)
> () for clarity though.
I do like the look and clarity of the parentheses around the addition.
Thanks,
Tom
next prev parent reply other threads:[~2023-01-10 17:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 16:08 [PATCH] KVM: sev: Fix int overflow in send|recieve_update_data ioctls Peter Gonda
2023-01-10 16:32 ` Tom Lendacky
2023-01-10 16:44 ` Peter Gonda
2023-01-10 17:16 ` Tom Lendacky [this message]
2023-01-10 17:20 ` 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=d6c2455c-aff5-a135-2610-53dd6b586b59@amd.com \
--to=thomas.lendacky@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=pgonda@google.com \
--cc=rientjes@google.com \
--cc=seanjc@google.com \
--cc=stable@vger.kernel.org \
--cc=theflow@google.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