diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-10 22:55:45 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-10 22:55:45 -0500 |
commit | 9399f0c51489ae8c16d6559b82a452fdc1895e91 (patch) | |
tree | f99c8140dfb98082496ea2d457f9641ca8078daa /crypto | |
parent | b0f9ca53cbb103e9240a29a974e0b6085e58f9f7 (diff) |
crypto: fix af_alg_make_sg() conversion to iov_iter
Commit 1d10eb2f156f ("crypto: switch af_alg_make_sg() to iov_iter")
broke af_alg_make_sg() and skcipher_recvmsg() in the process of moving
them to the iov_iter interfaces. The 'npages' calculation in the formar
calculated the number of *bytes* in the pages, and in the latter case
the conversion didn't re-read the value of 'ctx->used' after waiting for
it to become non-zero.
This reverts to the original code for both these cases.
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/af_alg.c | 2 | ||||
-rw-r--r-- | crypto/algif_skcipher.c | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c index eb78fe8a60c8..3e80d8b8be45 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c | |||
@@ -348,7 +348,7 @@ int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len) | |||
348 | if (n < 0) | 348 | if (n < 0) |
349 | return n; | 349 | return n; |
350 | 350 | ||
351 | npages = PAGE_ALIGN(off + n); | 351 | npages = (off + n + PAGE_SIZE - 1) >> PAGE_SHIFT; |
352 | if (WARN_ON(npages == 0)) | 352 | if (WARN_ON(npages == 0)) |
353 | return -EINVAL; | 353 | return -EINVAL; |
354 | 354 | ||
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index 37110fd68adf..6fc12c3fc4b9 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c | |||
@@ -439,14 +439,13 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock, | |||
439 | while (!sg->length) | 439 | while (!sg->length) |
440 | sg++; | 440 | sg++; |
441 | 441 | ||
442 | used = ctx->used; | 442 | if (!ctx->used) { |
443 | if (!used) { | ||
444 | err = skcipher_wait_for_data(sk, flags); | 443 | err = skcipher_wait_for_data(sk, flags); |
445 | if (err) | 444 | if (err) |
446 | goto unlock; | 445 | goto unlock; |
447 | } | 446 | } |
448 | 447 | ||
449 | used = min_t(unsigned long, used, iov_iter_count(&msg->msg_iter)); | 448 | used = min_t(unsigned long, ctx->used, iov_iter_count(&msg->msg_iter)); |
450 | 449 | ||
451 | used = af_alg_make_sg(&ctx->rsgl, &msg->msg_iter, used); | 450 | used = af_alg_make_sg(&ctx->rsgl, &msg->msg_iter, used); |
452 | err = used; | 451 | err = used; |