summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2024-08-22 01:51:39 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2024-10-09 17:28:06 +0200
commitb8ea429d7249253ec1fe90dffc648f0668d12385 (patch)
treee0b437967a278a2e1c0de1733f74b31412a53439
parentfile.c: merge __{set,clear}_close_on_exec() (diff)
downloadlinux-b8ea429d7249253ec1fe90dffc648f0668d12385.tar.xz
linux-b8ea429d7249253ec1fe90dffc648f0668d12385.zip
make __set_open_fd() set cloexec state as well
->close_on_exec[] state is maintained only for opened descriptors; as the result, anything that marks a descriptor opened has to set its cloexec state explicitly. As the result, all calls of __set_open_fd() are followed by __set_close_on_exec(); might as well fold it into __set_open_fd() so that cloexec state is defined as soon as the descriptor is marked opened. [braino fix folded] Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/file.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/file.c b/fs/file.c
index d8fccd4796a9..d468a9b6ef4d 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -248,9 +248,10 @@ static inline void __set_close_on_exec(unsigned int fd, struct fdtable *fdt,
}
}
-static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt)
+static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt, bool set)
{
__set_bit(fd, fdt->open_fds);
+ __set_close_on_exec(fd, fdt, set);
fd /= BITS_PER_LONG;
if (!~fdt->open_fds[fd])
__set_bit(fd, fdt->full_fds_bits);
@@ -517,8 +518,7 @@ repeat:
if (start <= files->next_fd)
files->next_fd = fd + 1;
- __set_open_fd(fd, fdt);
- __set_close_on_exec(fd, fdt, flags & O_CLOEXEC);
+ __set_open_fd(fd, fdt, flags & O_CLOEXEC);
error = fd;
out:
@@ -1186,8 +1186,7 @@ __releases(&files->file_lock)
goto Ebusy;
get_file(file);
rcu_assign_pointer(fdt->fd[fd], file);
- __set_open_fd(fd, fdt);
- __set_close_on_exec(fd, fdt, flags & O_CLOEXEC);
+ __set_open_fd(fd, fdt, flags & O_CLOEXEC);
spin_unlock(&files->file_lock);
if (tofree)