On Mon, Sep 30, 2019 at 11:09 PM Pascal Van Leeuwen <pvanleeuwen@xxxxxxxxxxxxxx> wrote: > > Subject: Re: [PATCH 2/3] crypto: inside-secure - Reduce stack usage > > > > On Mon, Sep 30, 2019 at 9:04 PM Pascal Van Leeuwen > > <pvanleeuwen@xxxxxxxxxxxxxx> 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. > > > I was actually referring to your kzalloc, not to the original stack > based implementation ... Ok, got it. For the kzalloc version, the size matters much less, as this is not coming from a scarce resource and only takes a few more cycles to do the initial clearing of the larger struct. > > > 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. > > > And by "other change" you mean the safexcel_ahash_export_state? Yes. > Ok, good to known, although I do like to improve that one as well, > but preferably by not exporting the cache so I don't need the full > struct. Sounds good to me. Arnd