summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-kernel/cryptodev/cryptodev-linux_1.10.bb (renamed from meta/recipes-kernel/cryptodev/cryptodev-linux_1.9.bb)0
-rw-r--r--meta/recipes-kernel/cryptodev/cryptodev-module_1.10.bb (renamed from meta/recipes-kernel/cryptodev/cryptodev-module_1.9.bb)5
-rw-r--r--meta/recipes-kernel/cryptodev/cryptodev-tests_1.10.bb (renamed from meta/recipes-kernel/cryptodev/cryptodev-tests_1.9.bb)1
-rw-r--r--meta/recipes-kernel/cryptodev/cryptodev.inc2
-rw-r--r--meta/recipes-kernel/cryptodev/files/0001-Port-tests-to-openssl-1.1.patch103
-rw-r--r--meta/recipes-kernel/cryptodev/files/0001-ioctl.c-Fix-build-with-linux-4.13.patch49
-rw-r--r--meta/recipes-kernel/cryptodev/files/0001-ioctl.c-Fix-build-with-linux-4.17.patch43
-rw-r--r--meta/recipes-kernel/cryptodev/files/0001-refactoring-split-big-function-to-simplify-maintaina.patch250
-rw-r--r--meta/recipes-kernel/cryptodev/files/0002-refactoring-relocate-code-to-simplify-later-patches.patch64
-rw-r--r--meta/recipes-kernel/cryptodev/files/0003-convert-to-new-AEAD-interface-in-kernels-v4.2.patch102
10 files changed, 1 insertions, 618 deletions
diff --git a/meta/recipes-kernel/cryptodev/cryptodev-linux_1.9.bb b/meta/recipes-kernel/cryptodev/cryptodev-linux_1.10.bb
index c55577c661..c55577c661 100644
--- a/meta/recipes-kernel/cryptodev/cryptodev-linux_1.9.bb
+++ b/meta/recipes-kernel/cryptodev/cryptodev-linux_1.10.bb
diff --git a/meta/recipes-kernel/cryptodev/cryptodev-module_1.9.bb b/meta/recipes-kernel/cryptodev/cryptodev-module_1.10.bb
index ed4327d40d..552eb6abaa 100644
--- a/meta/recipes-kernel/cryptodev/cryptodev-module_1.9.bb
+++ b/meta/recipes-kernel/cryptodev/cryptodev-module_1.10.bb
@@ -9,11 +9,6 @@ DEPENDS += "cryptodev-linux"
9 9
10SRC_URI += " \ 10SRC_URI += " \
11file://0001-Disable-installing-header-file-provided-by-another-p.patch \ 11file://0001-Disable-installing-header-file-provided-by-another-p.patch \
12file://0001-ioctl.c-Fix-build-with-linux-4.13.patch \
13file://0001-ioctl.c-Fix-build-with-linux-4.17.patch \
14file://0001-refactoring-split-big-function-to-simplify-maintaina.patch \
15file://0002-refactoring-relocate-code-to-simplify-later-patches.patch \
16file://0003-convert-to-new-AEAD-interface-in-kernels-v4.2.patch \
17" 12"
18 13
19EXTRA_OEMAKE='KERNEL_DIR="${STAGING_KERNEL_DIR}" PREFIX="${D}"' 14EXTRA_OEMAKE='KERNEL_DIR="${STAGING_KERNEL_DIR}" PREFIX="${D}"'
diff --git a/meta/recipes-kernel/cryptodev/cryptodev-tests_1.9.bb b/meta/recipes-kernel/cryptodev/cryptodev-tests_1.10.bb
index 617db6cdd3..9cb5dcb94f 100644
--- a/meta/recipes-kernel/cryptodev/cryptodev-tests_1.9.bb
+++ b/meta/recipes-kernel/cryptodev/cryptodev-tests_1.10.bb
@@ -6,7 +6,6 @@ DEPENDS += "openssl"
6 6
7SRC_URI += " \ 7SRC_URI += " \
8file://0001-Add-the-compile-and-install-rules-for-cryptodev-test.patch \ 8file://0001-Add-the-compile-and-install-rules-for-cryptodev-test.patch \
9file://0001-Port-tests-to-openssl-1.1.patch \
10" 9"
11 10
12EXTRA_OEMAKE='KERNEL_DIR="${STAGING_EXECPREFIXDIR}" PREFIX="${D}"' 11EXTRA_OEMAKE='KERNEL_DIR="${STAGING_EXECPREFIXDIR}" PREFIX="${D}"'
diff --git a/meta/recipes-kernel/cryptodev/cryptodev.inc b/meta/recipes-kernel/cryptodev/cryptodev.inc
index ab15bc1d97..252d39d23a 100644
--- a/meta/recipes-kernel/cryptodev/cryptodev.inc
+++ b/meta/recipes-kernel/cryptodev/cryptodev.inc
@@ -4,7 +4,7 @@ LICENSE = "GPLv2"
4LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" 4LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
5 5
6SRC_URI = "git://github.com/cryptodev-linux/cryptodev-linux" 6SRC_URI = "git://github.com/cryptodev-linux/cryptodev-linux"
7SRCREV = "87d959d9a279c055b361de8e730fab6a7144edd7" 7SRCREV = "fd8b15ef1c8398a69a37932ee48c74ab40329a29"
8 8
9S = "${WORKDIR}/git" 9S = "${WORKDIR}/git"
10 10
diff --git a/meta/recipes-kernel/cryptodev/files/0001-Port-tests-to-openssl-1.1.patch b/meta/recipes-kernel/cryptodev/files/0001-Port-tests-to-openssl-1.1.patch
deleted file mode 100644
index c9691265f6..0000000000
--- a/meta/recipes-kernel/cryptodev/files/0001-Port-tests-to-openssl-1.1.patch
+++ /dev/null
@@ -1,103 +0,0 @@
1From 2fe4bdeb8cdd0b0f46d9caed807812855d51ea56 Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Wed, 28 Mar 2018 20:11:05 +0300
4Subject: [PATCH] Port tests to openssl 1.1
5
6Upstream-Status: Accepted [https://github.com/cryptodev-linux/cryptodev-linux/pull/36]
7Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
8
9---
10 tests/openssl_wrapper.c | 33 +++++++++++++++++++++++++++++++++
11 1 file changed, 33 insertions(+)
12
13diff --git a/tests/openssl_wrapper.c b/tests/openssl_wrapper.c
14index 038c58f..dea2496 100644
15--- a/tests/openssl_wrapper.c
16+++ b/tests/openssl_wrapper.c
17@@ -4,6 +4,7 @@
18 #include <openssl/aes.h>
19 #include <openssl/evp.h>
20 #include <openssl/hmac.h>
21+#include <openssl/opensslv.h>
22
23 //#define DEBUG
24
25@@ -23,10 +24,17 @@ enum ctx_type {
26 ctx_type_md,
27 };
28
29+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
30+union openssl_ctx {
31+ HMAC_CTX *hmac;
32+ EVP_MD_CTX *md;
33+};
34+#else
35 union openssl_ctx {
36 HMAC_CTX hmac;
37 EVP_MD_CTX md;
38 };
39+#endif
40
41 struct ctx_mapping {
42 __u32 ses;
43@@ -63,6 +71,16 @@ static void remove_mapping(__u32 ses)
44 switch (mapping->type) {
45 case ctx_type_none:
46 break;
47+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
48+ case ctx_type_hmac:
49+ dbgp("%s: calling HMAC_CTX_free\n", __func__);
50+ HMAC_CTX_free(mapping->ctx.hmac);
51+ break;
52+ case ctx_type_md:
53+ dbgp("%s: calling EVP_MD_CTX_free\n", __func__);
54+ EVP_MD_CTX_free(mapping->ctx.md);
55+ break;
56+#else
57 case ctx_type_hmac:
58 dbgp("%s: calling HMAC_CTX_cleanup\n", __func__);
59 HMAC_CTX_cleanup(&mapping->ctx.hmac);
60@@ -71,6 +89,7 @@ static void remove_mapping(__u32 ses)
61 dbgp("%s: calling EVP_MD_CTX_cleanup\n", __func__);
62 EVP_MD_CTX_cleanup(&mapping->ctx.md);
63 break;
64+#endif
65 }
66 memset(mapping, 0, sizeof(*mapping));
67 }
68@@ -127,10 +146,17 @@ static int openssl_hmac(struct session_op *sess, struct crypt_op *cop)
69
70 mapping->ses = sess->ses;
71 mapping->type = ctx_type_hmac;
72+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
73+ ctx = mapping->ctx.hmac;
74+
75+ dbgp("calling HMAC_CTX_new");
76+ ctx = HMAC_CTX_new();
77+#else
78 ctx = &mapping->ctx.hmac;
79
80 dbgp("calling HMAC_CTX_init");
81 HMAC_CTX_init(ctx);
82+#endif
83 dbgp("calling HMAC_Init_ex");
84 if (!HMAC_Init_ex(ctx, sess->mackey, sess->mackeylen,
85 sess_to_evp_md(sess), NULL)) {
86@@ -172,10 +198,17 @@ static int openssl_md(struct session_op *sess, struct crypt_op *cop)
87
88 mapping->ses = sess->ses;
89 mapping->type = ctx_type_md;
90+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
91+ ctx = mapping->ctx.md;
92+
93+ dbgp("calling EVP_MD_CTX_new");
94+ ctx = EVP_MD_CTX_new();
95+#else
96 ctx = &mapping->ctx.md;
97
98 dbgp("calling EVP_MD_CTX_init");
99 EVP_MD_CTX_init(ctx);
100+#endif
101 dbgp("calling EVP_DigestInit");
102 EVP_DigestInit(ctx, sess_to_evp_md(sess));
103 }
diff --git a/meta/recipes-kernel/cryptodev/files/0001-ioctl.c-Fix-build-with-linux-4.13.patch b/meta/recipes-kernel/cryptodev/files/0001-ioctl.c-Fix-build-with-linux-4.13.patch
deleted file mode 100644
index a41efacdd9..0000000000
--- a/meta/recipes-kernel/cryptodev/files/0001-ioctl.c-Fix-build-with-linux-4.13.patch
+++ /dev/null
@@ -1,49 +0,0 @@
1From f0d69774afb27ffc62bf353465fba145e70cb85a Mon Sep 17 00:00:00 2001
2From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
3Date: Mon, 4 Sep 2017 11:05:08 +0200
4Subject: [PATCH] ioctl.c: Fix build with linux 4.13
5
6git/ioctl.c:1127:3: error: positional initialization of field in 'struct' declared with 'designated_init' attribute [-Werror=designated-init]
7 {0, },
8 ^
9note: (near initialization for 'verbosity_ctl_dir[1]')
10git/ioctl.c:1136:3: error: positional initialization of field in 'struct' declared with 'designated_init' attribute [-Werror=designated-init]
11 {0, },
12 ^
13
14Linux kernel has added -Werror=designated-init around 4.11 (c834f0e8a8b)
15triggering build errors with gcc 5 and 6 (but not with gcc 4)
16
17Upstream-Status: Backport
18
19Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
20Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
21---
22 ioctl.c | 4 ++--
23 1 file changed, 2 insertions(+), 2 deletions(-)
24
25diff --git a/ioctl.c b/ioctl.c
26index 0385203..8d4a162 100644
27--- a/ioctl.c
28+++ b/ioctl.c
29@@ -1124,7 +1124,7 @@ static struct ctl_table verbosity_ctl_dir[] = {
30 .mode = 0644,
31 .proc_handler = proc_dointvec,
32 },
33- {0, },
34+ {},
35 };
36
37 static struct ctl_table verbosity_ctl_root[] = {
38@@ -1133,7 +1133,7 @@ static struct ctl_table verbosity_ctl_root[] = {
39 .mode = 0555,
40 .child = verbosity_ctl_dir,
41 },
42- {0, },
43+ {},
44 };
45 static struct ctl_table_header *verbosity_sysctl_header;
46 static int __init init_cryptodev(void)
47--
482.7.4
49
diff --git a/meta/recipes-kernel/cryptodev/files/0001-ioctl.c-Fix-build-with-linux-4.17.patch b/meta/recipes-kernel/cryptodev/files/0001-ioctl.c-Fix-build-with-linux-4.17.patch
deleted file mode 100644
index 5881d1c4ee..0000000000
--- a/meta/recipes-kernel/cryptodev/files/0001-ioctl.c-Fix-build-with-linux-4.17.patch
+++ /dev/null
@@ -1,43 +0,0 @@
1From f60aa08c63fc02780554a0a12180a478ca27d49f Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Horia=20Geant=C4=83?= <horia.geanta@nxp.com>
3Date: Wed, 23 May 2018 18:43:39 +0300
4Subject: [PATCH] ioctl.c: Fix build with linux 4.17
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Since kernel 4.17-rc1, sys_* syscalls can no longer be called directly:
10819671ff849b ("syscalls: define and explain goal to not call syscalls in the kernel")
11
12Since cryptodev uses sys_close() - and this has been removed in commit:
132ca2a09d6215 ("fs: add ksys_close() wrapper; remove in-kernel calls to sys_close()")
14cryptodev has to be updated to use the ksys_close() wrapper.
15
16Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
17
18Upstream-Status: Backport
19
20Signed-off-by: He Zhe <zhe.he@windriver.com>
21---
22 ioctl.c | 4 ++++
23 1 file changed, 4 insertions(+)
24
25diff --git a/ioctl.c b/ioctl.c
26index d831b0c..2571034 100644
27--- a/ioctl.c
28+++ b/ioctl.c
29@@ -828,7 +828,11 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_)
30 fd = clonefd(filp);
31 ret = put_user(fd, p);
32 if (unlikely(ret)) {
33+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0))
34 sys_close(fd);
35+#else
36+ ksys_close(fd);
37+#endif
38 return ret;
39 }
40 return ret;
41--
422.7.4
43
diff --git a/meta/recipes-kernel/cryptodev/files/0001-refactoring-split-big-function-to-simplify-maintaina.patch b/meta/recipes-kernel/cryptodev/files/0001-refactoring-split-big-function-to-simplify-maintaina.patch
deleted file mode 100644
index f557b5dff6..0000000000
--- a/meta/recipes-kernel/cryptodev/files/0001-refactoring-split-big-function-to-simplify-maintaina.patch
+++ /dev/null
@@ -1,250 +0,0 @@
1From 20dcf071bc3076ee7db9d603cfbe6a06e86c7d5f Mon Sep 17 00:00:00 2001
2From: Cristian Stoica <cristian.stoica@nxp.com>
3Date: Thu, 4 May 2017 15:06:20 +0300
4Subject: [PATCH 1/3] refactoring: split big function to simplify maintainance
5
6The setup of auth_buf in tls and aead is now duplicated but this
7is temporary and allows necessary corrections for the aead case
8with v4.2+ kernels.
9
10Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
11
12Upstream-Status: Backport
13
14Commit ID: 20dcf071bc3076ee7db9d603c
15
16Signed-off-by: Hongzhi.Song <hongzhi.song@windriver.com>
17---
18 authenc.c | 197 ++++++++++++++++++++++++++++++++++++++++----------------------
19 1 file changed, 126 insertions(+), 71 deletions(-)
20
21diff --git a/authenc.c b/authenc.c
22index 1bd7377..28eb0f9 100644
23--- a/authenc.c
24+++ b/authenc.c
25@@ -609,96 +609,151 @@ auth_n_crypt(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop,
26 return 0;
27 }
28
29-/* This is the main crypto function - zero-copy edition */
30-static int
31-__crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop)
32+static int crypto_auth_zc_srtp(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop)
33 {
34- struct scatterlist *dst_sg, *auth_sg, *src_sg;
35+ struct scatterlist *dst_sg, *auth_sg;
36 struct crypt_auth_op *caop = &kcaop->caop;
37- int ret = 0;
38+ int ret;
39
40- if (caop->flags & COP_FLAG_AEAD_SRTP_TYPE) {
41- if (unlikely(ses_ptr->cdata.init != 0 &&
42- (ses_ptr->cdata.stream == 0 ||
43- ses_ptr->cdata.aead != 0))) {
44- derr(0, "Only stream modes are allowed in SRTP mode (but not AEAD)");
45- return -EINVAL;
46- }
47+ if (unlikely(ses_ptr->cdata.init != 0 &&
48+ (ses_ptr->cdata.stream == 0 || ses_ptr->cdata.aead != 0))) {
49+ derr(0, "Only stream modes are allowed in SRTP mode (but not AEAD)");
50+ return -EINVAL;
51+ }
52
53- ret = get_userbuf_srtp(ses_ptr, kcaop, &auth_sg, &dst_sg);
54- if (unlikely(ret)) {
55- derr(1, "get_userbuf_srtp(): Error getting user pages.");
56- return ret;
57- }
58+ ret = get_userbuf_srtp(ses_ptr, kcaop, &auth_sg, &dst_sg);
59+ if (unlikely(ret)) {
60+ derr(1, "get_userbuf_srtp(): Error getting user pages.");
61+ return ret;
62+ }
63
64- ret = srtp_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len,
65- dst_sg, caop->len);
66+ ret = srtp_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len,
67+ dst_sg, caop->len);
68
69- release_user_pages(ses_ptr);
70- } else { /* TLS and normal cases. Here auth data are usually small
71- * so we just copy them to a free page, instead of trying
72- * to map them.
73- */
74- unsigned char *auth_buf = NULL;
75- struct scatterlist tmp;
76+ release_user_pages(ses_ptr);
77
78- if (unlikely(caop->auth_len > PAGE_SIZE)) {
79- derr(1, "auth data len is excessive.");
80- return -EINVAL;
81- }
82+ return ret;
83+}
84
85- auth_buf = (char *)__get_free_page(GFP_KERNEL);
86- if (unlikely(!auth_buf)) {
87- derr(1, "unable to get a free page.");
88- return -ENOMEM;
89- }
90+static int crypto_auth_zc_tls(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop)
91+{
92+ struct crypt_auth_op *caop = &kcaop->caop;
93+ struct scatterlist *dst_sg, *auth_sg;
94+ unsigned char *auth_buf = NULL;
95+ struct scatterlist tmp;
96+ int ret;
97
98- if (caop->auth_src && caop->auth_len > 0) {
99- if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) {
100- derr(1, "unable to copy auth data from userspace.");
101- ret = -EFAULT;
102- goto free_auth_buf;
103- }
104+ if (unlikely(ses_ptr->cdata.aead != 0)) {
105+ return -EINVAL;
106+ }
107+
108+ if (unlikely(caop->auth_len > PAGE_SIZE)) {
109+ derr(1, "auth data len is excessive.");
110+ return -EINVAL;
111+ }
112+
113+ auth_buf = (char *)__get_free_page(GFP_KERNEL);
114+ if (unlikely(!auth_buf)) {
115+ derr(1, "unable to get a free page.");
116+ return -ENOMEM;
117+ }
118
119- sg_init_one(&tmp, auth_buf, caop->auth_len);
120- auth_sg = &tmp;
121- } else {
122- auth_sg = NULL;
123+ if (caop->auth_src && caop->auth_len > 0) {
124+ if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) {
125+ derr(1, "unable to copy auth data from userspace.");
126+ ret = -EFAULT;
127+ goto free_auth_buf;
128 }
129
130- if (caop->flags & COP_FLAG_AEAD_TLS_TYPE && ses_ptr->cdata.aead == 0) {
131- ret = get_userbuf_tls(ses_ptr, kcaop, &dst_sg);
132- if (unlikely(ret)) {
133- derr(1, "get_userbuf_tls(): Error getting user pages.");
134- goto free_auth_buf;
135- }
136+ sg_init_one(&tmp, auth_buf, caop->auth_len);
137+ auth_sg = &tmp;
138+ } else {
139+ auth_sg = NULL;
140+ }
141
142- ret = tls_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len,
143- dst_sg, caop->len);
144- } else {
145- if (unlikely(ses_ptr->cdata.init == 0 ||
146- (ses_ptr->cdata.stream == 0 &&
147- ses_ptr->cdata.aead == 0))) {
148- derr(0, "Only stream and AEAD ciphers are allowed for authenc");
149- ret = -EINVAL;
150- goto free_auth_buf;
151- }
152+ ret = get_userbuf_tls(ses_ptr, kcaop, &dst_sg);
153+ if (unlikely(ret)) {
154+ derr(1, "get_userbuf_tls(): Error getting user pages.");
155+ goto free_auth_buf;
156+ }
157
158- ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len,
159- kcaop->task, kcaop->mm, &src_sg, &dst_sg);
160- if (unlikely(ret)) {
161- derr(1, "get_userbuf(): Error getting user pages.");
162- goto free_auth_buf;
163- }
164+ ret = tls_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len,
165+ dst_sg, caop->len);
166+ release_user_pages(ses_ptr);
167+
168+free_auth_buf:
169+ free_page((unsigned long)auth_buf);
170+ return ret;
171+}
172+
173+static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop)
174+{
175+ struct scatterlist *dst_sg, *auth_sg, *src_sg;
176+ struct crypt_auth_op *caop = &kcaop->caop;
177+ unsigned char *auth_buf = NULL;
178+ struct scatterlist tmp;
179+ int ret;
180
181- ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len,
182- src_sg, dst_sg, caop->len);
183+ if (unlikely(ses_ptr->cdata.init == 0 ||
184+ (ses_ptr->cdata.stream == 0 && ses_ptr->cdata.aead == 0))) {
185+ derr(0, "Only stream and AEAD ciphers are allowed for authenc");
186+ return -EINVAL;
187+ }
188+
189+ if (unlikely(caop->auth_len > PAGE_SIZE)) {
190+ derr(1, "auth data len is excessive.");
191+ return -EINVAL;
192+ }
193+
194+ auth_buf = (char *)__get_free_page(GFP_KERNEL);
195+ if (unlikely(!auth_buf)) {
196+ derr(1, "unable to get a free page.");
197+ return -ENOMEM;
198+ }
199+
200+ if (caop->auth_src && caop->auth_len > 0) {
201+ if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) {
202+ derr(1, "unable to copy auth data from userspace.");
203+ ret = -EFAULT;
204+ goto free_auth_buf;
205 }
206
207- release_user_pages(ses_ptr);
208+ sg_init_one(&tmp, auth_buf, caop->auth_len);
209+ auth_sg = &tmp;
210+ } else {
211+ auth_sg = NULL;
212+ }
213+
214+ ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len,
215+ kcaop->task, kcaop->mm, &src_sg, &dst_sg);
216+ if (unlikely(ret)) {
217+ derr(1, "get_userbuf(): Error getting user pages.");
218+ goto free_auth_buf;
219+ }
220+
221+ ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len,
222+ src_sg, dst_sg, caop->len);
223+
224+ release_user_pages(ses_ptr);
225
226 free_auth_buf:
227- free_page((unsigned long)auth_buf);
228+ free_page((unsigned long)auth_buf);
229+
230+ return ret;
231+}
232+
233+static int
234+__crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop)
235+{
236+ struct crypt_auth_op *caop = &kcaop->caop;
237+ int ret;
238+
239+ if (caop->flags & COP_FLAG_AEAD_SRTP_TYPE) {
240+ ret = crypto_auth_zc_srtp(ses_ptr, kcaop);
241+ } else if (caop->flags & COP_FLAG_AEAD_TLS_TYPE) {
242+ ret = crypto_auth_zc_tls(ses_ptr, kcaop);
243+ } else {
244+ ret = crypto_auth_zc_aead(ses_ptr, kcaop);
245 }
246
247 return ret;
248--
2492.11.0
250
diff --git a/meta/recipes-kernel/cryptodev/files/0002-refactoring-relocate-code-to-simplify-later-patches.patch b/meta/recipes-kernel/cryptodev/files/0002-refactoring-relocate-code-to-simplify-later-patches.patch
deleted file mode 100644
index 83d9005a06..0000000000
--- a/meta/recipes-kernel/cryptodev/files/0002-refactoring-relocate-code-to-simplify-later-patches.patch
+++ /dev/null
@@ -1,64 +0,0 @@
1From c2bf0e42b1d9fda60cde4a3a682784d349ef1c0b Mon Sep 17 00:00:00 2001
2From: Cristian Stoica <cristian.stoica@nxp.com>
3Date: Thu, 4 May 2017 15:06:21 +0300
4Subject: [PATCH 2/3] refactoring: relocate code to simplify later patches
5
6This code move will simplify the conversion to new AEAD interface in
7next patches
8
9Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
10
11Upstream-Status: Backport
12
13Commit ID: c2bf0e42b1d9fda
14
15Signed-off-by: Hongzhi.Song <hongzhi.song@windriver.com>
16---
17 authenc.c | 17 +++++++++--------
18 1 file changed, 9 insertions(+), 8 deletions(-)
19
20diff --git a/authenc.c b/authenc.c
21index 28eb0f9..95727b4 100644
22--- a/authenc.c
23+++ b/authenc.c
24@@ -711,11 +711,18 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut
25 return -ENOMEM;
26 }
27
28+ ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len,
29+ kcaop->task, kcaop->mm, &src_sg, &dst_sg);
30+ if (unlikely(ret)) {
31+ derr(1, "get_userbuf(): Error getting user pages.");
32+ goto free_auth_buf;
33+ }
34+
35 if (caop->auth_src && caop->auth_len > 0) {
36 if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) {
37 derr(1, "unable to copy auth data from userspace.");
38 ret = -EFAULT;
39- goto free_auth_buf;
40+ goto free_pages;
41 }
42
43 sg_init_one(&tmp, auth_buf, caop->auth_len);
44@@ -724,16 +731,10 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut
45 auth_sg = NULL;
46 }
47
48- ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len,
49- kcaop->task, kcaop->mm, &src_sg, &dst_sg);
50- if (unlikely(ret)) {
51- derr(1, "get_userbuf(): Error getting user pages.");
52- goto free_auth_buf;
53- }
54-
55 ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len,
56 src_sg, dst_sg, caop->len);
57
58+free_pages:
59 release_user_pages(ses_ptr);
60
61 free_auth_buf:
62--
632.11.0
64
diff --git a/meta/recipes-kernel/cryptodev/files/0003-convert-to-new-AEAD-interface-in-kernels-v4.2.patch b/meta/recipes-kernel/cryptodev/files/0003-convert-to-new-AEAD-interface-in-kernels-v4.2.patch
deleted file mode 100644
index 860230778b..0000000000
--- a/meta/recipes-kernel/cryptodev/files/0003-convert-to-new-AEAD-interface-in-kernels-v4.2.patch
+++ /dev/null
@@ -1,102 +0,0 @@
1From a705360197260d28535746ae98c461ba2cfb7a9e Mon Sep 17 00:00:00 2001
2From: Cristian Stoica <cristian.stoica@nxp.com>
3Date: Thu, 4 May 2017 15:06:22 +0300
4Subject: [PATCH 3/3] convert to new AEAD interface in kernels v4.2+
5
6The crypto API for AEAD ciphers changed in recent kernels so that
7associated data is now part of both source and destination scatter
8gathers. The source, destination and associated data buffers need
9to be stiched accordingly for the operations to succeed:
10
11src_sg: auth_buf + src_buf
12dst_sg: auth_buf + (dst_buf + tag space)
13
14This patch fixes a kernel crash observed with cipher-gcm test.
15
16See also kernel patch: 81c4c35eb61a69c229871c490b011c1171511d5a
17 crypto: ccm - Convert to new AEAD interface
18
19Reported-by: Phil Sutter <phil@nwl.cc>
20Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
21
22Upstream-Status: Backport
23
24Commit ID: a705360197260d2853574
25
26Signed-off-by: Hongzhi.Song <hongzhi.song@windriver.com>
27---
28 authenc.c | 40 ++++++++++++++++++++++++++++++++++++++--
29 1 file changed, 38 insertions(+), 2 deletions(-)
30
31diff --git a/authenc.c b/authenc.c
32index 95727b4..692951f 100644
33--- a/authenc.c
34+++ b/authenc.c
35@@ -688,12 +688,20 @@ free_auth_buf:
36
37 static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop)
38 {
39- struct scatterlist *dst_sg, *auth_sg, *src_sg;
40+ struct scatterlist *dst_sg;
41+ struct scatterlist *src_sg;
42 struct crypt_auth_op *caop = &kcaop->caop;
43 unsigned char *auth_buf = NULL;
44- struct scatterlist tmp;
45 int ret;
46
47+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0))
48+ struct scatterlist tmp;
49+ struct scatterlist *auth_sg;
50+#else
51+ struct scatterlist auth1[2];
52+ struct scatterlist auth2[2];
53+#endif
54+
55 if (unlikely(ses_ptr->cdata.init == 0 ||
56 (ses_ptr->cdata.stream == 0 && ses_ptr->cdata.aead == 0))) {
57 derr(0, "Only stream and AEAD ciphers are allowed for authenc");
58@@ -718,6 +726,7 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut
59 goto free_auth_buf;
60 }
61
62+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0))
63 if (caop->auth_src && caop->auth_len > 0) {
64 if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) {
65 derr(1, "unable to copy auth data from userspace.");
66@@ -733,6 +742,33 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut
67
68 ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len,
69 src_sg, dst_sg, caop->len);
70+#else
71+ if (caop->auth_src && caop->auth_len > 0) {
72+ if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) {
73+ derr(1, "unable to copy auth data from userspace.");
74+ ret = -EFAULT;
75+ goto free_pages;
76+ }
77+
78+ sg_init_table(auth1, 2);
79+ sg_set_buf(auth1, auth_buf, caop->auth_len);
80+ sg_chain(auth1, 2, src_sg);
81+
82+ if (src_sg == dst_sg) {
83+ src_sg = auth1;
84+ dst_sg = auth1;
85+ } else {
86+ sg_init_table(auth2, 2);
87+ sg_set_buf(auth2, auth_buf, caop->auth_len);
88+ sg_chain(auth2, 2, dst_sg);
89+ src_sg = auth1;
90+ dst_sg = auth2;
91+ }
92+ }
93+
94+ ret = auth_n_crypt(ses_ptr, kcaop, NULL, caop->auth_len,
95+ src_sg, dst_sg, caop->len);
96+#endif
97
98 free_pages:
99 release_user_pages(ses_ptr);
100--
1012.11.0
102