aboutsummaryrefslogtreecommitdiffstats
path: root/fs/file.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2008-07-26 16:01:20 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2008-07-26 20:53:45 -0400
commit4e1e018ecc6f7bfd10fc75b3ff9715cc8164e0a2 (patch)
tree75404b1269b079a327551f76a9b3f941f5b11a77 /fs/file.c
parent6c5d0512a091480c9f981162227fdb1c9d70e555 (diff)
[PATCH] fix RLIM_NOFILE handling
* dup2() should return -EBADF on exceeded sysctl_nr_open * dup() should *not* return -EINVAL even if you have rlimit set to 0; it should get -EMFILE instead. Check for orig_start exceeding rlimit taken to sys_fcntl(). Failing expand_files() in dup{2,3}() now gets -EMFILE remapped to -EBADF. Consequently, remaining checks for rlimit are taken to expand_files(). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/file.c')
-rw-r--r--fs/file.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/file.c b/fs/file.c
index 7b3887e054d0..d8773b19fe47 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -250,9 +250,18 @@ int expand_files(struct files_struct *files, int nr)
250 struct fdtable *fdt; 250 struct fdtable *fdt;
251 251
252 fdt = files_fdtable(files); 252 fdt = files_fdtable(files);
253
254 /*
255 * N.B. For clone tasks sharing a files structure, this test
256 * will limit the total number of files that can be opened.
257 */
258 if (nr >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
259 return -EMFILE;
260
253 /* Do we need to expand? */ 261 /* Do we need to expand? */
254 if (nr < fdt->max_fds) 262 if (nr < fdt->max_fds)
255 return 0; 263 return 0;
264
256 /* Can we expand? */ 265 /* Can we expand? */
257 if (nr >= sysctl_nr_open) 266 if (nr >= sysctl_nr_open)
258 return -EMFILE; 267 return -EMFILE;