From f33ff9927f42045116d738ee47ff7bc59f739bd7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 12 Aug 2012 16:17:59 -0400 Subject: 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 --- fs/fcntl.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'fs/fcntl.c') 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); -- cgit v1.2.3-58-ga151