Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp12836483pxu; Sat, 2 Jan 2021 13:27:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJws+8opu35nVvP3KvVZMe8YeEdddTMusPQeK6IDD1fDodUbc8HX7tW4XIR3WjZuc00uGNE2 X-Received: by 2002:a17:906:451:: with SMTP id e17mr59589824eja.228.1609622834340; Sat, 02 Jan 2021 13:27:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609622834; cv=none; d=google.com; s=arc-20160816; b=R2S9Nxlg0uCbXX25bbVaNwlNUWCpKiM6xeB33ukXz5t3tkyeB/Z+sd0NID/JhjwHSk PoiUL8aC3B+PXOHZNiZl5v3erdgvQSR52INRBGFKo43LonZ9FPag+MGHXXfelLcbGTpK mVRtUrkno3TutbmEskmE63lvhS2JZELhU1uL1tw5O8YQSWN9DYQbTUKPth7JsP1Nnqyk wB2fJwgXHn/qoR7ivtUnb+Rk1cOrxcTtExqxcZonhegI6KSRpXmHYsnqOqQNAaX9Ck0d rb4Yw35qDBV4C90mX0KJsztQaw45DF9EwazuGayE6nrYimecF7i+IFIL5PY162zaKFhP IfJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=+EV8TcAqEBUkr7buIPeI/qAlxaJPi3Cds3bsO1TbBFA=; b=RML1fc7qricZISWqQf81MtzLpCnAZ5byytoFJ4Q99v8Oq7GtUnBIoLAGXOTCXHJI69 jKoUayzO7yMGhtHQgO2G4nfql3nSKTtThRC2GZoD0bykUSQoX7POD4XTiNcKq9xgV5Hl Ger7ZW/AVD+32SXERNGIN+BqDrt7Hd11S0SPXSZzo/hfKrYPdLAiOruqPoNR2ctvo8N/ liav31ZQ3Qcf/8yjvocdxUsUFwwlHm2YeA79jNFYsNtIW5IdlevcNEyVHNSSWC/qwWf8 5rfEg56Va44K9QHBhGw2ytKxf36JetLWA59wvcWLizES1+iU+quPbMN7DA/vZqxRotCE 3OEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si27932944edt.581.2021.01.02.13.26.54; Sat, 02 Jan 2021 13:27:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726689AbhABVZz (ORCPT + 99 others); Sat, 2 Jan 2021 16:25:55 -0500 Received: from helcar.hmeau.com ([216.24.177.18]:37128 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbhABVZz (ORCPT ); Sat, 2 Jan 2021 16:25:55 -0500 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.103.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1kvoOT-00009r-DV; Sun, 03 Jan 2021 08:25:02 +1100 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Sun, 03 Jan 2021 08:25:01 +1100 Date: Sun, 3 Jan 2021 08:25:01 +1100 From: Herbert Xu To: Thara Gopinath Cc: davem@davemloft.net, bjorn.andersson@linaro.org, ebiggers@google.com, ardb@kernel.org, sivaprak@codeaurora.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/6] drivers: crypto: qce: sha: Restore/save sha1_state/sha256_state with qce_sha_reqctx in export/import Message-ID: <20210102212501.GA1931@gondor.apana.org.au> References: <20201219033027.3066042-1-thara.gopinath@linaro.org> <20201219033027.3066042-2-thara.gopinath@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201219033027.3066042-2-thara.gopinath@linaro.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, Dec 18, 2020 at 10:30:22PM -0500, Thara Gopinath wrote: > Export and import interfaces save and restore partial transformation > states. The partial states were being stored and restored in struct > sha1_state for sha1/hmac(sha1) transformations and sha256_state for > sha256/hmac(sha256) transformations.This led to a bunch of corner cases > where improper state was being stored and restored. A few of the corner > cases that turned up during testing are: > > - wrong byte_count restored if export/import is called twice without h/w > transaction in between > - wrong buflen restored back if the pending buffer > length is exactly the block size. > - wrong state restored if buffer length is 0. > > To fix these issues, save and restore the entire qce_sha_rctx structure > instead of parts of it in sha1_state and sha256_state structures. > This in turn simplifies the export and import apis. > > Signed-off-by: Thara Gopinath > --- > drivers/crypto/qce/sha.c | 93 ++++------------------------------------ > 1 file changed, 8 insertions(+), 85 deletions(-) How is this safe when the reqctx structure contains pointers? Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt