* [PATCH 0/2] crypto: Fix driver load failure
@ 2015-11-29 14:45 Rui Wang
2015-11-29 14:45 ` [PATCH 1/2] crypto: ghash-clmulni - Fix " Rui Wang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Rui Wang @ 2015-11-29 14:45 UTC (permalink / raw)
To: herbert; +Cc: ying.huang, linux-crypto, linux-kernel, rui.y.wang
ghash_clmulni_intel fails to load on Linux 4.3+ with the following message:
"modprobe: ERROR: could not insert 'ghash_clmulni_intel': Invalid argument"
These two patches need to go together, for the driver to load correctly.
Rui Wang (2):
crypto: ghash-clmulni - Fix load failure
crypto: cryptd - Assign statesize properly
arch/x86/crypto/ghash-clmulni-intel_glue.c | 26 ++++++++++++++++++++++++++
crypto/cryptd.c | 1 +
2 files changed, 27 insertions(+)
--
1.8.5.2
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/2] crypto: ghash-clmulni - Fix load failure 2015-11-29 14:45 [PATCH 0/2] crypto: Fix driver load failure Rui Wang @ 2015-11-29 14:45 ` Rui Wang 2015-11-29 14:45 ` [PATCH 2/2] crypto: cryptd - Assign statesize properly Rui Wang 2015-12-04 14:41 ` [PATCH 0/2] crypto: Fix driver load failure Herbert Xu 2 siblings, 0 replies; 4+ messages in thread From: Rui Wang @ 2015-11-29 14:45 UTC (permalink / raw) To: herbert; +Cc: ying.huang, linux-crypto, linux-kernel, rui.y.wang 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 <rui.y.wang@intel.com> --- 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/ghash-clmulni-intel_glue.c index 440df0c..a69321a 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) } } +static int ghash_async_import(struct ahash_request *req, const void *in) +{ + struct ahash_request *cryptd_req = ahash_request_ctx(req); + struct shash_desc *desc = cryptd_shash_desc(cryptd_req); + struct ghash_desc_ctx *dctx = 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 = ahash_request_ctx(req); + struct shash_desc *desc = cryptd_shash_desc(cryptd_req); + struct ghash_desc_ctx *dctx = shash_desc_ctx(desc); + + memcpy(out, dctx, sizeof(*dctx)); + return 0; + +} + static int ghash_async_digest(struct ahash_request *req) { struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); @@ -288,8 +311,11 @@ static struct ahash_alg ghash_async_alg = { .final = ghash_async_final, .setkey = ghash_async_setkey, .digest = ghash_async_digest, + .export = ghash_async_export, + .import = ghash_async_import, .halg = { .digestsize = GHASH_DIGEST_SIZE, + .statesize = sizeof(struct ghash_desc_ctx), .base = { .cra_name = "ghash", .cra_driver_name = "ghash-clmulni", -- 1.8.5.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] crypto: cryptd - Assign statesize properly 2015-11-29 14:45 [PATCH 0/2] crypto: Fix driver load failure Rui Wang 2015-11-29 14:45 ` [PATCH 1/2] crypto: ghash-clmulni - Fix " Rui Wang @ 2015-11-29 14:45 ` Rui Wang 2015-12-04 14:41 ` [PATCH 0/2] crypto: Fix driver load failure Herbert Xu 2 siblings, 0 replies; 4+ messages in thread From: Rui Wang @ 2015-11-29 14:45 UTC (permalink / raw) To: herbert; +Cc: ying.huang, linux-crypto, linux-kernel, rui.y.wang cryptd_create_hash() fails by returning -EINVAL. It is because after 8996eafdc ("crypto: ahash - ensure statesize is non-zero") all ahash drivers must have a non-zero statesize. This patch fixes the problem by properly assigning the statesize. Signed-off-by: Rui Wang <rui.y.wang@intel.com> --- crypto/cryptd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/cryptd.c b/crypto/cryptd.c index c81861b..8b40db8 100644 --- a/crypto/cryptd.c +++ b/crypto/cryptd.c @@ -637,6 +637,7 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb, inst->alg.halg.base.cra_flags = type; inst->alg.halg.digestsize = salg->digestsize; + inst->alg.halg.statesize = salg->statesize; inst->alg.halg.base.cra_ctxsize = sizeof(struct cryptd_hash_ctx); inst->alg.halg.base.cra_init = cryptd_hash_init_tfm; -- 1.8.5.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] crypto: Fix driver load failure 2015-11-29 14:45 [PATCH 0/2] crypto: Fix driver load failure Rui Wang 2015-11-29 14:45 ` [PATCH 1/2] crypto: ghash-clmulni - Fix " Rui Wang 2015-11-29 14:45 ` [PATCH 2/2] crypto: cryptd - Assign statesize properly Rui Wang @ 2015-12-04 14:41 ` Herbert Xu 2 siblings, 0 replies; 4+ messages in thread From: Herbert Xu @ 2015-12-04 14:41 UTC (permalink / raw) To: Rui Wang; +Cc: ying.huang, linux-crypto, linux-kernel On Sun, Nov 29, 2015 at 10:45:32PM +0800, Rui Wang wrote: > ghash_clmulni_intel fails to load on Linux 4.3+ with the following message: > "modprobe: ERROR: could not insert 'ghash_clmulni_intel': Invalid argument" > > These two patches need to go together, for the driver to load correctly. > > Rui Wang (2): > crypto: ghash-clmulni - Fix load failure > crypto: cryptd - Assign statesize properly All applied. Thanks. -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-12-04 14:41 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-11-29 14:45 [PATCH 0/2] crypto: Fix driver load failure Rui Wang 2015-11-29 14:45 ` [PATCH 1/2] crypto: ghash-clmulni - Fix " Rui Wang 2015-11-29 14:45 ` [PATCH 2/2] crypto: cryptd - Assign statesize properly Rui Wang 2015-12-04 14:41 ` [PATCH 0/2] crypto: Fix driver load failure Herbert Xu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®