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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 30 Sep 2019 22:11:33 +0200
From:   Arnd Bergmann <arnd@...db.de>
To:     Pascal Van Leeuwen <pvanleeuwen@...imatrix.com>
Cc:     Antoine Tenart <antoine.tenart@...tlin.com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        "David S. Miller" <davem@...emloft.net>,
        Pascal van Leeuwen <pascalvanl@...il.com>,
        Ard Biesheuvel <ard.biesheuvel@...aro.org>,
        Eric Biggers <ebiggers@...gle.com>,
        "linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/3] crypto: inside-secure - Reduce stack usage

On Mon, Sep 30, 2019 at 9:04 PM Pascal Van Leeuwen
<pvanleeuwen@...imatrix.com> wrote:

> > Alternatively, it should be possible to shrink these allocations
> > as the extra buffers appear to be largely unnecessary, but doing
> > this would be a much more invasive change.
> >
> Actually, for HMAC-SHA512 you DO need all that buffer space.
> You could shrink it to 2 * ctx->state_sz but then your simple indexing
> is no longer going to fly. Not sure if that would be worth the effort.

Stack allocations can no longer be dynamically sized in the kernel,
so that would not work.

What I noticed though is that the largest part of safexcel_ahash_export_state
is used in the 'cache' member, and this is apparently only referenced inside of
safexcel_hmac_init_iv, which you call twice. If that cache can be allocated
only once, you save SHA512_BLOCK_SIZE bytes in one of the two paths.

> I don't like the part where you dynamically allocate the cryto_aes_ctx
> though, I think that was not necessary considering its a lot smaller.

I count 484 bytes for it, which is really large.

> And it conflicts with another change I have waiting that gets rid of
> aes_expandkey and that struct alltogether (since it was really just
> abused to do a key size check, which was very wasteful since the
> function actually generates all roundkeys we don't need at all ...)

Right, this is what I noticed there. With 480 of the 484 bytes gone,
you are well below the warning limit even without the other change.

       Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ