cryptodev-linux: Fix error when compiling with 5.4 kernel
[openwrt/staging/rmilecki.git] / package / kernel / cryptodev-linux / patches / 010-Fix-module-loading-with-Linux-v5.0-rc5.patch
1 From f971e0cd4a0ebe59fb2e8e17240399bf6901b09b Mon Sep 17 00:00:00 2001
2 From: "Derald D. Woods" <woods.technical@gmail.com>
3 Date: Sun, 10 Feb 2019 13:22:19 -0600
4 Subject: [PATCH] Fix module loading with Linux v5.0-rc5
5
6 This commit fixes this module load error:
7 [...]
8 [ 29.112091] cryptodev: loading out-of-tree module taints kernel.
9 [ 29.128906] cryptodev: Unknown symbol crypto_givcipher_type (err -2)
10 [ 29.188842] cryptodev: Unknown symbol crypto_givcipher_type (err -2)
11 modprobe: can't load module cryptodev (extra/cryptodev.ko): unknown symbol in module, or unknown parameter
12 [...]
13
14 Upstream Linux support for unused GIVCIPHER, and others, was dropped here:
15
16 c79b411eaa72 (crypto: skcipher - remove remnants of internal IV generators)
17
18 Signed-off-by: Derald D. Woods <woods.technical@gmail.com>
19 ---
20 cryptlib.c | 9 +++++++--
21 1 file changed, 7 insertions(+), 2 deletions(-)
22
23 diff --git a/cryptlib.c b/cryptlib.c
24 index 6e66698..4a87037 100644
25 --- a/cryptlib.c
26 +++ b/cryptlib.c
27 @@ -38,7 +38,9 @@
28 #include "cryptodev_int.h"
29 #include "cipherapi.h"
30
31 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0))
32 extern const struct crypto_type crypto_givcipher_type;
33 +#endif
34
35 static void cryptodev_complete(struct crypto_async_request *req, int err)
36 {
37 @@ -157,8 +159,11 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
38
39 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0))
40 tfm = crypto_skcipher_tfm(out->async.s);
41 - if ((tfm->__crt_alg->cra_type == &crypto_ablkcipher_type) ||
42 - (tfm->__crt_alg->cra_type == &crypto_givcipher_type)) {
43 + if ((tfm->__crt_alg->cra_type == &crypto_ablkcipher_type)
44 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0))
45 + || (tfm->__crt_alg->cra_type == &crypto_givcipher_type)
46 +#endif
47 + ) {
48 struct ablkcipher_alg *alg;
49
50 alg = &tfm->__crt_alg->cra_ablkcipher;