From 9da9aa7fa8266de554e6b579fd95fa5348235008 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 30 Jan 2018 13:03:00 +0530 Subject: [PATCH] crypto: algif_skcipher - Load TX SG list after waiting We need to load the TX SG list in sendmsg(2) after waiting for incoming data, not before. connoro@google.com: backport to 3.18,where the relevant logic is located in skcipher_recvmsg() rather than skcipher_recvmsg_sync() Change-Id: I4e18b385fe50c844cd62a2eb20122036ea4dfe09 Git-commit: 36c84b22ac8aa041cbdfbe48a55ebb32e3521704 Git-repo: https://android.googlesource.com/kernel/common.git Reported-by: Dmitry Vyukov Signed-off-by: Herbert Xu Tested-by: Dmitry Vyukov Signed-off-by: Connor O'Brien Signed-off-by: Greg Kroah-Hartman Signed-off-by: Kishor PK --- crypto/algif_skcipher.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index 83187f497c7c..9b3b806fae52 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c @@ -441,12 +441,6 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock, char __user *from = iov->iov_base; while (seglen) { - sgl = list_first_entry(&ctx->tsgl, - struct skcipher_sg_list, list); - sg = sgl->sg; - - while (!sg->length) - sg++; used = ctx->used; if (!used) { @@ -468,6 +462,12 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock, err = -EINVAL; if (!used) goto free; + sgl = list_first_entry(&ctx->tsgl, + struct skcipher_sg_list, list); + sg = sgl->sg; + + while (!sg->length) + sg++; ablkcipher_request_set_crypt(&ctx->req, sg, ctx->rsgl.sg, used,