Re: [BUG] crypto: export() overran state buffer on test vector

From: Corentin Labbe
Date: Wed Feb 12 2020 - 13:58:02 EST


On Wed, Feb 12, 2020 at 10:06:28AM +0800, Herbert Xu wrote:
> On Tue, Feb 11, 2020 at 08:21:18PM +0100, Corentin Labbe wrote:
> >
> > Do you mean that I should abandon ahash as a fallback ?
>
> Perhaps switching to shash is not as straightforward because of
> SG handling. But if you're getting problems with statesize
> perhaps at least force a sync ahash algorithm might be a good
> idea.
>

I just found the problem, it happen with ARM CE which has a bigger state_size (sha256_ce_state) of 4bytes.

Since my driver didnt use statesize at all, I detect this on cra_init() like this:
if (algt->alg.hash.halg.statesize < crypto_ahash_statesize(op->fallback_tfm))
algt->alg.hash.halg.statesize = crypto_ahash_statesize(op->fallback_tfm);

Regards