summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2021-03-02 21:33:03 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-05-11 14:04:05 +0200
commit9ee4fcdc653d31bdc3804da8a983db1df27899e3 (patch)
tree543e062697f9afc67ff9035507e418e0e4744b32
parentc45e9a0c7a703c10b4d1031496b31b9c18683ef4 (diff)
downloadlinux-crypto-9ee4fcdc653d31bdc3804da8a983db1df27899e3.tar.gz
linux-crypto-9ee4fcdc653d31bdc3804da8a983db1df27899e3.zip
crypto: api - check for ERR pointers in crypto_destroy_tfm()
[ Upstream commit 72e2a02cdf58fbe06533cc21f6d7dd518cf01ae5 ] Given that crypto_alloc_tfm() may return ERR pointers, and to avoid crashes on obscure error paths where such pointers are presented to crypto_destroy_tfm() (such as [0]), add an ERR_PTR check there before dereferencing the second argument as a struct crypto_tfm pointer. [0] https://lore.kernel.org/linux-crypto/000000000000de949705bc59e0f6@google.com/ Reported-by: syzbot+12cf5fbfdeba210a89dd@syzkaller.appspotmail.com Reviewed-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--crypto/api.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/api.c b/crypto/api.c
index eda0c56b..c71d1485 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -568,7 +568,7 @@ void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)
{
struct crypto_alg *alg;
- if (unlikely(!mem))
+ if (IS_ERR_OR_NULL(mem))
return;
alg = tfm->__crt_alg;