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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMj1kXGMPimX0_dR_kLuzZjuJK9rM=uCpRDtoJq0UjWq12M10A@mail.gmail.com>
Date:   Fri, 20 Aug 2021 13:14:52 +0200
From:   Ard Biesheuvel <ardb@...nel.org>
To:     Herbert Xu <herbert@...dor.apana.org.au>
Cc:     Shreyansh Chouhan <chouhan.shreyansh630@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        X86 ML <x86@...nel.org>, "H. Peter Anvin" <hpa@...or.com>,
        Linux Crypto Mailing List <linux-crypto@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        syzbot+20191dc583eff8602d2d@...kaller.appspotmail.com
Subject: Re: [PATCH] crypto: xts_crypt() return if walk.nbytes is 0

On Fri, 20 Aug 2021 at 10:31, Herbert Xu <herbert@...dor.apana.org.au> wrote:
>
> On Mon, Aug 09, 2021 at 07:40:27PM +0530, Shreyansh Chouhan wrote:
> > xts_crypt() code doesn't call kernel_fpu_end() after calling
> > kernel_fpu_begin() if walk.nbytes is 0. The correct behavior should be
> > not calling kernel_fpu_begin() if walk.nbytes is 0.
> >
> > Reported-by: syzbot+20191dc583eff8602d2d@...kaller.appspotmail.com
> > Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@...il.com>
> > ---
> >  arch/x86/crypto/aesni-intel_glue.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
> > index 388643ca2177..ec6eac57c493 100644
> > --- a/arch/x86/crypto/aesni-intel_glue.c
> > +++ b/arch/x86/crypto/aesni-intel_glue.c
> > @@ -849,7 +849,7 @@ static int xts_crypt(struct skcipher_request *req, bool encrypt)
> >               return -EINVAL;
> >
> >       err = skcipher_walk_virt(&walk, req, false);
> > -     if (err)
> > +     if (err || !walk.nbytes)
> >               return err;
>
> The err check is now redundant because when there is an error
> nbytes is always zero.
>

In spite of that, I have a slight preference for this version, given
that it makes it obvious that we bail on two separate conditions:
- an error has occurred
- no error has occurred but the resulting walk is empty

Testing walk.nbytes only needlessly obfuscates the code, as we need to
return 'err' in the end anyway.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ