diff options
| -rw-r--r-- | meta-oe/recipes-crypto/libkcapi/libkcapi/0001-kcapi-kernel-if-Adjust-for-musl-msghdr-struct-compat.patch | 81 | ||||
| -rw-r--r-- | meta-oe/recipes-crypto/libkcapi/libkcapi_1.3.1.bb | 4 |
2 files changed, 84 insertions, 1 deletions
diff --git a/meta-oe/recipes-crypto/libkcapi/libkcapi/0001-kcapi-kernel-if-Adjust-for-musl-msghdr-struct-compat.patch b/meta-oe/recipes-crypto/libkcapi/libkcapi/0001-kcapi-kernel-if-Adjust-for-musl-msghdr-struct-compat.patch new file mode 100644 index 0000000000..687eb359cf --- /dev/null +++ b/meta-oe/recipes-crypto/libkcapi/libkcapi/0001-kcapi-kernel-if-Adjust-for-musl-msghdr-struct-compat.patch | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | From d54e532821d40f8094a49742831d32ec7e76caed Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Thu, 16 Dec 2021 15:18:21 -0800 | ||
| 4 | Subject: [PATCH] kcapi-kernel-if: Adjust for musl msghdr struct compatibility | ||
| 5 | |||
| 6 | musl sticks to POSIX and defines msg_iovlen and msg_controllen as int | ||
| 7 | and socklen_t types respectively whereas glibc and kernel mark them as | ||
| 8 | size_t which is them assumed as such in the code here as well, Make the | ||
| 9 | needed conversions to get it going on musl/linux also see [1] for more | ||
| 10 | info | ||
| 11 | |||
| 12 | [1] https://git.musl-libc.org/cgit/musl/commit/?id=7168790763cdeb794df52be6e3b39fbb021c5a64 | ||
| 13 | |||
| 14 | Upstream-Status: Submitted [https://github.com/smuellerDD/libkcapi/pull/131] | ||
| 15 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 16 | --- | ||
| 17 | lib/kcapi-kernel-if.c | 22 ++++++++++++++++++---- | ||
| 18 | 1 file changed, 18 insertions(+), 4 deletions(-) | ||
| 19 | |||
| 20 | diff --git a/lib/kcapi-kernel-if.c b/lib/kcapi-kernel-if.c | ||
| 21 | index 739841e..e5d15d4 100644 | ||
| 22 | --- a/lib/kcapi-kernel-if.c | ||
| 23 | +++ b/lib/kcapi-kernel-if.c | ||
| 24 | @@ -168,10 +168,14 @@ ssize_t _kcapi_common_send_meta(struct kcapi_handle *handle, | ||
| 25 | } | ||
| 26 | |||
| 27 | msg.msg_control = buffer_p; | ||
| 28 | - msg.msg_controllen = bufferlen; | ||
| 29 | msg.msg_iov = iov; | ||
| 30 | +#ifdef __GLIBC__ | ||
| 31 | msg.msg_iovlen = iovlen; | ||
| 32 | - | ||
| 33 | + msg.msg_controllen = bufferlen; | ||
| 34 | +#else | ||
| 35 | + msg.msg_iovlen = (int)iovlen; | ||
| 36 | + msg.msg_controllen = (socklen_t)bufferlen; | ||
| 37 | +#endif | ||
| 38 | /* encrypt/decrypt operation */ | ||
| 39 | header = CMSG_FIRSTHDR(&msg); | ||
| 40 | if (!header) { | ||
| 41 | @@ -193,7 +197,11 @@ ssize_t _kcapi_common_send_meta(struct kcapi_handle *handle, | ||
| 42 | } | ||
| 43 | header->cmsg_level = SOL_ALG; | ||
| 44 | header->cmsg_type = ALG_SET_IV; | ||
| 45 | +#ifdef __GLIBC__ | ||
| 46 | header->cmsg_len = iv_msg_size; | ||
| 47 | +#else | ||
| 48 | + header->cmsg_len = (socklen_t)iv_msg_size; | ||
| 49 | +#endif | ||
| 50 | alg_iv = (void*)CMSG_DATA(header); | ||
| 51 | alg_iv->ivlen = tfm->info.ivsize; | ||
| 52 | memcpy(alg_iv->iv, handle->cipher.iv, tfm->info.ivsize); | ||
| 53 | @@ -244,8 +252,11 @@ ssize_t _kcapi_common_send_data(struct kcapi_handle *handle, | ||
| 54 | msg.msg_controllen = 0; | ||
| 55 | msg.msg_flags = 0; | ||
| 56 | msg.msg_iov = iov; | ||
| 57 | +#ifdef __GLIBC__ | ||
| 58 | msg.msg_iovlen = iovlen; | ||
| 59 | - | ||
| 60 | +#else | ||
| 61 | + msg.msg_iovlen = (int)iovlen; | ||
| 62 | +#endif | ||
| 63 | ret = sendmsg(*_kcapi_get_opfd(handle), &msg, (int)flags); | ||
| 64 | if (ret < 0) | ||
| 65 | ret = -errno; | ||
| 66 | @@ -542,8 +553,11 @@ ssize_t _kcapi_common_recv_data(struct kcapi_handle *handle, | ||
| 67 | msg.msg_controllen = 0; | ||
| 68 | msg.msg_flags = 0; | ||
| 69 | msg.msg_iov = iov; | ||
| 70 | +#ifdef __GLIBC__ | ||
| 71 | msg.msg_iovlen = iovlen; | ||
| 72 | - | ||
| 73 | +#else | ||
| 74 | + msg.msg_iovlen = (int)iovlen; | ||
| 75 | +#endif | ||
| 76 | ret = recvmsg(*_kcapi_get_opfd(handle), &msg, 0); | ||
| 77 | if (ret < 0) | ||
| 78 | ret = -errno; | ||
| 79 | -- | ||
| 80 | 2.34.1 | ||
| 81 | |||
diff --git a/meta-oe/recipes-crypto/libkcapi/libkcapi_1.3.1.bb b/meta-oe/recipes-crypto/libkcapi/libkcapi_1.3.1.bb index f10d684701..1bd587f0bc 100644 --- a/meta-oe/recipes-crypto/libkcapi/libkcapi_1.3.1.bb +++ b/meta-oe/recipes-crypto/libkcapi/libkcapi_1.3.1.bb | |||
| @@ -5,7 +5,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=80c467906eb826339c7f09e61808ed23" | |||
| 5 | 5 | ||
| 6 | S = "${WORKDIR}/git" | 6 | S = "${WORKDIR}/git" |
| 7 | SRCREV = "2936ecd060c299157ac880650ba2c9fd94d27bb1" | 7 | SRCREV = "2936ecd060c299157ac880650ba2c9fd94d27bb1" |
| 8 | SRC_URI = "git://github.com/smuellerDD/libkcapi.git;branch=master;protocol=https" | 8 | SRC_URI = "git://github.com/smuellerDD/libkcapi.git;branch=master;protocol=https \ |
| 9 | file://0001-kcapi-kernel-if-Adjust-for-musl-msghdr-struct-compat.patch \ | ||
| 10 | " | ||
| 9 | 11 | ||
| 10 | inherit autotools | 12 | inherit autotools |
| 11 | 13 | ||
