Skip to content

Commit

Permalink
crypto: algif_skcipher - Load TX SG list after waiting
Browse files Browse the repository at this point in the history
We need to load the TX SG list in sendmsg(2) after waiting for
incoming data, not before.

Cc: [email protected]
Reported-by: Dmitry Vyukov <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Tested-by: Dmitry Vyukov <[email protected]>
  • Loading branch information
herbertx committed Jan 19, 2016
1 parent e31835a commit 4f0414e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crypto/algif_skcipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,13 +647,6 @@ static int skcipher_recvmsg_sync(struct socket *sock, struct msghdr *msg,

lock_sock(sk);
while (msg_data_left(msg)) {
sgl = list_first_entry(&ctx->tsgl,
struct skcipher_sg_list, list);
sg = sgl->sg;

while (!sg->length)
sg++;

if (!ctx->used) {
err = skcipher_wait_for_data(sk, flags);
if (err)
Expand All @@ -674,6 +667,13 @@ static int skcipher_recvmsg_sync(struct socket *sock, struct msghdr *msg,
if (!used)
goto free;

sgl = list_first_entry(&ctx->tsgl,
struct skcipher_sg_list, list);
sg = sgl->sg;

while (!sg->length)
sg++;

skcipher_request_set_crypt(&ctx->req, sg, ctx->rsgl.sg, used,
ctx->iv);

Expand Down

0 comments on commit 4f0414e

Please sign in to comment.