Commit ee97cd87 authored by Al Viro's avatar Al Viro

switch flush_unauthorized_files() to replace_fd()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 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,39 +2136,24 @@ static inline void flush_unauthorized_files(const struct cred *cred, ...@@ -2138,39 +2136,24 @@ 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))
continue;
file = fget(i); file = fget(i);
if (!file) if (!file)
continue; continue;
if (file_has_perm(cred, if (file_has_perm(cred, file, file_to_av(file))) {
file,
file_to_av(file))) {
sys_close(i);
fd = get_unused_fd();
if (fd != i) {
if (fd >= 0)
put_unused_fd(fd);
fput(file);
continue;
}
if (devnull) { if (devnull) {
get_file(devnull); get_file(devnull);
} else { } else {
devnull = dentry_open( devnull = dentry_open(&selinux_null,
&selinux_null,
O_RDWR, cred); O_RDWR, cred);
if (IS_ERR(devnull)) { if (IS_ERR(devnull))
devnull = NULL; devnull = NULL;
put_unused_fd(fd);
fput(file);
continue;
} }
} replace_fd(i, devnull, 0);
fd_install(fd, devnull);
} }
fput(file); fput(file);
} }
}
spin_lock(&files->file_lock); spin_lock(&files->file_lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment