From patchwork Wed Jan 3 13:35:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 123309 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp10181812qgn; Wed, 3 Jan 2018 05:38:06 -0800 (PST) X-Google-Smtp-Source: ACJfBovXFrn/28MoxttMx8qrFjfbD6peEijnH16s0M2VvGdkrYJt6NrUyql9FrJPSvLSmYDxzuK2 X-Received: by 10.159.249.6 with SMTP id bf6mr1421941plb.145.1514986686033; Wed, 03 Jan 2018 05:38:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514986686; cv=none; d=google.com; s=arc-20160816; b=WUDlJTuMTH0Qjtk+z7GfRaKhFHbBRF3USwHYKCNxiYT7pTDDg1SVnnnWuRatM/2Qll sR257cKymt8IptR49CRihwl2ACW5w2frDkyL04y1PYJOHVJXhy2C/xNdR7kpTsT0en3h kjgokITgsu01+8v+ZDwf7dm+A3UI8Pkl0dbBguTB0LASQnBLGaI7VV105m3alnlWMJJU F2MB5PUOseOSxFipyvJ0sWdZSiNRtS2YKz+uzKEqr7+qyBAq9EPZAWNLqDhhw9fT6gCK IW7CUVx+g8CGUeBEJweH6L9ugqKYd6058JytSyqPysKVnCNCTdmoydPSxejp547THg3+ QMuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Exw85/BdUGFazMfXKXPc69+KNP54hD16VX9/j7ZQPGs=; b=0HlUeHXJLLuv6p0uvU4iYJhpc52k2Zcjc/rx3yk2E1uySFNOyecppDbSEFgb1+TsPz EjJl6O4TIGJfrJKq8aRzXTaCvur7NQaQQVkDvgEjEmfDM5hMOLLxOyYQgTQ8PkCceXdN /XSGd7ZCddOEZqCaebXLvSlXtLOj5vosHHva8iMVgPSb6uIGN/2bKzsH6WWs6JS5Qow5 294t3tcG1jwXn/jLxvSQiATBk6YMOFiBT+pnp044ETc4gRt0dJAo4ZqmAXfLadjpYBYo eYStj5CEO3BE/Mw4uHZnPsFy2zQZsPvn5F19ZhvOzLp4Hvdak87I0newEGo0uhMRdDiu oDGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k8si652844pgf.107.2018.01.03.05.38.05; Wed, 03 Jan 2018 05:38:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752512AbeACNiE (ORCPT + 1 other); Wed, 3 Jan 2018 08:38:04 -0500 Received: from foss.arm.com ([217.140.101.70]:50106 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752026AbeACNiC (ORCPT ); Wed, 3 Jan 2018 08:38:02 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 53CBE1529; Wed, 3 Jan 2018 05:38:02 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 90DBB3F24A; Wed, 3 Jan 2018 05:38:00 -0800 (PST) From: Gilad Ben-Yossef To: Greg Kroah-Hartman Cc: Ofir Drang , stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org Subject: [PATCH v2 11/27] stating: ccree: revert "staging: ccree: fix leak of import() after init()" Date: Wed, 3 Jan 2018 13:35:18 +0000 Message-Id: <1514986544-5888-12-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514986544-5888-1-git-send-email-gilad@benyossef.com> References: <1514986544-5888-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This reverts commit c5f39d07860c ("staging: ccree: fix leak of import() after init()") and commit aece09024414 ("staging: ccree: Uninitialized return in ssi_ahash_import()"). This is the wrong solution and ends up relying on uninitialized memory, although it was not obvious to me at the time. Cc: stable@vger.kernel.org Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_hash.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index ffcd1f0..e05c87d 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -1673,7 +1673,7 @@ static int cc_hash_import(struct ahash_request *req, const void *in) struct device *dev = drvdata_to_dev(ctx->drvdata); struct ahash_req_ctx *state = ahash_request_ctx(req); u32 tmp; - int rc = 0; + int rc; memcpy(&tmp, in, sizeof(u32)); if (tmp != CC_EXPORT_MAGIC) { @@ -1682,12 +1682,9 @@ static int cc_hash_import(struct ahash_request *req, const void *in) } in += sizeof(u32); - /* call init() to allocate bufs if the user hasn't */ - if (!state->digest_buff) { - rc = cc_hash_init(req); - if (rc) - goto out; - } + rc = cc_hash_init(req); + if (rc) + goto out; dma_sync_single_for_cpu(dev, state->digest_buff_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL);