From patchwork Sat Jan 13 21:34:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Aloni X-Patchwork-Id: 10162433 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 7AC3C6029B for ; Sat, 13 Jan 2018 21:36:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D65728AFA for ; Sat, 13 Jan 2018 21:36:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6212E28B2B; Sat, 13 Jan 2018 21:36:49 +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=-2.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, URIBL_BLACK 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 6FA5428AFA for ; Sat, 13 Jan 2018 21:36:47 +0000 (UTC) Received: (qmail 11576 invoked by uid 550); 13 Jan 2018 21:36:29 -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 11384 invoked from network); 13 Jan 2018 21:36:27 -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=CZ0qLTsu1GIxCwHT3PWSwsg7gRVVIx+ZTaFCJ0alnlk=; b=xGQ4C7AINOAEGAWPq+P5Y9l+2O6PTo6AZXy7cYQlGcOIXry9WTCtbgtH3Yd1NR4OLP Vd0SJuhTeQfSO8ZSmyfoW0i8GWwChdYxDlLe6HgYzekTGX0VO8pJHD2JdeRs9CZRaWsx HKe10Lctnkj//zGxq8GWna0+Mz5e3zw9M+pFUe616cROUeUg3QSUqfSpJ8zZQeHPs9AE ZdjHivzVZgmLaOI6uzNnt4U741+OaF+8nAepYT6vq0d+InxdsVJsDE815VfFwBvhmeS6 Jk0RpGaKfoWAaaoK6M/oIhzafGFiwX7ht9g4NvNUmNONk4zfA3oGEVxaNWD8s9vIyC69 z0WQ== 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=CZ0qLTsu1GIxCwHT3PWSwsg7gRVVIx+ZTaFCJ0alnlk=; b=BMCfPY3hqnNgD3Q2LQtg5gouSjjfuzz11FZCZa5oQ7zsHeu5hfOnNM6+VmJ0D/+kXV mqxofM7xnsv58444u+PxqgWUcJV1onSyTgQZx3k+pjoC4PhXuWtG5KwSL1qEu9u8FyH6 bBOzb9AgXtNEPQXfkf70l6eK7Vq0PWQyy4Vip/L9y3Ij2JEeRXXVa3CrqAeiT8kv4uvU PSixGps7V7jYRuS6SnXVlzi9dKKIGKdZA4d9MhbiYTVGvPDAVwFrnwB383LDSjAqJ6Kc cb/gl9ZGLBl1231f2WNeCgS7XXNfNbEiIHhiPEBzb/c5vEWc+IZphQbRGSDc3bcg3IT0 Fhlw== X-Gm-Message-State: AKwxyte/vafSRcMQNUUFYQE0eTruSibOD8Jiu0hnFLBJBKAZWJ3Ykj0k rw3HKXBO0E3E7iOn3koD4/wbeQ== X-Google-Smtp-Source: ACJfBov5SSXeudmupHwTRzhN22gekDr+YXiEmAOzKK+oKRNbtczu18MhYbJnKyX7GxIstM6Yvj9bhg== X-Received: by 10.223.139.10 with SMTP id n10mr7664531wra.23.1515879376063; Sat, 13 Jan 2018 13:36:16 -0800 (PST) From: Dan Aloni To: linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: Herbert Xu Date: Sat, 13 Jan 2018 23:34:35 +0200 Message-Id: <20180113213441.52047-2-dan@kernelim.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180113213441.52047-1-dan@kernelim.com> References: <20180113213441.52047-1-dan@kernelim.com> Subject: [kernel-hardening] [PATCHv2 1/7] crypto: fix memory leak in rsa-kcs1pad encryption X-Virus-Scanned: ClamAV using ClamSMTP 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);