aboutsummaryrefslogtreecommitdiffstats
path: root/executor
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-02-07 10:03:55 +0100
committerAleksandr Nogikh <nogikh@google.com>2024-02-08 11:35:00 +0000
commit7569a4b27c46c85a9d942b650db87e034774bf42 (patch)
treeaa722ff46350df0a1d7d333d8d9483044cde387a /executor
parent6404acf9ce200d01fcbe0923924c9f6c22c258de (diff)
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 <avagin@google.com>
Diffstat (limited to 'executor')
-rw-r--r--executor/common_linux.h14
1 files changed, 10 insertions, 4 deletions
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