fuse_lowlevel: Add O_CLOEXEC to pipe-max-size procfs open

grow_pipe_to_max() opens /proc/sys/fs/pipe-max-size without O_CLOEXEC.
In a multi-threaded FUSE daemon, a concurrent fork+exec (e.g., to
invoke fusermount) between the open() and close() calls would leak this
fd into the child process.

Add the same O_CLOEXEC fallback guard used in mount.c and
fuse_loop_mt.c for portability to older headers.

Signed-off-by: Abhinav Agarwal <abhinavagarwal1996@gmail.com>
This commit is contained in:
Abhinav Agarwal
2026-04-15 10:15:27 -07:00
committed by Bernd Schubert
parent 349b83231b
commit 79aefd4fd9
+5 -1
View File
@@ -57,6 +57,10 @@
#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
#define PARAM(inarg) (((char *)(inarg)) + sizeof(*(inarg)))
#define OFFSET_MAX 0x7fffffffffffffffLL
@@ -815,7 +819,7 @@ static int grow_pipe_to_max(int pipefd)
long maxfd;
char buf[32];
maxfd = open("/proc/sys/fs/pipe-max-size", O_RDONLY);
maxfd = open("/proc/sys/fs/pipe-max-size", O_RDONLY | O_CLOEXEC);
if (maxfd < 0)
return -errno;