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: <20180621004715.GI111712@gmail.com>
Date:   Wed, 20 Jun 2018 17:47:15 -0700
From:   Eric Biggers <ebiggers3@...il.com>
To:     Kees Cook <keescook@...omium.org>
Cc:     Herbert Xu <herbert@...dor.apana.org.au>,
        Giovanni Cabiddu <giovanni.cabiddu@...el.com>,
        Arnd Bergmann <arnd@...db.de>,
        Eric Biggers <ebiggers@...gle.com>,
        Mike Snitzer <snitzer@...hat.com>,
        "Gustavo A. R. Silva" <gustavo@...eddedor.com>,
        qat-linux@...el.com, LKML <linux-kernel@...r.kernel.org>,
        dm-devel@...hat.com, linux-crypto <linux-crypto@...r.kernel.org>,
        Lars Persson <larper@...s.com>,
        Tim Chen <tim.c.chen@...ux.intel.com>,
        "David S. Miller" <davem@...emloft.net>,
        Alasdair Kergon <agk@...hat.com>,
        Rabin Vincent <rabinv@...s.com>
Subject: Re: [dm-devel] [PATCH 07/11] crypto: xcbc: Remove VLA usage

On Wed, Jun 20, 2018 at 05:10:04PM -0700, Kees Cook wrote:
> On Wed, Jun 20, 2018 at 4:46 PM, Eric Biggers <ebiggers3@...il.com> wrote:
> > On Wed, Jun 20, 2018 at 12:04:04PM -0700, Kees Cook wrote:
> >> In the quest to remove all stack VLA usage from the kernel[1], this uses
> >> the maximum blocksize and adds a sanity check.
> >>
> >> [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com
> >>
> >> Signed-off-by: Kees Cook <keescook@...omium.org>
> >> ---
> >>  crypto/xcbc.c | 5 ++++-
> >>  1 file changed, 4 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/crypto/xcbc.c b/crypto/xcbc.c
> >> index 25c75af50d3f..016481b1f3ba 100644
> >> --- a/crypto/xcbc.c
> >> +++ b/crypto/xcbc.c
> >> @@ -65,7 +65,10 @@ static int crypto_xcbc_digest_setkey(struct crypto_shash *parent,
> >>       int bs = crypto_shash_blocksize(parent);
> >>       u8 *consts = PTR_ALIGN(&ctx->ctx[0], alignmask + 1);
> >>       int err = 0;
> >> -     u8 key1[bs];
> >> +     u8 key1[CRYPTO_ALG_MAX_BLOCKSIZE];
> >> +
> >> +     if (WARN_ON(bs > sizeof(key1)))
> >> +             return -EINVAL;
> >
> > Similarly, why not MAX_CIPHER_BLOCKSIZE?
> >
> > Also, xcbc_create() only allows a 16-byte block size, and you made the API
> > enforce the maximum for algorithms anyway.  So I think the extra check here
> > isn't very worthwhile.
> 
> Is the "parent" argument in crypto_xcbc_digest_setkey() always going
> to be the "alg" from xcbc_create()? I couldn't convince myself that
> was true. If it is, then yes, this VLA can trivially made to be 16,
> but it seemed like they were separate instances...

Yes, it's guaranteed to be an instance of "xcbc" which was created by
xcbc_create(), so it will have 'cra_blocksize == 16'.

So until someone actually tests and enables support in the "xcbc" template for
other block sizes (if the XCBC specification allows them), it would also be fine
to just '#define XCBC_BLOCK_SIZE 16' at the top of the file and use that
everywhere that references the block size.

Eric

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ