Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10486576ybi; Thu, 25 Jul 2019 00:09:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCmkuIFSDmo8RlImTYkD1AmlXf1Ih/BxZfeIcfA50sy5q4joCule2nxVVAnrszbVJKA1BT X-Received: by 2002:a17:902:4222:: with SMTP id g31mr14221527pld.41.1564038578300; Thu, 25 Jul 2019 00:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564038578; cv=none; d=google.com; s=arc-20160816; b=XU6lEikD6uxv5yKWi7pVn/pdynw7wbhs/GaA/qvu3PUm9zub7Ti3Axxlyx7lHVEyAU DUIJRaSf11EntCvyp3/3Enwp+qdsP3ozcqMO8vdh7qE3or4EPz3e0plKGjjQN2jfnbUH DW8Jzv/kB66ygSlpkXMuEXO+jZOurC8FTDcxx9GHCPWHo6aCh0WiNZ61F6ItPn7u0Vg1 DqYnEG5LzlNP9/CAWtDG3IWS7+74mTlpL7a6yn/hyxyvRnyocMmSjXkyK+adANA92Bny QjjRXcqDMWNLTEdW1gsZppyV3ihjqfcw+Juf3CWRanphTs6kSxosUOz2JnWdJjnkRXXc HZIw== 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=q4Z6IfIwx4A5I1x6BMLQFZYM0HpTTQHRevVQPA0G0buJMZpuIw1JSnt2Sz8PbIUzLa h20pE5YPEmjIvRZIm3WhWx87GfSFx2UovWlDcGbwVpjT9hN/j0y0w/0qQU+XH9xU6umJ eYfEr9woQ4gff6vmdr8zUEMjnVTuU9EyLbDmecu9uFjmHpemiU0aJUu9Q9fYIb89Or3n ELAvi68kkmOXU+oS5+lplX1Q/7GmGuBEQFGWxeAvxnr5mfmet/yOo8dIE5HRnmTLxLMa 8ejHUFKBoa0LkpcsQHrJMIkBu1mcaDNK9WvYAMXUaEpqHnRLnUIKP1E896nqEGbL2+jh lNlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aJF0fg2F; 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 a14si14346533pjo.102.2019.07.25.00.09.24; Thu, 25 Jul 2019 00:09:38 -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=aJF0fg2F; 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 S2391744AbfGXTzO (ORCPT + 99 others); Wed, 24 Jul 2019 15:55:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:38658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391635AbfGXTzM (ORCPT ); Wed, 24 Jul 2019 15:55:12 -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 A39E3205C9; Wed, 24 Jul 2019 19:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998112; bh=zQcjsPz9w6oUvjkZNUWQFrnvNiX/hs4lk5lTh3MC5KQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aJF0fg2FUx5LluiJN8KhL8Dqt1Rgzv4HTEQPxRHPlBS4BhYXN23119zUeq7rvHmhM jxmLGzrWyNqhutY/dB5g8J5hPBHVvOEvy7vQ+pDpBL4M53p/wlHsyx6uS4NE8xrU69 GfAYO+4Y4k8oqndOKXy/vAFkH99HK/f2DEJ2+3YM= 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.1 248/371] crypto: ccp - memset structure fields to zero before reuse Date: Wed, 24 Jul 2019 21:20:00 +0200 Message-Id: <20190724191743.363479510@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@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;