From patchwork Tue Nov 7 09:39:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 118128 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3757028qgn; Tue, 7 Nov 2017 01:40:27 -0800 (PST) X-Google-Smtp-Source: ABhQp+SB92izkuLgUeSatiZ+0s0IW8exnMjFRd72rF6qq00P7de7HaWzEHAtOS3BAnSJQQuGrnDt X-Received: by 10.84.241.5 with SMTP id a5mr16934282pll.81.1510047627832; Tue, 07 Nov 2017 01:40:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510047627; cv=none; d=google.com; s=arc-20160816; b=HGwuJvzAmIIYaxXmInWMyPt3+OxyOPn/uEEsyblnUJOc3uxTH2EqReYHTSulX1pBy5 Jdq4YwVBsltqmuqI6yAjtH/ntP85trDjaYAYYBJRm4YhEbH7X7USIyi5ZZ6w7QUj0QG/ Ol2SKvse/af7zHarDUW8YPM7QVkbpKfHG0+VsJaWpaqtcCQRjOr2Lwr5YaVRI2+yXVh6 RAO6cd8CTyGwlu7Pe74YD2SfxPyAYj9DdVRoRq/82NJ+5LhSQwrsc+YUJWzahIKSc0C1 tVTakwL1w/YPaPJ64DNwu/tHvTcrv4AEIgSL3gwCX5BB2Yv0/+SgGOvQNsAlALSzrEfu qGIw== 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=V1aLQJ1FHFs+zSxrFBsGaR8L9yMAfcNKHFvhK7ExjhQ=; b=nFMph2mC4mOT1kNloTwmLqWgFdkPGGG14aWDw8m+932rKeI+RnfYFryKosJ77QaAyE a6OLf/M4ABi0Qy4mTTJ+z+ZnrPAWYEfzxU3gwE2ioxhNh1wyohpLf+qXqupU0ecszZga YUCbOASe92Y0/pCEelNOlYcAi97JmPvVLwBFeCR/0toGIdhD7edwAWF7aU566X/LSmwh QJrc7vDDgJ8oFczL1cXerBqBLoDOlYj12kJ6r/2OD+QNjCmoSPBrJoDVVB1Pcs3uzSUg B9jN2WwOpL2BEQeupyvHlb4AL6yNZjarKm/QQI8pQtBiDTZOyRZvOeIfHqcOwj044YNh TmMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 r63si752935plb.638.2017.11.07.01.40.27; Tue, 07 Nov 2017 01:40:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756648AbdKGJkZ (ORCPT + 9 others); Tue, 7 Nov 2017 04:40:25 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:46336 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933035AbdKGJkW (ORCPT ); Tue, 7 Nov 2017 04:40:22 -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 609D41435; Tue, 7 Nov 2017 01:40:22 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 754813F220; Tue, 7 Nov 2017 01:40:20 -0800 (PST) From: Gilad Ben-Yossef To: Greg Kroah-Hartman Cc: Ofir Drang , stable , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] staging: ccree: fix leak of import() after init() Date: Tue, 7 Nov 2017 09:39:57 +0000 Message-Id: <1510047606-5589-2-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510047606-5589-1-git-send-email-gilad@benyossef.com> References: <1510047606-5589-1-git-send-email-gilad@benyossef.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org crypto_ahash_import() may be called either after crypto_ahash_init() or without such call. Right now we always internally call init() as part of import(), thus leaking memory and mappings if the user has already called init() herself. Fix this by only calling init() internally if the state is not already initialized. Fixes: commit 454527d0d94f ("staging: ccree: fix hash import/export") Cc: stable Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_hash.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index d79090e..1799d3f 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -1778,9 +1778,12 @@ static int ssi_ahash_import(struct ahash_request *req, const void *in) } in += sizeof(u32); - rc = ssi_hash_init(state, ctx); - if (rc) - goto out; + /* call init() to allocate bufs if the user hasn't */ + if (!state->digest_buff) { + rc = ssi_hash_init(state, ctx); + if (rc) + goto out; + } dma_sync_single_for_cpu(dev, state->digest_buff_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL);