Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10436041ybi; Wed, 24 Jul 2019 23:10:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJMgRdbQy5FljNTudmomXdyOZXuR7XjBMdNQIGoV2B96/TIs8v1gBpnLUrUqtmfeOBCKS/ X-Received: by 2002:a17:902:2889:: with SMTP id f9mr84861788plb.230.1564035033090; Wed, 24 Jul 2019 23:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564035033; cv=none; d=google.com; s=arc-20160816; b=PzyqK6ubmA0Vi+LHx+O/Ozft3JMx4964tul+Tcu0bn1dNCvBjzVxR2YHQd28URMpOS /X3OpzlhXZeUCp4P2bUoHrhJduC5YHAgETzzASeZHqYOHf7iKkJ/CebAkiermnEiICI7 DgHUsMR9mKiUsuRyTPKxCBHCiMp+P20KYwgdlNyrhJTCoFPtk/80G8Ske/Zjlr+AskRA 4jO0ETINM97YlMXyWgxBnZiOYVp532cruc/80FQJXxaN1pU9xzqhlebXbXFBa0X1XAat Uh4Z2t8Dj0PwGGQYY8voP46G+H3PLmv3MH6vgnIiub5rNmsozNzR9relwqQMN5nRyiP7 mKiw== 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=Wwg2wJBxgxtnhmebBBQEumQGt6+gUOxjHaU27knUp2g=; b=OPxbiqML8KrqFlN+HVZs6c/omXa+1TGZm3HhNqRCXRgfDK7JafHTYw2pfevTlj1AQ3 NU9wOBPIRatv/txL9kJaM5Sxqy/62cYMmyvJrFrfT/pciJnAiSH75IdAi81zX7nbejh+ xpnQXqpF6g7+BHXWWvUs8mHUYiYVF4uJRVykMp0M7Dg7ytoIleFYy+Nw7uZ3KwRSNHoi zkvSAPjy3zkFGOlCYZN7TYD9MgrFYzgJAQlcBf8u5d++CXgEmUP2319dX6XMkyyAJBaj FCtIg5Ag5CpElO6/UryQayzVW1LnKukDvnZvH3f2IHr38EVIEA6iXUb8e9dyUVfbDcIb v/OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U2hiqNUj; 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 64si16412414plk.87.2019.07.24.23.10.18; Wed, 24 Jul 2019 23:10:33 -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=U2hiqNUj; 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 S1729283AbfGYFul (ORCPT + 99 others); Thu, 25 Jul 2019 01:50:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:57544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390890AbfGYFmg (ORCPT ); Thu, 25 Jul 2019 01:42:36 -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 0259B22CD3; Thu, 25 Jul 2019 05:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033355; bh=zQcjsPz9w6oUvjkZNUWQFrnvNiX/hs4lk5lTh3MC5KQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U2hiqNUjtbjYjj9taSOi3ZvxnCl51X5rm/icNev4NTm3kA+xlrjYqYEHCaAOCm5MS 9KkDXuvlJ6uTsSDVs+PAUAJk8gNvabEFd1kFcGe4p25nTJdKCVWm+Ei2DQL9U9XAYf 2ctcV4InfNyU6kuQGZUK+22G7ko8mUnJMDkj1dRU= 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.19 180/271] crypto: ccp - memset structure fields to zero before reuse Date: Wed, 24 Jul 2019 21:20:49 +0200 Message-Id: <20190724191710.565637571@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@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 @@ -625,6 +625,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; @@ -663,9 +664,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; @@ -816,6 +819,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;