Skip to content

Commit 35e9787

Browse files
author
Torsten Duwe
committed
s390/crypto: fix aes_s390 crypto module unload problem
(bnc#881529, LTC#111065).
1 parent 4f22942 commit 35e9787

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
From: Ingo Tuchscherer <ingo.tuchscherer@de.ibm.com>
2+
Subject: s390/crypto: fix aes_s390 crypto module unload problem
3+
Git-commit: 4f57ba716b12ab939d46b7910768c3da3623fdc1
4+
Patch-mainline: v3.13-rc1
5+
References: bnc#881529, LTC#111065
6+
7+
s390/crypto: fix aes_s390 crypto module unload problem
8+
9+
If a machine has no hardware support for the xts-aes or ctr-aes algorithms
10+
they are not registered in aes_s390_init. But aes_s390_fini unconditionally
11+
unregisters the algorithms which causes crypto_remove_alg to crash.
12+
Add two flag variables to remember if xts-aes and ctr-aes have been added.
13+
14+
Signed-off-by: Ingo Tuchscherer <ingo.tuchscherer@de.ibm.com>
15+
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
16+
Acked-by: Torsten Duwe <duwe@suse.de>
17+
18+
diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
19+
index b4dbade..46cae13 100644
20+
--- a/arch/s390/crypto/aes_s390.c
21+
+++ b/arch/s390/crypto/aes_s390.c
22+
@@ -725,6 +725,8 @@ static struct crypto_alg xts_aes_alg = {
23+
}
24+
};
25+
26+
+static int xts_aes_alg_reg;
27+
+
28+
static int ctr_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
29+
unsigned int key_len)
30+
{
31+
@@ -846,6 +848,8 @@ static struct crypto_alg ctr_aes_alg = {
32+
}
33+
};
34+
35+
+static int ctr_aes_alg_reg;
36+
+
37+
static int __init aes_s390_init(void)
38+
{
39+
int ret;
40+
@@ -884,6 +888,7 @@ static int __init aes_s390_init(void)
41+
ret = crypto_register_alg(&xts_aes_alg);
42+
if (ret)
43+
goto xts_aes_err;
44+
+ xts_aes_alg_reg = 1;
45+
}
46+
47+
if (crypt_s390_func_available(KMCTR_AES_128_ENCRYPT,
48+
@@ -902,6 +907,7 @@ static int __init aes_s390_init(void)
49+
free_page((unsigned long) ctrblk);
50+
goto ctr_aes_err;
51+
}
52+
+ ctr_aes_alg_reg = 1;
53+
}
54+
55+
out:
56+
@@ -921,9 +927,12 @@ aes_err:
57+
58+
static void __exit aes_s390_fini(void)
59+
{
60+
- crypto_unregister_alg(&ctr_aes_alg);
61+
- free_page((unsigned long) ctrblk);
62+
- crypto_unregister_alg(&xts_aes_alg);
63+
+ if (ctr_aes_alg_reg) {
64+
+ crypto_unregister_alg(&ctr_aes_alg);
65+
+ free_page((unsigned long) ctrblk);
66+
+ }
67+
+ if (xts_aes_alg_reg)
68+
+ crypto_unregister_alg(&xts_aes_alg);
69+
crypto_unregister_alg(&cbc_aes_alg);
70+
crypto_unregister_alg(&ecb_aes_alg);
71+
crypto_unregister_alg(&aes_alg);

series.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,8 @@
686686
patches.arch/s390-sles12-07-12-uaccess.patch
687687
patches.arch/s390-sles12-07-13-uaccess.patch
688688

689+
patches.arch/s390-sles12-08-01-s390-crypto-fix-aes_s390-crypto-module-unload-problem
690+
689691
# fate#316346
690692
patches.drivers/hwrng-01-add-random-pool-input
691693
patches.drivers/hwrng-02-create-filler-thread

0 commit comments

Comments
 (0)