Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10187908ybi; Wed, 24 Jul 2019 17:58:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxvb1gRkbr2NNFim2uGKNj5haWhTJfJCFOZcruOo4YTMnhBEFpLstz713et2fwxwTo5F5A X-Received: by 2002:a62:1c5:: with SMTP id 188mr13415243pfb.26.1564016300520; Wed, 24 Jul 2019 17:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564016300; cv=none; d=google.com; s=arc-20160816; b=L1vCwiwwwoZb7ajBBYmTTy4civsXixlUtDLoSYGby5K8k4wtpEOswHO45kHEbcOboS kv6FikiLmj23MMExIY/cbTktgx/6fhKF6NM5+mG5wNl0BT9TYcEvP+WN4Aq32zwEqLUk uQGOpqNIw7Eq72RldvkgTK/dtCGWzj9wgs9VNbZTvtmvWGP5omC/gqo0FLBVskWJ8Y4F vyp6em8GxJzHv4bdjNKpV2u/4/qsykMShBYGlCtykCvL5PAg97w6B8Q+fm3voGMnmoiY RqZxyWYLjHPRvh9Wm5E93EhW3Tdea5rB61F7QEYPqSmKfO3RjGZzK+7VuV4MFv3eH8ZX ZSlQ== 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=3ki6sj7z5iGzWhWPdZvDyXBHMsqdaS5ZB/oB+hvZcfY=; b=u61H+spyADAiPQIo6NHo6bcquTR/vBgeJy/SBsXcnfoCjWcmdkPmVYT0s7L9cYTsto Qa5T8nzBAPTwfUhiD7AQcKkD1lVeD1i8W/+LjxwvLDIiyUhU3PrhxUnDQQzcUq+wjAJ3 fP3aLQ8pMIVBcaoFRRhYw/LAL7ACT6mN94So5Ux6kz7R0S5n8DERyhytDStFw3h4sVFc u0aDGaxDryhhHBH1D6nXDNmR+tyTaUSVMS/iKUF4Lsl8wDQHSzmvRa3q+TyNwxHbk5jE Z9yFpPze3o/xTiwe6k/jM13wrxChz+bWP/jaIRccXTXlO2TgohsxIoz2oJVSEUwcKHbL OzFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fzJRdhcS; 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 g15si16446195pjv.54.2019.07.24.17.58.05; Wed, 24 Jul 2019 17:58:20 -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=fzJRdhcS; 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 S2388937AbfGXTfy (ORCPT + 99 others); Wed, 24 Jul 2019 15:35:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:34214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388935AbfGXTfv (ORCPT ); Wed, 24 Jul 2019 15:35:51 -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 669BE20659; Wed, 24 Jul 2019 19:35:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996950; bh=EBqIx6Rp6CJbAxEr1+pNpmdrN3ibDpdhEdKnevF9rF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fzJRdhcSFEvqacvc4ujT4eQNgxkAdnOZOaTSlBf5M9/p3omp2uRA78ux9avFJKPc8 CXlaeqKs6sHmJ5pAs1Z+XXjwy/Oml/3BCKb1MvDKt5LGDmQ7SE8Oepb9eMWCm1I/+G 65znbdXON/eDj2ZRxf0cPolj1+x9nOWmJKHH0FRI= 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 5.2 272/413] crypto: ccp - memset structure fields to zero before reuse Date: Wed, 24 Jul 2019 21:19:23 +0200 Message-Id: <20190724191755.698741421@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 @@ -622,6 +622,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; @@ -660,9 +661,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; @@ -813,6 +816,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;