aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-08-21 12:26:45 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-09-26 21:09:58 -0400
commitee97cd872d08b8623076f2a63ffb872d0884411a (patch)
tree0eb578bbf88459dff4e04b0273531971c539c466 /security
parent8280d16172243702ed43432f826ca6130edb4086 (diff)
switch flush_unauthorized_files() to replace_fd()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'security')
-rw-r--r--security/selinux/hooks.c47
1 files changed, 15 insertions, 32 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 6c77f63c7591..00b50113642d 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2126,8 +2126,6 @@ static inline void flush_unauthorized_files(const struct cred *cred,
2126 spin_lock(&files->file_lock); 2126 spin_lock(&files->file_lock);
2127 for (;;) { 2127 for (;;) {
2128 unsigned long set, i; 2128 unsigned long set, i;
2129 int fd;
2130
2131 j++; 2129 j++;
2132 i = j * BITS_PER_LONG; 2130 i = j * BITS_PER_LONG;
2133 fdt = files_fdtable(files); 2131 fdt = files_fdtable(files);
@@ -2138,38 +2136,23 @@ static inline void flush_unauthorized_files(const struct cred *cred,
2138 continue; 2136 continue;
2139 spin_unlock(&files->file_lock); 2137 spin_unlock(&files->file_lock);
2140 for ( ; set ; i++, set >>= 1) { 2138 for ( ; set ; i++, set >>= 1) {
2141 if (set & 1) { 2139 if (!(set & 1))
2142 file = fget(i); 2140 continue;
2143 if (!file) 2141 file = fget(i);
2144 continue; 2142 if (!file)
2145 if (file_has_perm(cred, 2143 continue;
2146 file, 2144 if (file_has_perm(cred, file, file_to_av(file))) {
2147 file_to_av(file))) { 2145 if (devnull) {
2148 sys_close(i); 2146 get_file(devnull);
2149 fd = get_unused_fd(); 2147 } else {
2150 if (fd != i) { 2148 devnull = dentry_open(&selinux_null,
2151 if (fd >= 0) 2149 O_RDWR, cred);
2152 put_unused_fd(fd); 2150 if (IS_ERR(devnull))
2153 fput(file); 2151 devnull = NULL;
2154 continue;
2155 }
2156 if (devnull) {
2157 get_file(devnull);
2158 } else {
2159 devnull = dentry_open(
2160 &selinux_null,
2161 O_RDWR, cred);
2162 if (IS_ERR(devnull)) {
2163 devnull = NULL;
2164 put_unused_fd(fd);
2165 fput(file);
2166 continue;
2167 }
2168 }
2169 fd_install(fd, devnull);
2170 } 2152 }
2171 fput(file); 2153 replace_fd(i, devnull, 0);
2172 } 2154 }
2155 fput(file);
2173 } 2156 }
2174 spin_lock(&files->file_lock); 2157 spin_lock(&files->file_lock);
2175 2158