From b27d6d121c8fad94658bbcf433e99f7fff542550 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Mon, 14 Nov 2022 23:00:27 +0100 Subject: arp, tap, util: Don't use perror() after seccomp filter is installed If stderr is closed, after we fork to background, glibc's implementation of perror() will try to re-open it by calling dup(), upon which the seccomp filter causes the process to terminate, because dup() is not included in the list of allowed syscalls. Replace perror() calls that might happen after isolation_postfork(). We could probably replace all of them, but early ones need a bit more attention as we have to check whether log.c functions work in early stages. Signed-off-by: Stefano Brivio Reviewed-by: David Gibson --- arp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'arp.c') diff --git a/arp.c b/arp.c index 141d43f..930b9ea 100644 --- a/arp.c +++ b/arp.c @@ -24,6 +24,7 @@ #include #include "util.h" +#include "log.h" #include "arp.h" #include "dhcp.h" #include "passt.h" @@ -43,6 +44,7 @@ int arp(const struct ctx *c, const struct pool *p) struct arphdr *ah; struct arpmsg *am; size_t len; + int ret; eh = packet_get(p, 0, 0, sizeof(*eh), NULL); ah = packet_get(p, 0, sizeof(*eh), sizeof(*ah), NULL); @@ -81,8 +83,8 @@ int arp(const struct ctx *c, const struct pool *p) memcpy(eh->h_dest, eh->h_source, sizeof(eh->h_dest)); memcpy(eh->h_source, c->mac, sizeof(eh->h_source)); - if (tap_send(c, eh, len) < 0) - perror("ARP: send"); + if ((ret = tap_send(c, eh, len)) < 0) + warn("ARP: send: %s", strerror(ret)); return 1; } -- cgit v1.2.3