From: Herbert Xu <herbert@gondor.apana.org.au>
To: Stephan Mueller <smueller@chronox.de>
Cc: Harsh Jain <harshjain.prof@gmail.com>, linux-crypto@vger.kernel.org
Subject: [PATCH v2] crypto: algif_hash - Only export and import on sockets with data
Date: Sun, 1 Nov 2015 17:11:19 +0800 [thread overview]
Message-ID: <20151101091119.GA3035@gondor.apana.org.au> (raw)
In-Reply-To: <2587504.xtsMOV5mei@myon.chronox.de>
On Sat, Oct 31, 2015 at 12:45:47AM +0100, Stephan Mueller wrote:
>
> Testing complete: patch solves the oops and allows to successfully perform
> HMAC even when having subsequent accepts and operating on those subsequent
> accepts.
Thanks Stephan!
Unfortunately my patch is incomplete as some other thread could
change ctx->more while we're in the middle of the accept call.
So here is an updated version.
---8<---
The hash_accept call fails to work on sockets that have not received
any data. For some algorithm implementations it may cause crashes.
This patch fixes this by ensuring that we only export and import on
sockets that have received data.
Cc: stable@vger.kernel.org
Reported-by: Harsh Jain <harshjain.prof@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
index 1396ad0..b4c24fe 100644
--- a/crypto/algif_hash.c
+++ b/crypto/algif_hash.c
@@ -181,9 +181,14 @@ static int hash_accept(struct socket *sock, struct socket *newsock, int flags)
struct sock *sk2;
struct alg_sock *ask2;
struct hash_ctx *ctx2;
+ bool more;
int err;
- err = crypto_ahash_export(req, state);
+ lock_sock(sk);
+ more = ctx->more;
+ err = more ? crypto_ahash_export(req, state) : 0;
+ release_sock(sk);
+
if (err)
return err;
@@ -194,7 +199,10 @@ static int hash_accept(struct socket *sock, struct socket *newsock, int flags)
sk2 = newsock->sk;
ask2 = alg_sk(sk2);
ctx2 = ask2->private;
- ctx2->more = 1;
+ ctx2->more = more;
+
+ if (!more)
+ return err;
err = crypto_ahash_import(&ctx2->req, state);
if (err) {
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2015-11-01 9:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-25 6:26 kernel tainted while exporting shash context using af_alg interface Harsh Jain
2015-10-25 11:58 ` Stephan Mueller
2015-10-26 6:19 ` Harsh Jain
2015-10-26 9:21 ` Harsh Jain
2015-10-28 0:09 ` Stephan Mueller
2015-10-28 0:55 ` Stephan Mueller
2015-10-28 10:54 ` Harsh Jain
2015-10-28 11:23 ` Stephan Mueller
2015-10-30 8:32 ` Harsh Jain
2015-10-30 11:10 ` Stephan Mueller
2015-10-30 12:16 ` crypto: algif_hash - Only export and import on sockets with data Herbert Xu
2015-10-30 23:45 ` Stephan Mueller
2015-11-01 9:11 ` Herbert Xu [this message]
2015-11-01 11:06 ` [PATCH v2] " Stephan Mueller
2015-11-01 11:07 ` Stephan Mueller
2015-11-02 3:12 ` Herbert Xu
2015-11-05 7:42 ` Harsh Jain
2015-11-05 12:19 ` Herbert Xu
2015-11-02 5:48 ` kernel tainted while exporting shash context using af_alg interface Harsh Jain
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=20151101091119.GA3035@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=harshjain.prof@gmail.com \
--cc=linux-crypto@vger.kernel.org \
--cc=smueller@chronox.de \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox