diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-07-26 16:01:20 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-07-26 20:53:45 -0400 |
commit | 4e1e018ecc6f7bfd10fc75b3ff9715cc8164e0a2 (patch) | |
tree | 75404b1269b079a327551f76a9b3f941f5b11a77 /fs/open.c | |
parent | 6c5d0512a091480c9f981162227fdb1c9d70e555 (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/open.c')
-rw-r--r-- | fs/open.c | 9 |
1 files changed, 0 insertions, 9 deletions
@@ -972,7 +972,6 @@ int get_unused_fd_flags(int flags) | |||
972 | int fd, error; | 972 | int fd, error; |
973 | struct fdtable *fdt; | 973 | struct fdtable *fdt; |
974 | 974 | ||
975 | error = -EMFILE; | ||
976 | spin_lock(&files->file_lock); | 975 | spin_lock(&files->file_lock); |
977 | 976 | ||
978 | repeat: | 977 | repeat: |
@@ -980,13 +979,6 @@ repeat: | |||
980 | fd = find_next_zero_bit(fdt->open_fds->fds_bits, fdt->max_fds, | 979 | fd = find_next_zero_bit(fdt->open_fds->fds_bits, fdt->max_fds, |
981 | files->next_fd); | 980 | files->next_fd); |
982 | 981 | ||
983 | /* | ||
984 | * N.B. For clone tasks sharing a files structure, this test | ||
985 | * will limit the total number of files that can be opened. | ||
986 | */ | ||
987 | if (fd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) | ||
988 | goto out; | ||
989 | |||
990 | /* Do we need to expand the fd array or fd set? */ | 982 | /* Do we need to expand the fd array or fd set? */ |
991 | error = expand_files(files, fd); | 983 | error = expand_files(files, fd); |
992 | if (error < 0) | 984 | if (error < 0) |
@@ -997,7 +989,6 @@ repeat: | |||
997 | * If we needed to expand the fs array we | 989 | * If we needed to expand the fs array we |
998 | * might have blocked - try again. | 990 | * might have blocked - try again. |
999 | */ | 991 | */ |
1000 | error = -EMFILE; | ||
1001 | goto repeat; | 992 | goto repeat; |
1002 | } | 993 | } |
1003 | 994 | ||