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>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
298a44f381
commit
92f333793a
@@ -174,6 +174,8 @@ static inline struct crypto_akcipher *crypto_akcipher_reqtfm(
|
||||
* crypto_free_akcipher() - free AKCIPHER tfm handle
|
||||
*
|
||||
* @tfm: AKCIPHER tfm handle allocated with crypto_alloc_akcipher()
|
||||
*
|
||||
* If @tfm is a NULL or error pointer, this function does nothing.
|
||||
*/
|
||||
static inline void crypto_free_akcipher(struct crypto_akcipher *tfm)
|
||||
{
|
||||
|
Reference in New Issue
Block a user