Return-Path: Received: from mail-by2nam01on0139.outbound.protection.outlook.com ([104.47.34.139]:60384 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754806AbeARVA2 (ORCPT ); Thu, 18 Jan 2018 16:00:28 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: "Wang, Rui Y" , Herbert Xu , Sasha Levin Subject: [added to the 4.1 stable tree] crypto: ghash-clmulni - Fix load failure Date: Thu, 18 Jan 2018 20:59:50 +0000 Message-ID: <20180118205908.3220-50-alexander.levin@microsoft.com> References: <20180118205908.3220-1-alexander.levin@microsoft.com> In-Reply-To: <20180118205908.3220-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: "Wang, Rui Y" This patch has been added to the stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 3a020a723c65eb8ffa7c237faca26521a024e582 ] ghash_clmulni_intel fails to load on Linux 4.3+ with the following message: "modprobe: ERROR: could not insert 'ghash_clmulni_intel': Invalid argument" After 8996eafdc ("crypto: ahash - ensure statesize is non-zero") all ahash drivers are required to implement import()/export(), and must have a non- zero statesize. This patch has been tested with the algif_hash interface. The calculated digest values, after several rounds of import()s and export()s, match those calculated by tcrypt. Signed-off-by: Rui Wang Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- arch/x86/crypto/ghash-clmulni-intel_glue.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/g= hash-clmulni-intel_glue.c index daf8d2b9a217..b7ef6e202bb7 100644 --- a/arch/x86/crypto/ghash-clmulni-intel_glue.c +++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c @@ -219,6 +219,29 @@ static int ghash_async_final(struct ahash_request *req= ) } } =20 +static int ghash_async_import(struct ahash_request *req, const void *in) +{ + struct ahash_request *cryptd_req =3D ahash_request_ctx(req); + struct shash_desc *desc =3D cryptd_shash_desc(cryptd_req); + struct ghash_desc_ctx *dctx =3D shash_desc_ctx(desc); + + ghash_async_init(req); + memcpy(dctx, in, sizeof(*dctx)); + return 0; + +} + +static int ghash_async_export(struct ahash_request *req, void *out) +{ + struct ahash_request *cryptd_req =3D ahash_request_ctx(req); + struct shash_desc *desc =3D cryptd_shash_desc(cryptd_req); + struct ghash_desc_ctx *dctx =3D shash_desc_ctx(desc); + + memcpy(out, dctx, sizeof(*dctx)); + return 0; + +} + static int ghash_async_digest(struct ahash_request *req) { struct crypto_ahash *tfm =3D crypto_ahash_reqtfm(req); @@ -288,8 +311,11 @@ static struct ahash_alg ghash_async_alg =3D { .final =3D ghash_async_final, .setkey =3D ghash_async_setkey, .digest =3D ghash_async_digest, + .export =3D ghash_async_export, + .import =3D ghash_async_import, .halg =3D { .digestsize =3D GHASH_DIGEST_SIZE, + .statesize =3D sizeof(struct ghash_desc_ctx), .base =3D { .cra_name =3D "ghash", .cra_driver_name =3D "ghash-clmulni", --=20 2.11.0