From: Dan Carpenter <dan.carpenter@oracle.com> To: Neil Horman <nhorman@tuxdriver.com>, Corentin Labbe <clabbe@baylibre.com> Cc: Herbert Xu <herbert@gondor.apana.org.au>, "David S. Miller" <davem@davemloft.net>, linux-crypto@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] crypto: rng - Fix a refcounting bug in crypto_rng_reset() Date: Mon, 20 Jan 2020 17:38:04 +0300 [thread overview] Message-ID: <20200120143804.pbmnrh72v2gogx43@kili.mountain> (raw) We need to decrement this refcounter on these error paths. Fixes: f7d76e05d058 ("crypto: user - fix use_after_free of struct xxx_request") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- crypto/rng.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crypto/rng.c b/crypto/rng.c index 1e21231f71c9..1490d210f1a1 100644 --- a/crypto/rng.c +++ b/crypto/rng.c @@ -37,12 +37,16 @@ int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen) crypto_stats_get(alg); if (!seed && slen) { buf = kmalloc(slen, GFP_KERNEL); - if (!buf) + if (!buf) { + crypto_alg_put(alg); return -ENOMEM; + } err = get_random_bytes_wait(buf, slen); - if (err) + if (err) { + crypto_alg_put(alg); goto out; + } seed = buf; } -- 2.11.0
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com> To: Neil Horman <nhorman@tuxdriver.com>, Corentin Labbe <clabbe@baylibre.com> Cc: Herbert Xu <herbert@gondor.apana.org.au>, "David S. Miller" <davem@davemloft.net>, linux-crypto@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] crypto: rng - Fix a refcounting bug in crypto_rng_reset() Date: Mon, 20 Jan 2020 14:38:04 +0000 [thread overview] Message-ID: <20200120143804.pbmnrh72v2gogx43@kili.mountain> (raw) We need to decrement this refcounter on these error paths. Fixes: f7d76e05d058 ("crypto: user - fix use_after_free of struct xxx_request") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- crypto/rng.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crypto/rng.c b/crypto/rng.c index 1e21231f71c9..1490d210f1a1 100644 --- a/crypto/rng.c +++ b/crypto/rng.c @@ -37,12 +37,16 @@ int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen) crypto_stats_get(alg); if (!seed && slen) { buf = kmalloc(slen, GFP_KERNEL); - if (!buf) + if (!buf) { + crypto_alg_put(alg); return -ENOMEM; + } err = get_random_bytes_wait(buf, slen); - if (err) + if (err) { + crypto_alg_put(alg); goto out; + } seed = buf; } -- 2.11.0
next reply other threads:[~2020-01-20 14:40 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-01-20 14:38 Dan Carpenter [this message] 2020-01-20 14:38 ` [PATCH] crypto: rng - Fix a refcounting bug in crypto_rng_reset() Dan Carpenter 2020-01-20 15:56 ` Neil Horman 2020-01-20 15:56 ` Neil Horman 2020-02-13 9:17 ` Herbert Xu 2020-02-13 9:17 ` Herbert Xu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200120143804.pbmnrh72v2gogx43@kili.mountain \ --to=dan.carpenter@oracle.com \ --cc=clabbe@baylibre.com \ --cc=davem@davemloft.net \ --cc=herbert@gondor.apana.org.au \ --cc=kernel-janitors@vger.kernel.org \ --cc=linux-crypto@vger.kernel.org \ --cc=nhorman@tuxdriver.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.