diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2014-11-27 09:38:12 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-11-28 10:33:18 -0500 |
commit | 1e104f9a251b46787c3efc2bc9c8c496dead294b (patch) | |
tree | 1fb643e0ec624eb1e2145a6411407f8d27a4e4ce /crypto | |
parent | 421d82f5b3e75f94e31875e37d45cdf6a557c120 (diff) |
crypto: algif_skcipher - Fixed blocking recvmsg
As most (all?) users of algif_skcipher are single-threaded and
therefore always write before reading from an algif_skcipher
socket, they never block and exercise that code-path.
It turns out that code path doesn't even work because we never
reload ctx->used after waking up so we never even see the new
data and immediately return an error (and a loud WARN_ON).
This patch fixes this by always reloading ctx->used.
Reported-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Stephan Mueller <smueller@chronox.de>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/algif_skcipher.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index 34389964000d..f80e652ef0d0 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c | |||
@@ -448,14 +448,13 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock, | |||
448 | while (!sg->length) | 448 | while (!sg->length) |
449 | sg++; | 449 | sg++; |
450 | 450 | ||
451 | used = ctx->used; | 451 | if (!ctx->used) { |
452 | if (!used) { | ||
453 | err = skcipher_wait_for_data(sk, flags); | 452 | err = skcipher_wait_for_data(sk, flags); |
454 | if (err) | 453 | if (err) |
455 | goto unlock; | 454 | goto unlock; |
456 | } | 455 | } |
457 | 456 | ||
458 | used = min_t(unsigned long, used, seglen); | 457 | used = min_t(unsigned long, ctx->used, seglen); |
459 | 458 | ||
460 | used = af_alg_make_sg(&ctx->rsgl, from, used, 1); | 459 | used = af_alg_make_sg(&ctx->rsgl, from, used, 1); |
461 | err = used; | 460 | err = used; |