]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
crypto: ccree - only try to map auth tag if needed
authorGilad Ben-Yossef <gilad@benyossef.com>
Wed, 29 Jan 2020 14:37:55 +0000 (16:37 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 5 May 2020 10:32:22 +0000 (12:32 +0200)
BugLink: https://bugs.launchpad.net/bugs/1873481
commit 504e84abec7a635b861afd8d7f92ecd13eaa2b09 upstream.

Make sure to only add the size of the auth tag to the source mapping
for encryption if it is an in-place operation. Failing to do this
previously caused us to try and map auth size len bytes from a NULL
mapping and crashing if both the cryptlen and assoclen are zero.

Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Cc: stable@vger.kernel.org # v4.19+
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>
drivers/crypto/ccree/cc_buffer_mgr.c

index b938ceae7ae763b54e915d79dc87740ad4cdb92c..885347b5b372ab3098305e9094677187d7aa77f6 100644 (file)
@@ -1109,9 +1109,11 @@ int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req)
        }
 
        size_to_map = req->cryptlen + areq_ctx->assoclen;
-       if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT)
+       /* If we do in-place encryption, we also need the auth tag */
+       if ((areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT) &&
+          (req->src == req->dst)) {
                size_to_map += authsize;
-
+       }
        if (is_gcm4543)
                size_to_map += crypto_aead_ivsize(tfm);
        rc = cc_map_sg(dev, req->src, size_to_map, DMA_BIDIRECTIONAL,