crypto: zynqmp-sha - fix NULL pointer dereference in init_tfm
Subsystems (3)
PATCH 1/1 crypto: zynqmp-sha - fix NULL pointer dereference in init_tfm
zynqmp_sha_init_tfm() checks crypto_shash_statesize(tfm_ctx->fbk_tfm) before assigning the fallback transform to it, which dereferences a NULL pointer since the transform context is zero-initialized. Use the local fallback_tfm pointer for the size check instead.
Fixes c1dd353d18e5 ("crypto: zynqmp-sha - Make descsize an algorithm attribute")
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/crypto/xilinx/zynqmp-sha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/xilinx/zynqmp-sha.c +1 -1
@@ -59,7 +59,7 @@ static int zynqmp_sha_init_tfm(struct crypto_shash *hash)return PTR_ERR (fallback_tfm);if (crypto_shash_descsize (hash) < -crypto_shash_statesize (tfm_ctx->fbk_tfm)) { +crypto_shash_statesize (fallback_tfm)) {crypto_free_shash (fallback_tfm);return -EINVAL ; }
Herbert Xu
maintainerQuoted 11 lines · Thorsten Blum
zynqmp_sha_init_tfm()checkscrypto_shash_statesize(tfm_ctx->fbk_tfm)before assigning the fallback transform to it, which dereferences a NULL pointer since the transform context is zero-initialized. Use the localfallback_tfmpointer for the size check instead.Fixes c1dd353d18e5 ("crypto: zynqmp-sha - Make descsize an algorithm attribute")Signed-off-by Thorsten Blum <[email protected]>--- drivers/crypto/xilinx/zynqmp-sha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt