This series fixes issues and warnings I spotted in Martin's build logs for OpenSUSE on armv6l and armv7l (patches 1/7 to 3/7). I couldn't find (yet) a convenient way to add armv6l and armv7l OpenSUSE builds to the tests using qemu TCG (suggestions welcome!) so I tried things out on a Raspberry Pi Zero and a Raspberry Pi 4 for the moment being -- patches 4/7 to 7/7 fix the other issues I hit there. Stefano Brivio (7): passt: Explicitly check return value of chdir() udp: Explicitly initialise sin6_scope_id and sin_zero in sockaddr_in{,6} seccomp.sh: Handle syscall number defines in the (x + y) form tap: Cast ETH_MAX_MTU to signed in comparisons Makefile: Fix up AUDIT_ARCH for armv6l, armv7l passt: Don't warn on failed madvise() seccomp: Adjust list of allowed syscalls for armv6l, armv7l Makefile | 1 + passt.c | 15 +++++++++------ pasta.c | 3 ++- seccomp.sh | 3 +++ tap.c | 4 ++-- udp.c | 2 ++ util.c | 3 ++- 7 files changed, 21 insertions(+), 10 deletions(-) -- 2.34.1
...it doesn't actually matter as we're checking errno at the very end, but, depending on build flags, chdir() might be declared with warn_unused_result and the compiler issues a warning. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- passt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/passt.c b/passt.c index 3d18d1f..038d50a 100644 --- a/passt.c +++ b/passt.c @@ -260,7 +260,9 @@ static int sandbox(struct ctx *c) mount("", "/", "", MS_UNBINDABLE | MS_REC, NULL); mount("", TMPDIR, "tmpfs", MS_NODEV | MS_NOEXEC | MS_NOSUID | MS_RDONLY, "nr_inodes=2,nr_blocks=0"); - chdir(TMPDIR); + if (chdir(TMPDIR)) + return -errno; + syscall(SYS_pivot_root, ".", "."); umount2(".", MNT_DETACH | UMOUNT_NOFOLLOW); -- 2.34.1
Not functionally needed, but gcc versions 7 to 9 (at least) will issue a warning otherwise. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- udp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/udp.c b/udp.c index d4f3714..ccce005 100644 --- a/udp.c +++ b/udp.c @@ -640,6 +640,7 @@ static void udp_sock_handler_splice(struct ctx *c, union epoll_ref ref, .sin6_family = AF_INET6, .sin6_addr = IN6ADDR_LOOPBACK_INIT, .sin6_port = htons(send_dst), + .sin6_scope_id = 0, }); } else { *((struct sockaddr_in *)&udp_splice_namebuf) = @@ -647,6 +648,7 @@ static void udp_sock_handler_splice(struct ctx *c, union epoll_ref ref, .sin_family = AF_INET, .sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) }, .sin_port = htons(send_dst), + .sin_zero = { 0 }, }); } -- 2.34.1
This is the case at least for current glibc headers on armv6l and armv7l. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- seccomp.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/seccomp.sh b/seccomp.sh index f5ee98e..6ac59a1 100755 --- a/seccomp.sh +++ b/seccomp.sh @@ -109,6 +109,9 @@ syscall_nr() { __in="$(printf "#include <asm-generic/unistd.h>\n#include <sys/syscall.h>\n__NR_%s" ${1})" __out="$(echo "${__in}" | cc -E -xc - -o - | tail -1)" [ "${__out}" = "__NR_$1" ] && return 1 + + # Output might be in the form "(x + y)" (seen on armv6l, armv7l) + __out="$(eval echo $((${__out})))" echo "${__out}" } -- 2.34.1
At least gcc 8.3 and 10.2 emit a warning on armv6l and armv7l. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tap.c b/tap.c index 9e6ece9..29fcd51 100644 --- a/tap.c +++ b/tap.c @@ -658,7 +658,7 @@ redo: /* Complete the partial read above before discarding a malformed * frame, otherwise the stream will be inconsistent. */ - if (len < (ssize_t)sizeof(*eh) || len > ETH_MAX_MTU) + if (len < (ssize_t)sizeof(*eh) || len > (ssize_t)ETH_MAX_MTU) goto next; pcap(p, len); @@ -718,7 +718,7 @@ restart: while ((len = read(c->fd_tap, pkt_buf + n, TAP_BUF_BYTES - n)) > 0) { struct ethhdr *eh = (struct ethhdr *)(pkt_buf + n); - if (len < (ssize_t)sizeof(*eh) || len > ETH_MAX_MTU) { + if (len < (ssize_t)sizeof(*eh) || len > (ssize_t)ETH_MAX_MTU) { n += len; continue; } -- 2.34.1
There's a single AUDIT_ARCH_ARM define available (and big-endian shouldn't be a concern with those). Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 28ef316..031b684 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ RLIMIT_STACK_VAL := 1024 endif AUDIT_ARCH := $(shell uname -m | tr [a-z] [A-Z]) +AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/^ARM.*/ARM/') AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/I[456]86/I386/') AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/PPC64/PPC/') AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/PPCLE/PPC64LE/') -- 2.34.1
A kernel might not be configured with CONFIG_TRANSPARENT_HUGEPAGE, especially on embedded systems. Ignore the error, it doesn't affect functionality. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- passt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/passt.c b/passt.c index 038d50a..22934a2 100644 --- a/passt.c +++ b/passt.c @@ -339,8 +339,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } - if (madvise(pkt_buf, TAP_BUF_BYTES, MADV_HUGEPAGE)) - perror("madvise"); + madvise(pkt_buf, TAP_BUF_BYTES, MADV_HUGEPAGE); __openlog(log_name, 0, LOG_DAEMON); -- 2.34.1
It looks like glibc commonly implements clock_gettime(2) with clock_gettime64(), and uses recv() instead of recvfrom(), send() instead of sendto(), and sigreturn() instead of rt_sigreturn() on armv6l and armv7l. Adjust the list of system calls for armv6l and armv7l accordingly. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- passt.c | 8 +++++--- pasta.c | 3 ++- util.c | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/passt.c b/passt.c index 22934a2..e7dd108 100644 --- a/passt.c +++ b/passt.c @@ -297,9 +297,11 @@ void exit_handler(int signal) * * #syscalls read write writev * #syscalls socket bind connect getsockopt setsockopt s390x:socketcall close - * #syscalls recvfrom sendto shutdown ppc64le:recv ppc64le:send - * #syscalls accept4|accept listen - * #syscalls epoll_ctl epoll_wait|epoll_pwait epoll_pwait clock_gettime + * #syscalls recvfrom sendto shutdown + * #syscalls armv6l:recv armv7l:recv ppc64le:recv + * #syscalls armv6l:send armv7l:send ppc64le:send + * #syscalls accept4|accept listen epoll_ctl epoll_wait|epoll_pwait epoll_pwait + * #syscalls clock_gettime armv6l:clock_gettime64 armv7l:clock_gettime64 */ int main(int argc, char **argv) { diff --git a/pasta.c b/pasta.c index e45cc92..96866c6 100644 --- a/pasta.c +++ b/pasta.c @@ -12,7 +12,8 @@ * Author: Stefano Brivio <sbrivio(a)redhat.com> * * #syscalls:pasta clone waitid exit exit_group rt_sigprocmask - * #syscalls:pasta rt_sigreturn|sigreturn ppc64:sigreturn s390x:sigreturn + * #syscalls:pasta rt_sigreturn|sigreturn armv6l:sigreturn armv7l:sigreturn + * #syscalls:pasta ppc64:sigreturn s390x:sigreturn */ #include <sched.h> diff --git a/util.c b/util.c index e9fca3b..90b5ab8 100644 --- a/util.c +++ b/util.c @@ -441,7 +441,8 @@ char *line_read(char *buf, size_t len, int fd) * @map: Bitmap where numbers of ports in listening state will be set * @exclude: Bitmap of ports to exclude from setting (and clear) * - * #syscalls:pasta lseek ppc64le:_llseek ppc64:_llseek + * #syscalls:pasta lseek + * #syscalls:pasta ppc64le:_llseek ppc64:_llseek armv6l:_llseek armv7l:_llseek */ void procfs_scan_listen(struct ctx *c, uint8_t proto, int ip_version, int ns, uint8_t *map, uint8_t *exclude) -- 2.34.1