mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 09:12:07 +00:00
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>
This commit is contained in:
parent
e880d33b49
commit
b8ea429d72
@ -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 @@ static int alloc_fd(unsigned start, unsigned end, unsigned flags)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user