mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
Merge 4ea51e0e37 ("Merge tag 'for-linus-2021-04-08' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux") into android-mainline
Steps on the way to 5.12-rc7 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I3e01d8950c38d7ac8a734159c288daaa92966732
This commit is contained in:
21
fs/file.c
21
fs/file.c
@@ -629,17 +629,30 @@ int close_fd(unsigned fd)
|
||||
}
|
||||
EXPORT_SYMBOL(close_fd); /* for ksys_close() */
|
||||
|
||||
/**
|
||||
* last_fd - return last valid index into fd table
|
||||
* @cur_fds: files struct
|
||||
*
|
||||
* Context: Either rcu read lock or files_lock must be held.
|
||||
*
|
||||
* Returns: Last valid index into fdtable.
|
||||
*/
|
||||
static inline unsigned last_fd(struct fdtable *fdt)
|
||||
{
|
||||
return fdt->max_fds - 1;
|
||||
}
|
||||
|
||||
static inline void __range_cloexec(struct files_struct *cur_fds,
|
||||
unsigned int fd, unsigned int max_fd)
|
||||
{
|
||||
struct fdtable *fdt;
|
||||
|
||||
if (fd > max_fd)
|
||||
return;
|
||||
|
||||
/* make sure we're using the correct maximum value */
|
||||
spin_lock(&cur_fds->file_lock);
|
||||
fdt = files_fdtable(cur_fds);
|
||||
bitmap_set(fdt->close_on_exec, fd, max_fd - fd + 1);
|
||||
max_fd = min(last_fd(fdt), max_fd);
|
||||
if (fd <= max_fd)
|
||||
bitmap_set(fdt->close_on_exec, fd, max_fd - fd + 1);
|
||||
spin_unlock(&cur_fds->file_lock);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user