提交 ee97cd87 编写于 作者: A Al Viro

switch flush_unauthorized_files() to replace_fd()

Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 8280d161
...@@ -2126,8 +2126,6 @@ static inline void flush_unauthorized_files(const struct cred *cred, ...@@ -2126,8 +2126,6 @@ static inline void flush_unauthorized_files(const struct cred *cred,
spin_lock(&files->file_lock); spin_lock(&files->file_lock);
for (;;) { for (;;) {
unsigned long set, i; unsigned long set, i;
int fd;
j++; j++;
i = j * BITS_PER_LONG; i = j * BITS_PER_LONG;
fdt = files_fdtable(files); fdt = files_fdtable(files);
...@@ -2138,38 +2136,23 @@ static inline void flush_unauthorized_files(const struct cred *cred, ...@@ -2138,38 +2136,23 @@ static inline void flush_unauthorized_files(const struct cred *cred,
continue; continue;
spin_unlock(&files->file_lock); spin_unlock(&files->file_lock);
for ( ; set ; i++, set >>= 1) { for ( ; set ; i++, set >>= 1) {
if (set & 1) { if (!(set & 1))
file = fget(i); continue;
if (!file) file = fget(i);
continue; if (!file)
if (file_has_perm(cred, continue;
file, if (file_has_perm(cred, file, file_to_av(file))) {
file_to_av(file))) { if (devnull) {
sys_close(i); get_file(devnull);
fd = get_unused_fd(); } else {
if (fd != i) { devnull = dentry_open(&selinux_null,
if (fd >= 0) O_RDWR, cred);
put_unused_fd(fd); if (IS_ERR(devnull))
fput(file); devnull = NULL;
continue;
}
if (devnull) {
get_file(devnull);
} else {
devnull = dentry_open(
&selinux_null,
O_RDWR, cred);
if (IS_ERR(devnull)) {
devnull = NULL;
put_unused_fd(fd);
fput(file);
continue;
}
}
fd_install(fd, devnull);
} }
fput(file); replace_fd(i, devnull, 0);
} }
fput(file);
} }
spin_lock(&files->file_lock); spin_lock(&files->file_lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册