From patchwork Thu Apr 18 13:38:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 162485 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp761767jan; Thu, 18 Apr 2019 06:41:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0mNdrOQ+tU5SVWj7OVc6ozu27qpRuKiAi3NR7uV9XSwOYRN4HUmIE++efXQhSFwKstcf1 X-Received: by 2002:a17:902:2de4:: with SMTP id p91mr93504291plb.191.1555594872488; Thu, 18 Apr 2019 06:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555594872; cv=none; d=google.com; s=arc-20160816; b=AnQZJ/ygSsVFcyWfZeJYtb/Rr8zsYRXDdtqcP43feJSNPSeXH27c2aH9caMYakiGe0 h2Iv3Y5sX1+foHz0mcYXyFW7fczmVbFWD5Cjf0Cj0oR0gluC9dtHdTP6whvoZejbPfG6 SoTPmUQkQRvmCFNfMhxqPZUZSLIKQqZMiBz720gbiBBUDs2ucP7ywmeBsFtL/r64zplC /9B4x9wnXJGZ53cAK/2rjXH2ItMADDz3qWUOmw9R/AbOAfM2OdeWZLwxF8P8pyewuBx0 Q/VsTwvryhRq2h3ZYv2kB6lZfJKXzLQwAELRdMsMA02vPT9VEzFG+WxfygujVupnHJrT Oy+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tQv7p9q/HwVPu7wBM2A2BgXwPDsjOd1bgZbCHo0ojzM=; b=zM3XGTewA4wXJyMr3VV/TAvE37l8sLprB9THsKXK2yGXyUK+aFGMrg80iVUtaArXop CQ65UR68OFQPW+i5Ywx/Q8TgDUvWhDqLV8efYJsF4rVY3TcH83HLuocEme2xKeXpb1o5 ImIIwPzeIp1EnXtJeJOgmnUY94Yoj6srd5yka+To34fu9N3NZxPryoQ/imhRQ1739dfi EvCQok0/yimhfWcSc+gtZgC5Y5BamBo1J5E3Pnc/7Wf2CS3FGHtFruiRiYH8cts0DEEG h+RU5vz+okQjte+mcn762Cm19+ii6e9t1Yp1W6LkRBRrfG20YCwYLfyp3+lP4PSO0IQ5 13Ag== 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 z143si2486889pfc.64.2019.04.18.06.41.12; Thu, 18 Apr 2019 06:41:12 -0700 (PDT) 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 S2389387AbfDRNlL (ORCPT + 3 others); Thu, 18 Apr 2019 09:41:11 -0400 Received: from foss.arm.com ([217.140.101.70]:33644 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388582AbfDRNlK (ORCPT ); Thu, 18 Apr 2019 09:41:10 -0400 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 EC0251688; Thu, 18 Apr 2019 06:41:09 -0700 (PDT) Received: from e110176-lin.kfn.arm.com (e110176-lin.kfn.arm.com [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 809E83F5AF; Thu, 18 Apr 2019 06:41:08 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/35] crypto: ccree: zero out internal struct before use Date: Thu, 18 Apr 2019 16:38:54 +0300 Message-Id: <20190418133913.9122-20-gilad@benyossef.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418133913.9122-1-gilad@benyossef.com> References: <20190418133913.9122-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org We did not zero out the internal struct before use causing problem in some rare error code paths. Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_aead.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.21.0 diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c index ed306a612c0f..0fa676b5603c 100644 --- a/drivers/crypto/ccree/cc_aead.c +++ b/drivers/crypto/ccree/cc_aead.c @@ -2062,6 +2062,8 @@ static int cc_aead_encrypt(struct aead_request *req) struct aead_req_ctx *areq_ctx = aead_request_ctx(req); int rc; + memset(areq_ctx, 0, sizeof(*areq_ctx)); + /* No generated IV required */ areq_ctx->backup_iv = req->iv; areq_ctx->backup_giv = NULL; @@ -2091,6 +2093,8 @@ static int cc_rfc4309_ccm_encrypt(struct aead_request *req) goto out; } + memset(areq_ctx, 0, sizeof(*areq_ctx)); + /* No generated IV required */ areq_ctx->backup_iv = req->iv; areq_ctx->backup_giv = NULL; @@ -2110,6 +2114,8 @@ static int cc_aead_decrypt(struct aead_request *req) struct aead_req_ctx *areq_ctx = aead_request_ctx(req); int rc; + memset(areq_ctx, 0, sizeof(*areq_ctx)); + /* No generated IV required */ areq_ctx->backup_iv = req->iv; areq_ctx->backup_giv = NULL; @@ -2137,6 +2143,8 @@ static int cc_rfc4309_ccm_decrypt(struct aead_request *req) goto out; } + memset(areq_ctx, 0, sizeof(*areq_ctx)); + /* No generated IV required */ areq_ctx->backup_iv = req->iv; areq_ctx->backup_giv = NULL; @@ -2254,6 +2262,8 @@ static int cc_rfc4106_gcm_encrypt(struct aead_request *req) goto out; } + memset(areq_ctx, 0, sizeof(*areq_ctx)); + /* No generated IV required */ areq_ctx->backup_iv = req->iv; areq_ctx->backup_giv = NULL; @@ -2277,6 +2287,8 @@ static int cc_rfc4543_gcm_encrypt(struct aead_request *req) struct aead_req_ctx *areq_ctx = aead_request_ctx(req); int rc; + memset(areq_ctx, 0, sizeof(*areq_ctx)); + //plaintext is not encryped with rfc4543 areq_ctx->plaintext_authenticate_only = true; @@ -2309,6 +2321,8 @@ static int cc_rfc4106_gcm_decrypt(struct aead_request *req) goto out; } + memset(areq_ctx, 0, sizeof(*areq_ctx)); + /* No generated IV required */ areq_ctx->backup_iv = req->iv; areq_ctx->backup_giv = NULL; @@ -2332,6 +2346,8 @@ static int cc_rfc4543_gcm_decrypt(struct aead_request *req) struct aead_req_ctx *areq_ctx = aead_request_ctx(req); int rc; + memset(areq_ctx, 0, sizeof(*areq_ctx)); + //plaintext is not decryped with rfc4543 areq_ctx->plaintext_authenticate_only = true;