Skip to content

Commit

Permalink
crypto: fix af_alg_make_sg() conversion to iov_iter
Browse files Browse the repository at this point in the history
Commit 1d10eb2 ("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>
  • Loading branch information
torvalds committed Feb 11, 2015
1 parent b0f9ca5 commit 9399f0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crypto/af_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len)
if (n < 0)
return n;

npages = PAGE_ALIGN(off + n);
npages = (off + n + PAGE_SIZE - 1) >> PAGE_SHIFT;
if (WARN_ON(npages == 0))
return -EINVAL;

Expand Down
5 changes: 2 additions & 3 deletions crypto/algif_skcipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,13 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock,
while (!sg->length)
sg++;

used = ctx->used;
if (!used) {
if (!ctx->used) {
err = skcipher_wait_for_data(sk, flags);
if (err)
goto unlock;
}

used = min_t(unsigned long, used, iov_iter_count(&msg->msg_iter));
used = min_t(unsigned long, ctx->used, iov_iter_count(&msg->msg_iter));

used = af_alg_make_sg(&ctx->rsgl, &msg->msg_iter, used);
err = used;
Expand Down

0 comments on commit 9399f0c

Please sign in to comment.