aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Eymann <J.Eymann@gmx.net>2016-04-19 13:33:47 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2016-04-20 05:42:48 -0400
commit89d124cb61b39900959e2839ac06b6339b6a54cb (patch)
tree8f3ecc397cdfea3df8438756daec8356d93fa6bc
parentf709b45ec461b548c41a00044dba1f1b572783bf (diff)
crypto: talitos - fix crash in talitos_cra_init()
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> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/talitos.c41
1 files 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 {
2629 struct talitos_alg_template algt; 2629 struct talitos_alg_template algt;
2630}; 2630};
2631 2631
2632static int talitos_cra_init(struct crypto_tfm *tfm) 2632static int talitos_init_common(struct talitos_ctx *ctx,
2633 struct talitos_crypto_alg *talitos_alg)
2633{ 2634{
2634 struct crypto_alg *alg = tfm->__crt_alg;
2635 struct talitos_crypto_alg *talitos_alg;
2636 struct talitos_ctx *ctx = crypto_tfm_ctx(tfm);
2637 struct talitos_private *priv; 2635 struct talitos_private *priv;
2638 2636
2639 if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_AHASH)
2640 talitos_alg = container_of(__crypto_ahash_alg(alg),
2641 struct talitos_crypto_alg,
2642 algt.alg.hash);
2643 else
2644 talitos_alg = container_of(alg, struct talitos_crypto_alg,
2645 algt.alg.crypto);
2646
2647 /* update context with ptr to dev */ 2637 /* update context with ptr to dev */
2648 ctx->dev = talitos_alg->dev; 2638 ctx->dev = talitos_alg->dev;
2649 2639
@@ -2661,10 +2651,33 @@ static int talitos_cra_init(struct crypto_tfm *tfm)
2661 return 0; 2651 return 0;
2662} 2652}
2663 2653
2654static int talitos_cra_init(struct crypto_tfm *tfm)
2655{
2656 struct crypto_alg *alg = tfm->__crt_alg;
2657 struct talitos_crypto_alg *talitos_alg;
2658 struct talitos_ctx *ctx = crypto_tfm_ctx(tfm);
2659
2660 if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_AHASH)
2661 talitos_alg = container_of(__crypto_ahash_alg(alg),
2662 struct talitos_crypto_alg,
2663 algt.alg.hash);
2664 else
2665 talitos_alg = container_of(alg, struct talitos_crypto_alg,
2666 algt.alg.crypto);
2667
2668 return talitos_init_common(ctx, talitos_alg);
2669}
2670
2664static int talitos_cra_init_aead(struct crypto_aead *tfm) 2671static int talitos_cra_init_aead(struct crypto_aead *tfm)
2665{ 2672{
2666 talitos_cra_init(crypto_aead_tfm(tfm)); 2673 struct aead_alg *alg = crypto_aead_alg(tfm);
2667 return 0; 2674 struct talitos_crypto_alg *talitos_alg;
2675 struct talitos_ctx *ctx = crypto_aead_ctx(tfm);
2676
2677 talitos_alg = container_of(alg, struct talitos_crypto_alg,
2678 algt.alg.aead);
2679
2680 return talitos_init_common(ctx, talitos_alg);
2668} 2681}
2669 2682
2670static int talitos_cra_init_ahash(struct crypto_tfm *tfm) 2683static int talitos_cra_init_ahash(struct crypto_tfm *tfm)