lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMkAt6orqOCrOiy=kjBq=5jnP1CyM=cbaYYaVAZLDnqbRpgUCw@mail.gmail.com>
Date:   Tue, 10 Jan 2023 10:20:50 -0700
From:   Peter Gonda <pgonda@...gle.com>
To:     Tom Lendacky <thomas.lendacky@....com>
Cc:     kvm@...r.kernel.org, Andy Nguyen <theflow@...gle.com>,
        David Rientjes <rientjes@...gle.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Sean Christopherson <seanjc@...gle.com>,
        stable@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: sev: Fix int overflow in send|recieve_update_data ioctls

On Tue, Jan 10, 2023 at 10:16 AM Tom Lendacky <thomas.lendacky@....com> wrote:
>
> 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.

Sounds good to me. I'll update the V2 in a couple days to wait for any
other comments.

>
> Thanks,
> Tom

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ