From patchwork Sat Dec 30 17:58:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Aloni X-Patchwork-Id: 10137853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AB20A60375 for ; Sat, 30 Dec 2017 17:58:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C9AF287A3 for ; Sat, 30 Dec 2017 17:58:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9189C287B5; Sat, 30 Dec 2017 17:58:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id B3478287A2 for ; Sat, 30 Dec 2017 17:58:38 +0000 (UTC) Received: (qmail 14287 invoked by uid 550); 30 Dec 2017 17:58:23 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 14110 invoked from network); 30 Dec 2017 17:58:21 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernelim-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PhJaLHC0QL9q8dKi8dR1jMrBCTGxyt2XdenqZvcO944=; b=MMQde0dq028rp65zAghtbB2Up654TeyXnAZJoNM7QusjqWFbHbrj1ypo22uvyakb3e YonpoVkQWQhi+qxSfSzVZjYvLBLUaw9wEGHNJ9hIB7JyHCo4IYRQj1LGYsdfsK4Ojpsz 1V04dNEiAR4dnCYiXDluWuApSJoKKStZ9e6k7bsUCmVxLCxi5g+wicbRBOr5P1lTxlnq vhfuMPnHmFAbeENB7klOSrDnJuLwn2I0m6qGF0FFdzhUs1OzfF+No8nKDiznA6lTckfs WfDnV6eSLsL53BS7P2JETEH8A7YpDBEz8Uq1fK5AsHuNiGz/omep+iGx1I/QYbunHsOT Yldg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PhJaLHC0QL9q8dKi8dR1jMrBCTGxyt2XdenqZvcO944=; b=QuLBeusl8x+B+bEs+fIsGAd9t7z34xOlkhhzzFCZ7/I6yGnmcTA7RiVGaCF2YhpUCD I9vwr0SofNwFrgidYw6WoMM48SUu2JQzTYLq35vWIHeAHJBw9d2b2D1X6jLvY1UBwSvo zMVbud7r9M2kh9zQnIfpFBIuIpkmiM0Er75XrTFTbgZ5rdWK7f1SyN9Nr0gsidYsw8Oi cj0s5aFIhYRw2+LitOTMjW7+YJyWcOnDFy/3cSvTDfDuYf/ykF37ux8eI+XNtNQL035v NLqbhpMbs/4oPK3Qo6bI23otgMm/FZDH0VqQdOLq2R2MKSgWGAKZGuxk2SvZmsjOcbmy TCeg== X-Gm-Message-State: AKGB3mJuIEQ2nm0cnAEp1OJovsxCazOMlQVHLgP4lXanT8xIZhnKwd02 JdNIOOT8crsHuYw+HOc0XIuvIA== X-Google-Smtp-Source: ACJfBovepYcH9fXyKfHKF9Zs30cCAmfO5S0wY3h/QOg1f4rQBr6bm6/pELYxwSXCoYM04goLRtarCg== X-Received: by 10.28.239.4 with SMTP id n4mr33526035wmh.31.1514656690070; Sat, 30 Dec 2017 09:58:10 -0800 (PST) From: Dan Aloni X-Google-Original-From: Dan Aloni To: linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: Dan Aloni , Herbert Xu Date: Sat, 30 Dec 2017 19:58:00 +0200 Message-Id: <20171230175804.7354-2-alonid@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171230175804.7354-1-alonid@gmail.com> References: <20171230175804.7354-1-alonid@gmail.com> Subject: [kernel-hardening] [PATCH 1/5] crypto: fix memory leak in rsa-kcs1pad encryption X-Virus-Scanned: ClamAV using ClamSMTP From: Dan Aloni 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 Signed-off-by: Dan Aloni --- crypto/rsa-pkcs1pad.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c index 2908f93c3e55..e8354084ef4e 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);