Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3785843ybi; Mon, 29 Jul 2019 12:35:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxEJ/jIStWr7AJCnzHFNc13kWXD0Ro82OC5rWib5RJq1C5/Rz2ZSMqKHL9Gj30KVROBJEL X-Received: by 2002:a62:16:: with SMTP id 22mr39563498pfa.151.1564428918723; Mon, 29 Jul 2019 12:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428918; cv=none; d=google.com; s=arc-20160816; b=vMlPIe6doR85H1w8A0cg2giB7vjOe9BfRn6zgDeja6AgNpDp5lwbxMYYu9enNDXWo+ A56pPzgmu1osmkTWAG4wRdaBu9CagTnVtDmh57QsjS9afi3fj3vPR5sTh9HvDbuUzJqp HFQtggEt/D7jbtlmwrSyDFocVWSpJn/1fEhlcBWk9gBp6GiRd7Hto16IsCC4mJt82xEd Y/kMDFOsYpa+FvD5gwlJENSt0FlmGRz4MyBStD6MF7MfeK1dV054uk4nCu+sfjDmb0hS jyjQBJ6LlcutKXbeQTwAL2YsypO8lXnxwm8L83+k3T/F1V1YaY8SxJXgKTBwugOaxj4K UNQQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xoqHyi63EMf3tuly/JLcHFd+zmNOSpV1MGuzLujmpuM=; b=qrY4Ep68SjojOe8o7fhg4JpNGW1ddP0nTX6dp5d63o1TCUs7OlUMP42+RhSnUqhr9O xFpeO9Xkjdv6xWWZszN1O9mowPUbjTjaH1hxbIx1r+VKRA12UhrPfEht75n/fYl3CKrl vwRBfQ3KVXBc7U1qo/58xIenLOQnkyATkHDnTJMXYBp+d7ZEu+QWD2gqQrr9dtva2RFR pLbyLBoTrUg1d4lqYanpKS+53HpCqsByrrTUsvs0Mh6xkJOLBzqIsz+g0CULDewwubPW 0Bk+cxqtaiE690a2eapXXNP5ofcizMCVb5q3D4xNwdMnjLCH8xLCT/y6QPe5QM+Z+ui8 ffdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oLvRsCeV; 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 23si18963679pgh.298.2019.07.29.12.35.03; Mon, 29 Jul 2019 12:35:18 -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; dkim=pass header.i=@kernel.org header.s=default header.b=oLvRsCeV; 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 S1730118AbfG2T3w (ORCPT + 99 others); Mon, 29 Jul 2019 15:29:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:42518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728828AbfG2T3u (ORCPT ); Mon, 29 Jul 2019 15:29:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 57CF621655; Mon, 29 Jul 2019 19:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428589; bh=rEXX59c7Rsq38IWTPHKRNw6o8S78//6z/w9uAWHg0lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oLvRsCeV9JA59m1eGWGH4WfXzc0VoADwGzOBTwlZeVHaT1R1uVonhuOBN/2RMx/Mo S3n7KWXUbWbcqJ6QLvPjp9gaOyORzgGu9eYDSSfwyAS2bU8n9zIAi8W4nSc8MCtosc T7zBrlEk4i3zQf2Whjb00+V2Ya+9mFoTEXC2cLdo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gary R Hook , Herbert Xu Subject: [PATCH 4.14 124/293] crypto: ccp - memset structure fields to zero before reuse Date: Mon, 29 Jul 2019 21:20:15 +0200 Message-Id: <20190729190834.086896039@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hook, Gary commit 20e833dc36355ed642d00067641a679c618303fa upstream. The AES GCM function reuses an 'op' data structure, which members contain values that must be cleared for each (re)use. This fix resolves a crypto self-test failure: alg: aead: gcm-aes-ccp encryption test failed (wrong result) on test vector 2, cfg="two even aligned splits" Fixes: 36cf515b9bbe ("crypto: ccp - Enable support for AES GCM on v5 CCPs") Cc: Signed-off-by: Gary R Hook Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccp/ccp-ops.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/drivers/crypto/ccp/ccp-ops.c +++ b/drivers/crypto/ccp/ccp-ops.c @@ -612,6 +612,7 @@ static int ccp_run_aes_gcm_cmd(struct cc unsigned long long *final; unsigned int dm_offset; + unsigned int jobid; unsigned int ilen; bool in_place = true; /* Default value */ int ret; @@ -650,9 +651,11 @@ static int ccp_run_aes_gcm_cmd(struct cc p_tag = scatterwalk_ffwd(sg_tag, p_inp, ilen); } + jobid = CCP_NEW_JOBID(cmd_q->ccp); + memset(&op, 0, sizeof(op)); op.cmd_q = cmd_q; - op.jobid = CCP_NEW_JOBID(cmd_q->ccp); + op.jobid = jobid; op.sb_key = cmd_q->sb_key; /* Pre-allocated */ op.sb_ctx = cmd_q->sb_ctx; /* Pre-allocated */ op.init = 1; @@ -797,6 +800,13 @@ static int ccp_run_aes_gcm_cmd(struct cc final[0] = cpu_to_be64(aes->aad_len * 8); final[1] = cpu_to_be64(ilen * 8); + memset(&op, 0, sizeof(op)); + op.cmd_q = cmd_q; + op.jobid = jobid; + op.sb_key = cmd_q->sb_key; /* Pre-allocated */ + op.sb_ctx = cmd_q->sb_ctx; /* Pre-allocated */ + op.init = 1; + op.u.aes.type = aes->type; op.u.aes.mode = CCP_AES_MODE_GHASH; op.u.aes.action = CCP_AES_GHASHFINAL; op.src.type = CCP_MEMTYPE_SYSTEM;