Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp604820yba; Thu, 18 Apr 2019 06:42:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxX/fTsX46mdhyVS0LRby92ePckeEkO+4RP7/lbIVU4yegFR0NpJnykKKvZ+kC0dA5RhYe0 X-Received: by 2002:a63:1e04:: with SMTP id e4mr4046004pge.191.1555594978590; Thu, 18 Apr 2019 06:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555594978; cv=none; d=google.com; s=arc-20160816; b=N8txTueB1tRUoBoxWnFRArP0tw1W9ZJjYaP1fPFv7QNfoDIKnADMTjqLfh7PrEZ/oZ ueYhxQKmjIEaPR1yiRmWQU2uQkz2SjbdzTCIBQtbxyHTLQ4EgSQiQRnIoAFgoO6oNfDW f6cRanFsMGFRl8+fy4K6bYiXSdZz40mtV8+Q+HTpDBb5T+y090JBzq5TW1JX5aG8lm+B xSiwUAd4oILmOSlbCQgT8ROqHomt3xakDx8O7QemO5ZQXgIh0P+EiZUDnrRW/mXgwZnR TtWrHcKu7jWBCqRsSOBqjyJVPs7SrErR4E6XNv3emFWhf9a2lKJrzXoIHNrEz7gYql23 bGjA== 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=K1dfnp583HvN1MOtTJjPSFRS9upCK7FmVQjgXWnP6k182OKUB6rJhYZpk4IGnx6SBS C5sipzuTjF4HbGOISKMLNiHD2snQootkVZh1lN8I3sE4SqnVVd8BZuCU6ch5DlxGCK+e eulrTqFp+pGeWzhBMKyXYysGEaXV+j4Ceu9V+rw7KR9Id7Fu/gEE2a7Nb7HyJc7m7oX1 wGsvB2u+jwtbJ9X4dbhP0TXtXSGyYKyO7Bed/7guKjmR2eR8PvjZG2vHmU4wyQfM/di5 1NX4SFgWXwBXZCnAa84PUkiEzDxBD3HQDpd8lM5ftyGxvsGnyFnHzgZCeo3IPdAMx88f EAgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 n80si2293808pfb.169.2019.04.18.06.42.43; Thu, 18 Apr 2019 06:42:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389394AbfDRNlM (ORCPT + 99 others); Thu, 18 Apr 2019 09:41:12 -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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(+) 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; -- 2.21.0