]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
crypto: algif_skcipher - Cap recv SG list at ctx->used
authorHerbert Xu <herbert@gondor.apana.org.au>
Fri, 29 May 2020 04:54:43 +0000 (14:54 +1000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Sat, 8 Aug 2020 05:53:12 +0000 (01:53 -0400)
BugLink: https://bugs.launchpad.net/bugs/1885322
commit 7cf81954705b7e5b057f7dc39a7ded54422ab6e1 upstream.

Somewhere along the line the cap on the SG list length for receive
was lost.  This patch restores it and removes the subsequent test
which is now redundant.

Fixes: 2d97591ef43d ("crypto: af_alg - consolidation of...")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
crypto/algif_skcipher.c

index e2c8ab408bed528b3ca109add88b63f25fd0b3e1..4c3bdffe0c3a578bb49f7d51ab2ceb50655addca 100644 (file)
@@ -74,14 +74,10 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
                return PTR_ERR(areq);
 
        /* convert iovecs of output buffers into RX SGL */
-       err = af_alg_get_rsgl(sk, msg, flags, areq, -1, &len);
+       err = af_alg_get_rsgl(sk, msg, flags, areq, ctx->used, &len);
        if (err)
                goto free;
 
-       /* Process only as much RX buffers for which we have TX data */
-       if (len > ctx->used)
-               len = ctx->used;
-
        /*
         * If more buffers are to be expected to be processed, process only
         * full block size buffers.