]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
crypto: fix a memory leak in rsa-kcs1pad's encryption mode
authorDan Aloni <dan@kernelim.com>
Mon, 17 Sep 2018 17:24:32 +0000 (20:24 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 26 Nov 2019 12:16:53 +0000 (13:16 +0100)
BugLink: https://bugs.launchpad.net/bugs/1853915
[ Upstream commit 3944f139d5592790b70bc64f197162e643a8512b ]

The encryption mode of pkcs1pad never uses out_sg and out_buf, so
there's no need to allocate the buffer, which presently is not even
being freed.

CC: Herbert Xu <herbert@gondor.apana.org.au>
CC: linux-crypto@vger.kernel.org
CC: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Dan Aloni <dan@kernelim.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
crypto/rsa-pkcs1pad.c

index 2908f93c3e554482b0e4ca1d2061a9dac2910438..e8354084ef4ec64561a0a17cfea5d2fd525e054a 100644 (file)
@@ -261,15 +261,6 @@ static int pkcs1pad_encrypt(struct akcipher_request *req)
        pkcs1pad_sg_set_buf(req_ctx->in_sg, req_ctx->in_buf,
                        ctx->key_size - 1 - req->src_len, req->src);
 
-       req_ctx->out_buf = kmalloc(ctx->key_size, GFP_KERNEL);
-       if (!req_ctx->out_buf) {
-               kfree(req_ctx->in_buf);
-               return -ENOMEM;
-       }
-
-       pkcs1pad_sg_set_buf(req_ctx->out_sg, req_ctx->out_buf,
-                       ctx->key_size, NULL);
-
        akcipher_request_set_tfm(&req_ctx->child_req, ctx->child);
        akcipher_request_set_callback(&req_ctx->child_req, req->base.flags,
                        pkcs1pad_encrypt_sign_complete_cb, req);