]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: shash - Add init_tfm/exit_tfm and verify descsize
authorHerbert Xu <herbert@gondor.apana.org.au>
Sun, 8 Dec 2019 05:42:51 +0000 (13:42 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 11 Dec 2019 08:48:39 +0000 (16:48 +0800)
commit3e00397ea8b99dd674bd80392673f8ad3bcbdeaa
tree14f125cc1ae013ef1cdcddf85531f6d76b6a3130
parent2e3fbf98e2f825922cdb5f68c3fe0b886dd7e1e9
crypto: shash - Add init_tfm/exit_tfm and verify descsize

The shash interface supports a dynamic descsize field because of
the presence of fallbacks (it's just padlock-sha actually, perhaps
we can remove it one day).  As it is the API does not verify the
setting of descsize at all.  It is up to the individual algorithms
to ensure that descsize does not exceed the specified maximum value
of HASH_MAX_DESCSIZE (going above would cause stack corruption).

In order to allow the API to impose this limit directly, this patch
adds init_tfm/exit_tfm hooks to the shash_alg structure.  We can
then verify the descsize setting in the API directly.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/shash.c
include/crypto/hash.h