>From fb7fb5e4bd7ccb8efa691364404efc7804fad90c Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 28 Feb 2023 12:18:43 -0500 Subject: [PATCH 1/2] fix pipe2 silently ignoring unknown flags on old kernels kernels using the fallback have an inherent close-on-exec race condition and as such support for them is only best-effort anyway. however, ignoring potential new flags is still very bad behavior. instead, fail with EINVAL. --- src/unistd/pipe2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unistd/pipe2.c b/src/unistd/pipe2.c index f24f74fb..a096990b 100644 --- a/src/unistd/pipe2.c +++ b/src/unistd/pipe2.c @@ -8,6 +8,7 @@ int pipe2(int fd[2], int flag) if (!flag) return pipe(fd); int ret = __syscall(SYS_pipe2, fd, flag); if (ret != -ENOSYS) return __syscall_ret(ret); + if (flag & ~(O_CLOEXEC|O_NONBLOCK)) return __syscall_ret(-EINVAL); ret = pipe(fd); if (ret) return ret; if (flag & O_CLOEXEC) { -- 2.21.0