crypto: api - check for ERR pointers in crypto_destroy_tfm()
authorArd Biesheuvel <ardb@kernel.org>
Tue, 2 Mar 2021 20:33:03 +0000 (21:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 May 2021 12:47:16 +0000 (14:47 +0200)
commit92f333793a78d9d721085aca4b2fa9ed01b7eb73
tree64337874346859d00b889fb31083ff6101bb5e09
parent298a44f3817167b99bbc06a9e6a5a7770b561ae8
crypto: api - check for ERR pointers in crypto_destroy_tfm()

[ Upstream commit 83681f2bebb34dbb3f03fecd8f570308ab8b7c2c ]

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>
crypto/api.c
include/crypto/acompress.h
include/crypto/aead.h
include/crypto/akcipher.h
include/crypto/hash.h
include/crypto/kpp.h
include/crypto/rng.h
include/crypto/skcipher.h