summaryrefslogtreecommitdiff
path: root/include/crypto/rng.h
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2021-03-02 21:33:03 +0100
committerDenys Drozdov <denys.drozdov@toradex.com>2021-07-15 13:53:12 +0300
commitde95aa1060886217b6fd7dfefe7df1ced27bbb0b (patch)
tree31885f216b9cc35ecca8e8231f49319a36ae81df /include/crypto/rng.h
parent02d5dfb039c8d08935b5480cf76fb8d6a6eea007 (diff)
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>
Diffstat (limited to 'include/crypto/rng.h')
-rw-r--r--include/crypto/rng.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/crypto/rng.h b/include/crypto/rng.h
index 8b4b844b4eef..17bb3673d3c1 100644
--- a/include/crypto/rng.h
+++ b/include/crypto/rng.h
@@ -111,6 +111,8 @@ static inline struct rng_alg *crypto_rng_alg(struct crypto_rng *tfm)
/**
* crypto_free_rng() - zeroize and free RNG handle
* @tfm: cipher handle to be freed
+ *
+ * If @tfm is a NULL or error pointer, this function does nothing.
*/
static inline void crypto_free_rng(struct crypto_rng *tfm)
{