crypto: algif_skcipher - sendmsg SG marking is off by one
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 19 Jan 2016 13:23:57 +0000 (21:23 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 20 Jan 2016 13:15:45 +0000 (21:15 +0800)
We mark the end of the SG list in sendmsg and sendpage and unmark
it on the next send call.  Unfortunately the unmarking in sendmsg
is off-by-one, leading to an SG list that is too short.

Fixes: 0f477b655a52 ("crypto: algif - Mark sgl end at the end of data")
Cc: stable@vger.kernel.org
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/algif_skcipher.c

index df86fb47c3ae814f8243279d33698bc336425530..a81c10faf9c4ea75e5d366e0bdf878b221cdd0a0 100644 (file)
@@ -392,7 +392,8 @@ static int skcipher_sendmsg(struct socket *sock, struct msghdr *msg,
 
                sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list);
                sg = sgl->sg;
 
                sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list);
                sg = sgl->sg;
-               sg_unmark_end(sg + sgl->cur);
+               if (sgl->cur)
+                       sg_unmark_end(sg + sgl->cur - 1);
                do {
                        i = sgl->cur;
                        plen = min_t(size_t, len, PAGE_SIZE);
                do {
                        i = sgl->cur;
                        plen = min_t(size_t, len, PAGE_SIZE);