From 7569a4b27c46c85a9d942b650db87e034774bf42 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 7 Feb 2024 10:03:55 +0100 Subject: executor: don't fail on setns() in pseudo syscalls The fd may be closed by an async close() call, it's not a reason to report a failure. Reported-by: Andrei Vagin --- executor/common_linux.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'executor') diff --git a/executor/common_linux.h b/executor/common_linux.h index 98339194f..6b96d8cea 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -2479,8 +2479,11 @@ static long syz_init_net_socket(volatile long domain, volatile long type, volati return -1; int sock = syscall(__NR_socket, domain, type, proto); int err = errno; - if (setns(netns, 0)) - fail("setns(netns) failed"); + if (setns(netns, 0)) { + // The operation may fail if the fd is closed by + // a syscall from another thread. + exitf("setns(netns) failed"); + } close(netns); errno = err; return sock; @@ -2514,8 +2517,11 @@ static long syz_socket_connect_nvme_tcp() return -1; int sock = syscall(__NR_socket, AF_INET, SOCK_STREAM, 0x0); int err = errno; - if (setns(netns, 0)) - fail("setns(netns) failed"); + if (setns(netns, 0)) { + // The operation may fail if the fd is closed by + // a syscall from another thread. + exitf("setns(netns) failed"); + } close(netns); errno = err; // We only connect to an NVMe-oF/TCP server on 127.0.0.1:4420 -- cgit mrf-deployment