stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: algif_skcipher - Load TX SG list after waiting
@ 2017-10-04  1:18 Connor O'Brien
  2017-10-06  8:27 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Connor O'Brien @ 2017-10-04  1:18 UTC (permalink / raw)
  To: stable; +Cc: Herbert Xu, Connor O'Brien

From: Herbert Xu <herbert@gondor.apana.org.au>

commit 4f0414e54e4d1893c6f08260693f8ef84c929293 upstream.

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()]

Cc: stable@vger.kernel.org
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Connor O'Brien <connoro@google.com>
---
 crypto/algif_skcipher.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index fd1967ecc928..110970be0716 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -448,13 +448,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) {
 				err = skcipher_wait_for_data(sk, flags);
@@ -476,6 +469,13 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock,
 			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,
 						     ctx->iv);
-- 
2.14.2.920.gcf0c67979c-goog

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: algif_skcipher - Load TX SG list after waiting
  2017-10-04  1:18 [PATCH] crypto: algif_skcipher - Load TX SG list after waiting Connor O'Brien
@ 2017-10-06  8:27 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2017-10-06  8:27 UTC (permalink / raw)
  To: Connor O'Brien; +Cc: stable, Herbert Xu

On Tue, Oct 03, 2017 at 06:18:31PM -0700, Connor O'Brien wrote:
> From: Herbert Xu <herbert@gondor.apana.org.au>
> 
> commit 4f0414e54e4d1893c6f08260693f8ef84c929293 upstream.
> 
> 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()]

thanks for the backport, now queued up.

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-06  8:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-04  1:18 [PATCH] crypto: algif_skcipher - Load TX SG list after waiting Connor O'Brien
2017-10-06  8:27 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).