summaryrefslogtreecommitdiffstats
path: root/fs/fcntl.c
diff options
context:
space:
mode:
authorAl Viro2012-08-12 22:17:59 +0200
committerAl Viro2012-09-27 03:08:53 +0200
commitf33ff9927f42045116d738ee47ff7bc59f739bd7 (patch)
tree917e0d7c10392a884a0aeda8733bdd2ef8e2c105 /fs/fcntl.c
parentfanotify: sanitize failure exits in copy_event_to_user() (diff)
downloadkernel-qcow2-linux-f33ff9927f42045116d738ee47ff7bc59f739bd7.tar.gz
kernel-qcow2-linux-f33ff9927f42045116d738ee47ff7bc59f739bd7.tar.xz
kernel-qcow2-linux-f33ff9927f42045116d738ee47ff7bc59f739bd7.zip
take rlimit check to callers of expand_files()
... except for one in android, where the check is different and already done in caller. No need to recalculate rlimit many times in alloc_fd() either. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/fcntl.c')
-rw-r--r--fs/fcntl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 887b5ba8c9b5..08e6af5c1b1f 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -64,6 +64,9 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
if (unlikely(oldfd == newfd))
return -EINVAL;
+ if (newfd >= rlimit(RLIMIT_NOFILE))
+ return -EMFILE;
+
spin_lock(&files->file_lock);
err = expand_files(files, newfd);
file = fcheck(oldfd);