On Mon, Jun 23, 2025 at 11:40:39AM +0200, Mikulas Patocka wrote:
> 
> 
> On Fri, 20 Jun 2025, Milan Broz wrote:
> 
> > Hi,
> > 
> > On 6/20/25 6:09 AM, Herbert Xu wrote:
> > > The output buffer size of of crypto_shash_export is returned by
> > > crypto_shash_statesize.  Alternatively HASH_MAX_STATESIZE may be
> > > used for stack buffers.
> > > 
> > > Fixes: 8cf4c341f193 ("crypto: md5-generic - Use API partial block 
> > > handling")
> > > Reported-by: Milan Broz <gmazyl...@gmail.com>
> > > Signed-off-by: Herbert Xu <herb...@gondor.apana.org.au>
> > 
> > Yes, that fixes the issue, thanks!
> > 
> > Tested-by: Milan Broz <gmazyl...@gmail.com>
> > 
> > Mikulas, I think this should go through DM tree, could you send it for 6.16?
> > The full patch is here
> > https://lore.kernel.org/linux-crypto/afte3kdzxcazc...@gondor.apana.org.au/T/#u
> > 
> > > diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
> > > index 9dfdb63220d7..cb4617df7356 100644
> > > --- a/drivers/md/dm-crypt.c
> > > +++ b/drivers/md/dm-crypt.c
> > > @@ -517,7 +517,10 @@ static int crypt_iv_lmk_one(struct crypt_config *cc, 
> > > u8
> > > *iv,
> > >   {
> > >           struct iv_lmk_private *lmk = &cc->iv_gen_private.lmk;
> > >           SHASH_DESC_ON_STACK(desc, lmk->hash_tfm);
> > > - struct md5_state md5state;
> > > + union {
> > > +         struct md5_state md5state;
> > > +         u8 state[HASH_MAX_STATESIZE];
> > > + } u;
> 
> Hi
> 
> 345 bytes on the stack - I think it's too much, given the fact that it 
> already uses 345 bytes (from SHASH_DESC_ON_STACK) and it may be called in 
> a tasklet context. I'd prefer a solution that allocates less bytes.

Of course, the correct solution is to just add MD5 support to lib/crypto/ and
use that here.  All that's needed is a single MD5 context (88 bytes), and direct
calls to the MD5 code...

- Eric

Reply via email to