diff options
author | Ariadne Conill <ariadne@dereferenced.org> | 2022-01-20 22:38:44 +0000 |
---|---|---|
committer | Ariadne Conill <ariadne@dereferenced.org> | 2022-01-20 22:38:44 +0000 |
commit | c70367d4096801f748891c7a40940bbb056c3db6 (patch) | |
tree | 9fd32e0f1a9a91a15dcdc9bc2e9317d0e01bef8a | |
parent | 71f67074b73871194531fc64c5eba23c98626743 (diff) | |
download | aports-c70367d4096801f748891c7a40940bbb056c3db6.tar.gz aports-c70367d4096801f748891c7a40940bbb056c3db6.tar.bz2 aports-c70367d4096801f748891c7a40940bbb056c3db6.tar.xz |
main/libuv: fix padding when calling recvmmsg(3)
libc verses kernel structure layout differences caused the structure
to not be properly initialized in all cases (namely s390x)
noticed by @alxu
-rw-r--r-- | main/libuv/APKBUILD | 6 | ||||
-rw-r--r-- | main/libuv/recvmmsg-padding.patch | 63 |
2 files changed, 67 insertions, 2 deletions
diff --git a/main/libuv/APKBUILD b/main/libuv/APKBUILD index f6e56b4fb4..ee5cb77a1f 100644 --- a/main/libuv/APKBUILD +++ b/main/libuv/APKBUILD @@ -3,7 +3,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=libuv pkgver=1.43.0 -pkgrel=0 +pkgrel=1 pkgdesc="Cross-platform asychronous I/O" url="https://libuv.org/" arch="all" @@ -11,7 +11,8 @@ license="MIT AND ISC" makedepends_build="automake autoconf libtool" makedepends_host="linux-headers" subpackages="$pkgname-static $pkgname-dev $pkgname-dbg" -source="https://dist.libuv.org/dist/v$pkgver/libuv-v$pkgver.tar.gz" +source="https://dist.libuv.org/dist/v$pkgver/libuv-v$pkgver.tar.gz + recvmmsg-padding.patch" builddir="$srcdir/$pkgname-v$pkgver" # secfixes: @@ -46,4 +47,5 @@ package() { sha512sums=" ba48140ac5733e09462a731fe9194c902b011a1a93a63175949c616367bde56bd1c114e8487c5580bee2d4656b45ab8cdc4fc335f67dd35e793c1a943f69fb34 libuv-v1.43.0.tar.gz +25d8bd89eda953aca9f879d3cad49ad9a02b9ac69fc2a69839f45ca9e0da6f8a2ffd1d7a6c491bd38537dcfa59a800301ca278310c7c90584f6c4a73562ad3ed recvmmsg-padding.patch " diff --git a/main/libuv/recvmmsg-padding.patch b/main/libuv/recvmmsg-padding.patch new file mode 100644 index 0000000000..c6c850d1d5 --- /dev/null +++ b/main/libuv/recvmmsg-padding.patch @@ -0,0 +1,63 @@ +From e9cb18484ecdc10e005d306db53d099e06ade9f4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= <ondrej@sury.org> +Date: Sat, 15 Jan 2022 06:24:37 +0100 +Subject: [PATCH] unix: ensure struct msghdr is zeroed in recvmmsg (#3419) + +With MUSL libc, the struct msghdr is padded to align with the types used +in the Linux kernel headers (int vs size_t). When the padding was not +zeroed, the syscall would return EMSGSIZE because the random bytes in +the padding would be read by kernel as part of the size_t type. + +Fixes: https://github.com/libuv/libuv/issues/3416 +--- + src/unix/udp.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/src/unix/udp.c b/src/unix/udp.c +index aee8d63934..74ef398a06 100644 +--- a/src/unix/udp.c ++++ b/src/unix/udp.c +@@ -201,6 +201,7 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) { + for (k = 0; k < chunks; ++k) { + iov[k].iov_base = buf->base + k * UV__UDP_DGRAM_MAXSIZE; + iov[k].iov_len = UV__UDP_DGRAM_MAXSIZE; ++ memset(&msgs[k].msg_hdr, 0, sizeof(msgs[k].msg_hdr)); + msgs[k].msg_hdr.msg_iov = iov + k; + msgs[k].msg_hdr.msg_iovlen = 1; + msgs[k].msg_hdr.msg_name = peers + k; +@@ -655,16 +656,16 @@ int uv__udp_connect(uv_udp_t* handle, + } + + /* From https://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html +- * Any of uv supported UNIXs kernel should be standardized, but the kernel ++ * Any of uv supported UNIXs kernel should be standardized, but the kernel + * implementation logic not same, let's use pseudocode to explain the udp + * disconnect behaviors: +- * ++ * + * Predefined stubs for pseudocode: + * 1. sodisconnect: The function to perform the real udp disconnect + * 2. pru_connect: The function to perform the real udp connect + * 3. so: The kernel object match with socket fd + * 4. addr: The sockaddr parameter from user space +- * ++ * + * BSDs: + * if(sodisconnect(so) == 0) { // udp disconnect succeed + * if (addr->sa_len != so->addr->sa_len) return EINVAL; +@@ -694,13 +695,13 @@ int uv__udp_disconnect(uv_udp_t* handle) { + #endif + + memset(&addr, 0, sizeof(addr)); +- ++ + #if defined(__MVS__) + addr.ss_family = AF_UNSPEC; + #else + addr.sa_family = AF_UNSPEC; + #endif +- ++ + do { + errno = 0; + r = connect(handle->io_watcher.fd, (struct sockaddr*) &addr, sizeof(addr)); |