From patchwork Tue Nov 19 05:20:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 11250847 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C305914C0 for ; Tue, 19 Nov 2019 05:55:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B03021783 for ; Tue, 19 Nov 2019 05:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574142936; bh=yNy5f3Bw3KkD7wJrL+SQzTMJT5C/90GVEYL0GQQQ3zg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=h3T9KnDCXDj2VC62RApgxldH0y8w4ElpjyblbFHtnwmO2Khk1v333eKhqg9sJODk/ NehbcTBJq7JhtgVRw1PVw/H8uCmFC9KSBgQBYiRquvCti7dEpk1SrCC7eS/ANBZKbm UgQjo3ST2mrf7nqf0r25wazocxSJsrbPTkeS45OU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732232AbfKSFzJ (ORCPT ); Tue, 19 Nov 2019 00:55:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:53486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731923AbfKSFzJ (ORCPT ); Tue, 19 Nov 2019 00:55:09 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 56081218BA; Tue, 19 Nov 2019 05:55:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574142908; bh=yNy5f3Bw3KkD7wJrL+SQzTMJT5C/90GVEYL0GQQQ3zg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LfTy4Nym9DwORzED7uuOIHREOeQMUSDuY1lU7sFC0PDeSUXybmiL8EHbYZeGndnEr 05WswyEckWBdzjfmcVODurGxqN6yJ1NRrsLEDQNAjWDH5RgDyNfFFCFoWq19tSz5/G KL6Wpx7sMKsY2S6w8XNO2iZ0yvrG5jkDE5QH5h9w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, "David S. Miller" , Dan Aloni , Sasha Levin Subject: [PATCH 4.14 216/239] crypto: fix a memory leak in rsa-kcs1pads encryption mode Date: Tue, 19 Nov 2019 06:20:16 +0100 Message-Id: <20191119051339.185883486@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051255.850204959@linuxfoundation.org> References: <20191119051255.850204959@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Dan Aloni [ 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 CC: linux-crypto@vger.kernel.org CC: "David S. Miller" Signed-off-by: Dan Aloni Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- crypto/rsa-pkcs1pad.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c index 407c64bdcdd9a..3279b457c4ede 100644 --- a/crypto/rsa-pkcs1pad.c +++ b/crypto/rsa-pkcs1pad.c @@ -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);