All of lore.kernel.org
 help / color / mirror / Atom feed
* ppc/talitos oops on call to crypto_alloc_aead
@ 2016-04-08 13:40 Jonas Eymann
  2016-04-15 14:02 ` Herbert Xu
  0 siblings, 1 reply; 13+ messages in thread
From: Jonas Eymann @ 2016-04-08 13:40 UTC (permalink / raw)
  To: linux-crypto

Hi all,

running a current 4.4.6 kernel on a board using a Freescale P1020, I ran into an oops when calling crypto_alloc_aead using the talitos driver. I could also reproduce this using the run-time self tests:

[...]
[    1.141095] talitos ffe30000.crypto: hwrng
[    1.145381] Unable to handle kernel paging request for data at address 0x00000058
[    1.152913] Faulting instruction address: 0xc02accc0
[    1.157910] Oops: Kernel access of bad area, sig: 11 [#1]
[    1.163315] SMP NR_CPUS=2 P1020 RDB
[    1.166810] Modules linked in:
[    1.169875] CPU: 0 PID: 1007 Comm: cryptomgr_test Not tainted 4.4.6 #1
[    1.176415] task: db5ec200 ti: db4d6000 task.ti: db4d6000
[    1.181821] NIP: c02accc0 LR: c02acd18 CTR: c02acd04
[    1.186793] REGS: db4d7d30 TRAP: 0300   Not tainted  (4.4.6)
[    1.192457] MSR: 00029000 <CE,EE,ME>  CR: 95009359  XER: e0000000
[    1.198585] DEAR: 00000058 ESR: 00000000 
GPR00: c017bdc0 db4d7de0 db5ec200 df424b48 00000000 00000000 df424bfc db75a600 
GPR08: df424b48 00000000 db75a628 db4d6000 00000149 00000000 c0044cac db5acda0 
GPR16: 00000000 00000000 00000000 00000000 00000000 00000000 00000400 df424940 
GPR24: df424900 00003083 00000400 c0180000 db75a640 c03e9f84 df424b40 df424b48 
[    1.230978] NIP [c02accc0] talitos_cra_init+0x28/0x6c
[    1.236039] LR [c02acd18] talitos_cra_init_aead+0x14/0x28
[    1.241443] Call Trace:
[    1.243894] [db4d7de0] [c03e9f84] 0xc03e9f84 (unreliable)
[    1.249322] [db4d7df0] [c017bdc0] crypto_create_tfm+0x5c/0xf0
[    1.255083] [db4d7e10] [c017beec] crypto_alloc_tfm+0x98/0xf8
[    1.260769] [db4d7e40] [c0186a20] alg_test_aead+0x28/0xc8
[    1.266181] [db4d7e60] [c0186718] alg_test+0x260/0x2e0
[    1.271333] [db4d7ee0] [c0183860] cryptomgr_test+0x30/0x54
[    1.276843] [db4d7ef0] [c0044d80] kthread+0xd4/0xd8
[    1.281741] [db4d7f40] [c000e4a4] ret_from_kernel_thread+0x5c/0x64
[    1.287930] Instruction dump:
[    1.290902] 38600000 4e800020 81230028 7c681b78 81490010 38e9ffc0 3929ffe8 554a073e 
[    1.298691] 2b8a000a 7d474f9e 812a0008 91230030 <80e90058> 39270060 7c0004ac 7cc04828 
[    1.306676] ---[ end trace 4b725069552c2912 ]---
[    1.311298] 

In a first attempt to fix this problem using the patch further below, I could prevent the oops, though the self tests still fail:

[...]
[    1.145414] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-aes-talitos
[    1.153564] 00000000: 53 69 6e 67 6c 65 20 62 6c 6f 63 6b 20 6d 73 67
[    1.160041] 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.166509] 00000020: 00 00 00 00
[    1.170041] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-3des-talitos
[    1.178276] 00000000: 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72 73 74
[    1.184751] 00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
[    1.191220] 00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
[    1.197689] 00000030: 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63
[    1.204158] 00000040: 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65
[    1.210626] 00000050: 65 72 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53
[    1.217095] 00000060: 72 63 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20
[    1.223563] 00000070: 63 65 65 72 73 74 54 20 6f 6f 4d 20 6e 61 0a 79
[    1.230038] 00000080: de ad be ef de ad be ef de ad be ef de ad be ef
[    1.236515] 00000090: de ad be ef
[...]
[    1.651807] alg: No test for authenc(hmac(md5),cbc(aes)) (authenc-hmac-md5-cbc-aes-talitos)
[    1.660371] alg: No test for authenc(hmac(md5),cbc(des3_ede)) (authenc-hmac-md5-cbc-3des-talitos)
[    1.669576] talitos ffe30000.crypto: md5-talitos alg registration failed
[    1.676331] talitos ffe30000.crypto: sha1-talitos alg registration failed
[    1.683155] talitos ffe30000.crypto: sha224-talitos alg registration failed
[    1.690153] talitos ffe30000.crypto: sha256-talitos alg registration failed
[    1.697150] talitos ffe30000.crypto: sha384-talitos alg registration failed
[    1.704148] talitos ffe30000.crypto: sha512-talitos alg registration failed
[    1.711146] talitos ffe30000.crypto: hmac-md5-talitos alg registration failed
[    1.718317] talitos ffe30000.crypto: hmac-sha1-talitos alg registration failed
[    1.725581] talitos ffe30000.crypto: hmac-sha224-talitos alg registration failed
[    1.733014] talitos ffe30000.crypto: hmac-sha256-talitos alg registration failed
[    1.740446] talitos ffe30000.crypto: hmac-sha384-talitos alg registration failed
[    1.747878] talitos ffe30000.crypto: hmac-sha512-talitos alg registration failed
[    1.755310] talitos ffe30000.crypto: fsl,sec3.3 algorithms registered in /proc/crypto


I'm unsure whether or not this is related to the talitos driver not being able to register the hash algorithms (as it does not yet implement state import/export functions).
Can anyone generally confirm the problem on a P1020 or other CPU using the talitos driver and/or knows how to fix the remaining issues?
 
Thanks a lot in advance,
Jonas


---
Patch:

--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -2519,21 +2519,10 @@ struct talitos_crypto_alg {
 	struct talitos_alg_template algt;
 };
 
-static int talitos_cra_init(struct crypto_tfm *tfm)
+static int talitos_init_common(struct talitos_ctx *ctx, struct talitos_crypto_alg *talitos_alg)
 {
-	struct crypto_alg *alg = tfm->__crt_alg;
-	struct talitos_crypto_alg *talitos_alg;
-	struct talitos_ctx *ctx = crypto_tfm_ctx(tfm);
 	struct talitos_private *priv;
 
-	if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_AHASH)
-		talitos_alg = container_of(__crypto_ahash_alg(alg),
-					   struct talitos_crypto_alg,
-					   algt.alg.hash);
-	else
-		talitos_alg = container_of(alg, struct talitos_crypto_alg,
-					   algt.alg.crypto);
-
 	/* update context with ptr to dev */
 	ctx->dev = talitos_alg->dev;
 
@@ -2551,10 +2540,33 @@ static int talitos_cra_init(struct crypt
 	return 0;
 }
 
+static int talitos_cra_init(struct crypto_tfm *tfm)
+{
+	struct crypto_alg *alg = tfm->__crt_alg;
+	struct talitos_crypto_alg *talitos_alg;
+	struct talitos_ctx *ctx = crypto_tfm_ctx(tfm);
+
+	if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_AHASH)
+		talitos_alg = container_of(__crypto_ahash_alg(tfm),
+					   struct talitos_crypto_alg,
+					   algt.alg.hash);
+	else
+		talitos_alg = container_of(alg, struct talitos_crypto_alg,
+					   algt.alg.crypto);
+
+	return talitos_init_common(ctx, talitos_alg);
+}
+
 static int talitos_cra_init_aead(struct crypto_aead *tfm)
 {
-	talitos_cra_init(crypto_aead_tfm(tfm));
-	return 0;
+	struct aead_alg *alg = crypto_aead_alg(tfm);
+	struct talitos_crypto_alg *talitos_alg;
+	talitos_alg = container_of(alg,
+				struct talitos_crypto_alg,
+				algt.alg.aead);
+	struct talitos_ctx *ctx = crypto_aead_ctx(tfm);
+	
+	return talitos_init_common(ctx, talitos_alg);
 }
 
 static int talitos_cra_init_ahash(struct crypto_tfm *tfm)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ppc/talitos oops on call to crypto_alloc_aead
  2016-04-08 13:40 ppc/talitos oops on call to crypto_alloc_aead Jonas Eymann
@ 2016-04-15 14:02 ` Herbert Xu
  2016-04-18  9:36   ` Herbert Xu
  0 siblings, 1 reply; 13+ messages in thread
From: Herbert Xu @ 2016-04-15 14:02 UTC (permalink / raw)
  To: Jonas Eymann; +Cc: linux-crypto

Jonas Eymann <J.Eymann@gmx.net> wrote:
> 
> running a current 4.4.6 kernel on a board using a Freescale P1020, I ran into an oops when calling crypto_alloc_aead using the talitos driver. I could also reproduce this using the run-time self tests:

Thanks for the patch.  Could you please add a Signed-off-by?
 
> In a first attempt to fix this problem using the patch further below, I could prevent the oops, though the self tests still fail:
> 
> [...]
> [    1.145414] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-aes-talitos
> [    1.153564] 00000000: 53 69 6e 67 6c 65 20 62 6c 6f 63 6b 20 6d 73 67
> [    1.160041] 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> [    1.166509] 00000020: 00 00 00 00
> [    1.170041] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-3des-talitos
> [    1.178276] 00000000: 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72 73 74
> [    1.184751] 00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
> [    1.191220] 00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
> [    1.197689] 00000030: 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63
> [    1.204158] 00000040: 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65
> [    1.210626] 00000050: 65 72 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53
> [    1.217095] 00000060: 72 63 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20
> [    1.223563] 00000070: 63 65 65 72 73 74 54 20 6f 6f 4d 20 6e 61 0a 79
> [    1.230038] 00000080: de ad be ef de ad be ef de ad be ef de ad be ef
> [    1.236515] 00000090: de ad be ef

Let me look into this.

Cheers,
-- 
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] 13+ messages in thread

* Re: ppc/talitos oops on call to crypto_alloc_aead
  2016-04-15 14:02 ` Herbert Xu
@ 2016-04-18  9:36   ` Herbert Xu
  2016-04-18 12:55     ` Horia Ioan Geanta Neag
  0 siblings, 1 reply; 13+ messages in thread
From: Herbert Xu @ 2016-04-18  9:36 UTC (permalink / raw)
  To: Jonas Eymann; +Cc: linux-crypto

On Fri, Apr 15, 2016 at 10:02:21PM +0800, Herbert Xu wrote:
> Jonas Eymann <J.Eymann@gmx.net> wrote:
> > 
> > running a current 4.4.6 kernel on a board using a Freescale P1020, I ran into an oops when calling crypto_alloc_aead using the talitos driver. I could also reproduce this using the run-time self tests:
> 
> Thanks for the patch.  Could you please add a Signed-off-by?
>  
> > In a first attempt to fix this problem using the patch further below, I could prevent the oops, though the self tests still fail:
> > 
> > [...]
> > [    1.145414] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-aes-talitos
> > [    1.153564] 00000000: 53 69 6e 67 6c 65 20 62 6c 6f 63 6b 20 6d 73 67
> > [    1.160041] 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> > [    1.166509] 00000020: 00 00 00 00
> > [    1.170041] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-3des-talitos
> > [    1.178276] 00000000: 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72 73 74
> > [    1.184751] 00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
> > [    1.191220] 00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
> > [    1.197689] 00000030: 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63
> > [    1.204158] 00000040: 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65
> > [    1.210626] 00000050: 65 72 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53
> > [    1.217095] 00000060: 72 63 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20
> > [    1.223563] 00000070: 63 65 65 72 73 74 54 20 6f 6f 4d 20 6e 61 0a 79
> > [    1.230038] 00000080: de ad be ef de ad be ef de ad be ef de ad be ef
> > [    1.236515] 00000090: de ad be ef

Any chance you can let me know whether 4.2 works on this machine?

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] 13+ messages in thread

* Re: ppc/talitos oops on call to crypto_alloc_aead
  2016-04-18  9:36   ` Herbert Xu
@ 2016-04-18 12:55     ` Horia Ioan Geanta Neag
  2016-04-19 17:33       ` [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface Horia Geantă
  2016-04-21 16:24       ` [PATCH] crypto: talitos - fix ahash algorithms registration Horia Geantă
  0 siblings, 2 replies; 13+ messages in thread
From: Horia Ioan Geanta Neag @ 2016-04-18 12:55 UTC (permalink / raw)
  To: Herbert Xu, Jonas Eymann; +Cc: linux-crypto

On 4/18/2016 12:36 PM, Herbert Xu wrote:
> On Fri, Apr 15, 2016 at 10:02:21PM +0800, Herbert Xu wrote:
>> Jonas Eymann <J.Eymann@gmx.net> wrote:
>>>
>>> running a current 4.4.6 kernel on a board using a Freescale P1020, I ran into an oops when calling crypto_alloc_aead using the talitos driver. I could also reproduce this using the run-time self tests:
>>
>> Thanks for the patch.  Could you please add a Signed-off-by?
>>  
Thanks Jonas.

It looks there's a typo, please consider this incremental patch:

diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index 4f09395dd5f2..7c16051599fd 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -2657,7 +2657,7 @@ static int talitos_cra_init(struct crypto_tfm *tfm)
        struct talitos_ctx *ctx = crypto_tfm_ctx(tfm);

        if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
CRYPTO_ALG_TYPE_AHASH)
-               talitos_alg = container_of(__crypto_ahash_alg(tfm),
+               talitos_alg = container_of(__crypto_ahash_alg(alg),
                                           struct talitos_crypto_alg,
                                           algt.alg.hash);
        else


>>> In a first attempt to fix this problem using the patch further below, I could prevent the oops, though the self tests still fail:
>>>
>>> [...]
>>> [    1.145414] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-aes-talitos
>>> [    1.153564] 00000000: 53 69 6e 67 6c 65 20 62 6c 6f 63 6b 20 6d 73 67
>>> [    1.160041] 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>>> [    1.166509] 00000020: 00 00 00 00
>>> [    1.170041] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-3des-talitos
>>> [    1.178276] 00000000: 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72 73 74
>>> [    1.184751] 00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
>>> [    1.191220] 00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
>>> [    1.197689] 00000030: 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63
>>> [    1.204158] 00000040: 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65
>>> [    1.210626] 00000050: 65 72 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53
>>> [    1.217095] 00000060: 72 63 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20
>>> [    1.223563] 00000070: 63 65 65 72 73 74 54 20 6f 6f 4d 20 6e 61 0a 79
>>> [    1.230038] 00000080: de ad be ef de ad be ef de ad be ef de ad be ef
>>> [    1.236515] 00000090: de ad be ef
> 
> Any chance you can let me know whether 4.2 works on this machine?
> 
4.2 works fine. 4.3+ have issues.

This might be related to:
aeb4c132f33d crypto: talitos - Convert to new AEAD interface
Before this commit, self-tests pass.

Wrt. hash algorithms registration failure, indeed the problem is due to
lack of import/export functionality.

Regards,
Horia

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface
  2016-04-18 12:55     ` Horia Ioan Geanta Neag
@ 2016-04-19 17:33       ` Horia Geantă
  2016-04-19 17:33         ` [PATCH 1/2] crypto: talitos - fix crash in talitos_cra_init() Horia Geantă
                           ` (2 more replies)
  2016-04-21 16:24       ` [PATCH] crypto: talitos - fix ahash algorithms registration Horia Geantă
  1 sibling, 3 replies; 13+ messages in thread
From: Horia Geantă @ 2016-04-19 17:33 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, Jonas Eymann, David S. Miller

Jonas Eymann reports a crash and some failures of AED algorithms
with kernel 4.4.6, all easily reproducible with tcrypt.

These have to do with the onversion to the new AEAD interface:
aeb4c132f33d crypto: talitos - Convert to new AEAD interface

Problems occur for 4.3+ kernels, sending patches to -stable.

(*) Proper fix for hash algorithms registration failures
(implementation of import/export functionality) will be added separately.

Thannks,
Horia

Horia Geantă (1):
  crypto: talitos - fix AEAD tcrypt tests

Jonas Eymann (1):
  crypto: talitos - fix crash in talitos_cra_init()

 drivers/crypto/talitos.c | 87 +++++++++++++++++++++++++++++++-----------------
 1 file changed, 57 insertions(+), 30 deletions(-)

-- 
2.4.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/2] crypto: talitos - fix crash in talitos_cra_init()
  2016-04-19 17:33       ` [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface Horia Geantă
@ 2016-04-19 17:33         ` Horia Geantă
  2016-04-19 17:33         ` [PATCH 2/2] crypto: talitos - fix AEAD tcrypt tests Horia Geantă
  2016-04-20  9:58         ` [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface Herbert Xu
  2 siblings, 0 replies; 13+ messages in thread
From: Horia Geantă @ 2016-04-19 17:33 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, Jonas Eymann, David S. Miller, stable

From: Jonas Eymann <J.Eymann@gmx.net>

Conversion of talitos driver to the new AEAD interface
hasn't been properly tested.

AEAD algorithms crash in talitos_cra_init as follows:

[...]
[    1.141095] talitos ffe30000.crypto: hwrng
[    1.145381] Unable to handle kernel paging request for data at address 0x00000058
[    1.152913] Faulting instruction address: 0xc02accc0
[    1.157910] Oops: Kernel access of bad area, sig: 11 [#1]
[    1.163315] SMP NR_CPUS=2 P1020 RDB
[    1.166810] Modules linked in:
[    1.169875] CPU: 0 PID: 1007 Comm: cryptomgr_test Not tainted 4.4.6 #1
[    1.176415] task: db5ec200 ti: db4d6000 task.ti: db4d6000
[    1.181821] NIP: c02accc0 LR: c02acd18 CTR: c02acd04
[    1.186793] REGS: db4d7d30 TRAP: 0300   Not tainted  (4.4.6)
[    1.192457] MSR: 00029000 <CE,EE,ME>  CR: 95009359  XER: e0000000
[    1.198585] DEAR: 00000058 ESR: 00000000
GPR00: c017bdc0 db4d7de0 db5ec200 df424b48 00000000 00000000 df424bfc db75a600
GPR08: df424b48 00000000 db75a628 db4d6000 00000149 00000000 c0044cac db5acda0
GPR16: 00000000 00000000 00000000 00000000 00000000 00000000 00000400 df424940
GPR24: df424900 00003083 00000400 c0180000 db75a640 c03e9f84 df424b40 df424b48
[    1.230978] NIP [c02accc0] talitos_cra_init+0x28/0x6c
[    1.236039] LR [c02acd18] talitos_cra_init_aead+0x14/0x28
[    1.241443] Call Trace:
[    1.243894] [db4d7de0] [c03e9f84] 0xc03e9f84 (unreliable)
[    1.249322] [db4d7df0] [c017bdc0] crypto_create_tfm+0x5c/0xf0
[    1.255083] [db4d7e10] [c017beec] crypto_alloc_tfm+0x98/0xf8
[    1.260769] [db4d7e40] [c0186a20] alg_test_aead+0x28/0xc8
[    1.266181] [db4d7e60] [c0186718] alg_test+0x260/0x2e0
[    1.271333] [db4d7ee0] [c0183860] cryptomgr_test+0x30/0x54
[    1.276843] [db4d7ef0] [c0044d80] kthread+0xd4/0xd8
[    1.281741] [db4d7f40] [c000e4a4] ret_from_kernel_thread+0x5c/0x64
[    1.287930] Instruction dump:
[    1.290902] 38600000 4e800020 81230028 7c681b78 81490010 38e9ffc0 3929ffe8 554a073e
[    1.298691] 2b8a000a 7d474f9e 812a0008 91230030 <80e90058> 39270060 7c0004ac 7cc04828

Cc: <stable@vger.kernel.org> # 4.3+
Fixes: aeb4c132f33d ("crypto: talitos - Convert to new AEAD interface")
Signed-off-by: Jonas Eymann <J.Eymann@gmx.net>

Fix typo - replaced parameter of __crypto_ahash_alg(): s/tfm/alg
Remove checkpatch warnings.
Add commit message.

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/talitos.c | 41 +++++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index a0d4a08313ae..35198804d6d3 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -2629,21 +2629,11 @@ struct talitos_crypto_alg {
 	struct talitos_alg_template algt;
 };
 
-static int talitos_cra_init(struct crypto_tfm *tfm)
+static int talitos_init_common(struct talitos_ctx *ctx,
+			       struct talitos_crypto_alg *talitos_alg)
 {
-	struct crypto_alg *alg = tfm->__crt_alg;
-	struct talitos_crypto_alg *talitos_alg;
-	struct talitos_ctx *ctx = crypto_tfm_ctx(tfm);
 	struct talitos_private *priv;
 
-	if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_AHASH)
-		talitos_alg = container_of(__crypto_ahash_alg(alg),
-					   struct talitos_crypto_alg,
-					   algt.alg.hash);
-	else
-		talitos_alg = container_of(alg, struct talitos_crypto_alg,
-					   algt.alg.crypto);
-
 	/* update context with ptr to dev */
 	ctx->dev = talitos_alg->dev;
 
@@ -2661,10 +2651,33 @@ static int talitos_cra_init(struct crypto_tfm *tfm)
 	return 0;
 }
 
+static int talitos_cra_init(struct crypto_tfm *tfm)
+{
+	struct crypto_alg *alg = tfm->__crt_alg;
+	struct talitos_crypto_alg *talitos_alg;
+	struct talitos_ctx *ctx = crypto_tfm_ctx(tfm);
+
+	if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_AHASH)
+		talitos_alg = container_of(__crypto_ahash_alg(alg),
+					   struct talitos_crypto_alg,
+					   algt.alg.hash);
+	else
+		talitos_alg = container_of(alg, struct talitos_crypto_alg,
+					   algt.alg.crypto);
+
+	return talitos_init_common(ctx, talitos_alg);
+}
+
 static int talitos_cra_init_aead(struct crypto_aead *tfm)
 {
-	talitos_cra_init(crypto_aead_tfm(tfm));
-	return 0;
+	struct aead_alg *alg = crypto_aead_alg(tfm);
+	struct talitos_crypto_alg *talitos_alg;
+	struct talitos_ctx *ctx = crypto_aead_ctx(tfm);
+
+	talitos_alg = container_of(alg, struct talitos_crypto_alg,
+				   algt.alg.aead);
+
+	return talitos_init_common(ctx, talitos_alg);
 }
 
 static int talitos_cra_init_ahash(struct crypto_tfm *tfm)
-- 
2.4.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/2] crypto: talitos - fix AEAD tcrypt tests
  2016-04-19 17:33       ` [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface Horia Geantă
  2016-04-19 17:33         ` [PATCH 1/2] crypto: talitos - fix crash in talitos_cra_init() Horia Geantă
@ 2016-04-19 17:33         ` Horia Geantă
  2016-04-20  9:58         ` [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface Herbert Xu
  2 siblings, 0 replies; 13+ messages in thread
From: Horia Geantă @ 2016-04-19 17:33 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, Jonas Eymann, David S. Miller, stable

After conversion to new AEAD interface, tcrypt tests fail as follows:

[...]
[    1.145414] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-aes-talitos
[    1.153564] 00000000: 53 69 6e 67 6c 65 20 62 6c 6f 63 6b 20 6d 73 67
[    1.160041] 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.166509] 00000020: 00 00 00 00
[...]

Fix them by providing the correct cipher in & cipher out pointers,
i.e. must skip over associated data in src and dst S/G.

While here, fix a problem with the HW S/G table index usage:
tbl_off must be updated after the pointer to the table entries is set.

Cc: <stable@vger.kernel.org> # 4.3+
Fixes: aeb4c132f33d ("crypto: talitos - Convert to new AEAD interface")
Reported-by: Jonas Eymann <J.Eymann@gmx.net>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/talitos.c | 46 ++++++++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index 35198804d6d3..aae05547b924 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -63,6 +63,14 @@ static void to_talitos_ptr(struct talitos_ptr *ptr, dma_addr_t dma_addr,
 		ptr->eptr = upper_32_bits(dma_addr);
 }
 
+static void copy_talitos_ptr(struct talitos_ptr *dst_ptr,
+			     struct talitos_ptr *src_ptr, bool is_sec1)
+{
+	dst_ptr->ptr = src_ptr->ptr;
+	if (!is_sec1)
+		dst_ptr->eptr = src_ptr->eptr;
+}
+
 static void to_talitos_ptr_len(struct talitos_ptr *ptr, unsigned int len,
 			       bool is_sec1)
 {
@@ -1083,21 +1091,20 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
 	sg_count = dma_map_sg(dev, areq->src, edesc->src_nents ?: 1,
 			      (areq->src == areq->dst) ? DMA_BIDIRECTIONAL
 							   : DMA_TO_DEVICE);
-
 	/* hmac data */
 	desc->ptr[1].len = cpu_to_be16(areq->assoclen);
 	if (sg_count > 1 &&
 	    (ret = sg_to_link_tbl_offset(areq->src, sg_count, 0,
 					 areq->assoclen,
 					 &edesc->link_tbl[tbl_off])) > 1) {
-		tbl_off += ret;
-
 		to_talitos_ptr(&desc->ptr[1], edesc->dma_link_tbl + tbl_off *
 			       sizeof(struct talitos_ptr), 0);
 		desc->ptr[1].j_extent = DESC_PTR_LNKTBL_JUMP;
 
 		dma_sync_single_for_device(dev, edesc->dma_link_tbl,
 					   edesc->dma_len, DMA_BIDIRECTIONAL);
+
+		tbl_off += ret;
 	} else {
 		to_talitos_ptr(&desc->ptr[1], sg_dma_address(areq->src), 0);
 		desc->ptr[1].j_extent = 0;
@@ -1126,11 +1133,13 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
 	if (edesc->desc.hdr & DESC_HDR_MODE1_MDEU_CICV)
 		sg_link_tbl_len += authsize;
 
-	if (sg_count > 1 &&
-	    (ret = sg_to_link_tbl_offset(areq->src, sg_count, areq->assoclen,
-					 sg_link_tbl_len,
-					 &edesc->link_tbl[tbl_off])) > 1) {
-		tbl_off += ret;
+	if (sg_count == 1) {
+		to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->src) +
+			       areq->assoclen, 0);
+	} else if ((ret = sg_to_link_tbl_offset(areq->src, sg_count,
+						areq->assoclen, sg_link_tbl_len,
+						&edesc->link_tbl[tbl_off])) >
+		   1) {
 		desc->ptr[4].j_extent |= DESC_PTR_LNKTBL_JUMP;
 		to_talitos_ptr(&desc->ptr[4], edesc->dma_link_tbl +
 					      tbl_off *
@@ -1138,8 +1147,10 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
 		dma_sync_single_for_device(dev, edesc->dma_link_tbl,
 					   edesc->dma_len,
 					   DMA_BIDIRECTIONAL);
-	} else
-		to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->src), 0);
+		tbl_off += ret;
+	} else {
+		copy_talitos_ptr(&desc->ptr[4], &edesc->link_tbl[tbl_off], 0);
+	}
 
 	/* cipher out */
 	desc->ptr[5].len = cpu_to_be16(cryptlen);
@@ -1151,11 +1162,13 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
 
 	edesc->icv_ool = false;
 
-	if (sg_count > 1 &&
-	    (sg_count = sg_to_link_tbl_offset(areq->dst, sg_count,
+	if (sg_count == 1) {
+		to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst) +
+			       areq->assoclen, 0);
+	} else if ((sg_count =
+			sg_to_link_tbl_offset(areq->dst, sg_count,
 					      areq->assoclen, cryptlen,
-					      &edesc->link_tbl[tbl_off])) >
-	    1) {
+					      &edesc->link_tbl[tbl_off])) > 1) {
 		struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off];
 
 		to_talitos_ptr(&desc->ptr[5], edesc->dma_link_tbl +
@@ -1178,8 +1191,9 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
 					   edesc->dma_len, DMA_BIDIRECTIONAL);
 
 		edesc->icv_ool = true;
-	} else
-		to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst), 0);
+	} else {
+		copy_talitos_ptr(&desc->ptr[5], &edesc->link_tbl[tbl_off], 0);
+	}
 
 	/* iv out */
 	map_single_talitos_ptr(dev, &desc->ptr[6], ivsize, ctx->iv,
-- 
2.4.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface
  2016-04-19 17:33       ` [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface Horia Geantă
  2016-04-19 17:33         ` [PATCH 1/2] crypto: talitos - fix crash in talitos_cra_init() Horia Geantă
  2016-04-19 17:33         ` [PATCH 2/2] crypto: talitos - fix AEAD tcrypt tests Horia Geantă
@ 2016-04-20  9:58         ` Herbert Xu
  2016-04-20 11:29           ` Horia Ioan Geanta Neag
  2016-04-20 12:09           ` Jonas Eymann
  2 siblings, 2 replies; 13+ messages in thread
From: Herbert Xu @ 2016-04-20  9:58 UTC (permalink / raw)
  To: Horia Geantă; +Cc: linux-crypto, Jonas Eymann, David S. Miller

On Tue, Apr 19, 2016 at 08:33:46PM +0300, Horia Geantă wrote:
> Jonas Eymann reports a crash and some failures of AED algorithms
> with kernel 4.4.6, all easily reproducible with tcrypt.
> 
> These have to do with the onversion to the new AEAD interface:
> aeb4c132f33d crypto: talitos - Convert to new AEAD interface
> 
> Problems occur for 4.3+ kernels, sending patches to -stable.
> 
> (*) Proper fix for hash algorithms registration failures
> (implementation of import/export functionality) will be added separately.

Both 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] 13+ messages in thread

* Re: [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface
  2016-04-20  9:58         ` [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface Herbert Xu
@ 2016-04-20 11:29           ` Horia Ioan Geanta Neag
  2016-04-21 11:02             ` Herbert Xu
  2016-04-20 12:09           ` Jonas Eymann
  1 sibling, 1 reply; 13+ messages in thread
From: Horia Ioan Geanta Neag @ 2016-04-20 11:29 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, Jonas Eymann, David S. Miller

On 4/20/2016 12:58 PM, Herbert Xu wrote:
> On Tue, Apr 19, 2016 at 08:33:46PM +0300, Horia Geantă wrote:
>> Jonas Eymann reports a crash and some failures of AED algorithms
>> with kernel 4.4.6, all easily reproducible with tcrypt.
>>
>> These have to do with the onversion to the new AEAD interface:
>> aeb4c132f33d crypto: talitos - Convert to new AEAD interface
>>
>> Problems occur for 4.3+ kernels, sending patches to -stable.
>>
>> (*) Proper fix for hash algorithms registration failures
>> (implementation of import/export functionality) will be added separately.
> 
> Both applied.  Thanks!
> 
Thanks Herbert.

Shouldn't these have been included in the recent "Crypto Update for 4.6"
pull request?

Horia

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface
  2016-04-20  9:58         ` [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface Herbert Xu
  2016-04-20 11:29           ` Horia Ioan Geanta Neag
@ 2016-04-20 12:09           ` Jonas Eymann
  1 sibling, 0 replies; 13+ messages in thread
From: Jonas Eymann @ 2016-04-20 12:09 UTC (permalink / raw)
  To: horia.geanta; +Cc: linux-crypto

sorry for the late reply, I was out of office. Thank you very much Horia for fixing the typo, adding the sign-off and also for the second patch. I'll also run some tests when I find the time to see how everything works together.

Jonas

> Gesendet: Mittwoch, 20. April 2016 um 11:58 Uhr
> Von: "Herbert Xu" <herbert@gondor.apana.org.au>
> An: "Horia Geantă" <horia.geanta@nxp.com>
> Cc: linux-crypto@vger.kernel.org, "Jonas Eymann" <J.Eymann@gmx.net>, "David S. Miller" <davem@davemloft.net>
> Betreff: Re: [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface
>
> On Tue, Apr 19, 2016 at 08:33:46PM +0300, Horia Geantă wrote:
> > Jonas Eymann reports a crash and some failures of AED algorithms
> > with kernel 4.4.6, all easily reproducible with tcrypt.
> > 
> > These have to do with the onversion to the new AEAD interface:
> > aeb4c132f33d crypto: talitos - Convert to new AEAD interface
> > 
> > Problems occur for 4.3+ kernels, sending patches to -stable.
> > 
> > (*) Proper fix for hash algorithms registration failures
> > (implementation of import/export functionality) will be added separately.
> 
> Both 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] 13+ messages in thread

* Re: [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface
  2016-04-20 11:29           ` Horia Ioan Geanta Neag
@ 2016-04-21 11:02             ` Herbert Xu
  0 siblings, 0 replies; 13+ messages in thread
From: Herbert Xu @ 2016-04-21 11:02 UTC (permalink / raw)
  To: Horia Ioan Geanta Neag; +Cc: linux-crypto, Jonas Eymann, David S. Miller

On Wed, Apr 20, 2016 at 11:29:52AM +0000, Horia Ioan Geanta Neag wrote:
>
> Shouldn't these have been included in the recent "Crypto Update for 4.6"
> pull request?

It will go in the next pull request.

Cheers,
-- 
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] 13+ messages in thread

* [PATCH] crypto: talitos - fix ahash algorithms registration
  2016-04-18 12:55     ` Horia Ioan Geanta Neag
  2016-04-19 17:33       ` [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface Horia Geantă
@ 2016-04-21 16:24       ` Horia Geantă
  2016-04-25 11:22         ` Herbert Xu
  1 sibling, 1 reply; 13+ messages in thread
From: Horia Geantă @ 2016-04-21 16:24 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, Jonas Eymann, David S. Miller

Provide hardware state import/export functionality, as mandated by
commit 8996eafdcbad ("crypto: ahash - ensure statesize is non-zero")

Cc: <stable@vger.kernel.org> # 4.3+
Reported-by: Jonas Eymann <J.Eymann@gmx.net>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/talitos.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index aae05547b924..b7ee8d30147d 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -835,6 +835,16 @@ struct talitos_ahash_req_ctx {
 	struct scatterlist *psrc;
 };
 
+struct talitos_export_state {
+	u32 hw_context[TALITOS_MDEU_MAX_CONTEXT_SIZE / sizeof(u32)];
+	u8 buf[HASH_MAX_BLOCK_SIZE];
+	unsigned int swinit;
+	unsigned int first;
+	unsigned int last;
+	unsigned int to_hash_later;
+	unsigned int nbuf;
+};
+
 static int aead_setkey(struct crypto_aead *authenc,
 		       const u8 *key, unsigned int keylen)
 {
@@ -1981,6 +1991,46 @@ static int ahash_digest(struct ahash_request *areq)
 	return ahash_process_req(areq, areq->nbytes);
 }
 
+static int ahash_export(struct ahash_request *areq, void *out)
+{
+	struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq);
+	struct talitos_export_state *export = out;
+
+	memcpy(export->hw_context, req_ctx->hw_context,
+	       req_ctx->hw_context_size);
+	memcpy(export->buf, req_ctx->buf, req_ctx->nbuf);
+	export->swinit = req_ctx->swinit;
+	export->first = req_ctx->first;
+	export->last = req_ctx->last;
+	export->to_hash_later = req_ctx->to_hash_later;
+	export->nbuf = req_ctx->nbuf;
+
+	return 0;
+}
+
+static int ahash_import(struct ahash_request *areq, const void *in)
+{
+	struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq);
+	struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq);
+	const struct talitos_export_state *export = in;
+
+	memset(req_ctx, 0, sizeof(*req_ctx));
+	req_ctx->hw_context_size =
+		(crypto_ahash_digestsize(tfm) <= SHA256_DIGEST_SIZE)
+			? TALITOS_MDEU_CONTEXT_SIZE_MD5_SHA1_SHA256
+			: TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512;
+	memcpy(req_ctx->hw_context, export->hw_context,
+	       req_ctx->hw_context_size);
+	memcpy(req_ctx->buf, export->buf, export->nbuf);
+	req_ctx->swinit = export->swinit;
+	req_ctx->first = export->first;
+	req_ctx->last = export->last;
+	req_ctx->to_hash_later = export->to_hash_later;
+	req_ctx->nbuf = export->nbuf;
+
+	return 0;
+}
+
 struct keyhash_result {
 	struct completion completion;
 	int err;
@@ -2458,6 +2508,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = MD5_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "md5",
 				.cra_driver_name = "md5-talitos",
@@ -2473,6 +2524,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = SHA1_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "sha1",
 				.cra_driver_name = "sha1-talitos",
@@ -2488,6 +2540,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = SHA224_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "sha224",
 				.cra_driver_name = "sha224-talitos",
@@ -2503,6 +2556,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = SHA256_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "sha256",
 				.cra_driver_name = "sha256-talitos",
@@ -2518,6 +2572,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = SHA384_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "sha384",
 				.cra_driver_name = "sha384-talitos",
@@ -2533,6 +2588,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = SHA512_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "sha512",
 				.cra_driver_name = "sha512-talitos",
@@ -2548,6 +2604,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = MD5_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "hmac(md5)",
 				.cra_driver_name = "hmac-md5-talitos",
@@ -2563,6 +2620,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = SHA1_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "hmac(sha1)",
 				.cra_driver_name = "hmac-sha1-talitos",
@@ -2578,6 +2636,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = SHA224_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "hmac(sha224)",
 				.cra_driver_name = "hmac-sha224-talitos",
@@ -2593,6 +2652,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = SHA256_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "hmac(sha256)",
 				.cra_driver_name = "hmac-sha256-talitos",
@@ -2608,6 +2668,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = SHA384_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "hmac(sha384)",
 				.cra_driver_name = "hmac-sha384-talitos",
@@ -2623,6 +2684,7 @@ static struct talitos_alg_template driver_algs[] = {
 	{	.type = CRYPTO_ALG_TYPE_AHASH,
 		.alg.hash = {
 			.halg.digestsize = SHA512_DIGEST_SIZE,
+			.halg.statesize = sizeof(struct talitos_export_state),
 			.halg.base = {
 				.cra_name = "hmac(sha512)",
 				.cra_driver_name = "hmac-sha512-talitos",
@@ -2814,6 +2876,8 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,
 		t_alg->algt.alg.hash.finup = ahash_finup;
 		t_alg->algt.alg.hash.digest = ahash_digest;
 		t_alg->algt.alg.hash.setkey = ahash_setkey;
+		t_alg->algt.alg.hash.import = ahash_import;
+		t_alg->algt.alg.hash.export = ahash_export;
 
 		if (!(priv->features & TALITOS_FTR_HMAC_OK) &&
 		    !strncmp(alg->cra_name, "hmac", 4)) {
-- 
2.4.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] crypto: talitos - fix ahash algorithms registration
  2016-04-21 16:24       ` [PATCH] crypto: talitos - fix ahash algorithms registration Horia Geantă
@ 2016-04-25 11:22         ` Herbert Xu
  0 siblings, 0 replies; 13+ messages in thread
From: Herbert Xu @ 2016-04-25 11:22 UTC (permalink / raw)
  To: Horia Geantă; +Cc: linux-crypto, Jonas Eymann, David S. Miller

On Thu, Apr 21, 2016 at 07:24:55PM +0300, Horia Geantă wrote:
> Provide hardware state import/export functionality, as mandated by
> commit 8996eafdcbad ("crypto: ahash - ensure statesize is non-zero")
> 
> Cc: <stable@vger.kernel.org> # 4.3+
> Reported-by: Jonas Eymann <J.Eymann@gmx.net>
> Signed-off-by: Horia Geantă <horia.geanta@nxp.com>

Applied to cryptodev.  As with other statesize fixes, I'd like
this to go into the next merge window.

Cheers,
-- 
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] 13+ messages in thread

end of thread, other threads:[~2016-04-25 11:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-08 13:40 ppc/talitos oops on call to crypto_alloc_aead Jonas Eymann
2016-04-15 14:02 ` Herbert Xu
2016-04-18  9:36   ` Herbert Xu
2016-04-18 12:55     ` Horia Ioan Geanta Neag
2016-04-19 17:33       ` [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface Horia Geantă
2016-04-19 17:33         ` [PATCH 1/2] crypto: talitos - fix crash in talitos_cra_init() Horia Geantă
2016-04-19 17:33         ` [PATCH 2/2] crypto: talitos - fix AEAD tcrypt tests Horia Geantă
2016-04-20  9:58         ` [PATCH 0/2] crypto: talitos - fix conversion to new AEAD interface Herbert Xu
2016-04-20 11:29           ` Horia Ioan Geanta Neag
2016-04-21 11:02             ` Herbert Xu
2016-04-20 12:09           ` Jonas Eymann
2016-04-21 16:24       ` [PATCH] crypto: talitos - fix ahash algorithms registration Horia Geantă
2016-04-25 11:22         ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.