mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Adam Tkac <vonsch@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 2.6.27-rc5] Allow set RLIMIT_NOFILE to RLIM_INFINITY
Date: Tue, 9 Sep 2008 09:14:07 +0200	[thread overview]
Message-ID: <20080909071406.GA3814@traged.atkac.englab.brq.redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 266 bytes --]

Hi all,

when process wants set limit of open files to RLIM_INFINITY it gets
EPERM even if it has CAP_SYS_RESOURCE capability. Attached patch
should fix the problem. Please add me to CC of your responses because
I'm not member of list.

Regards, Adam

-- 
Adam Tkac

[-- Attachment #2: linux26-openfiles.patch --]
[-- Type: text/plain, Size: 633 bytes --]

--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1458,8 +1458,14 @@ asmlinkage long sys_setrlimit(unsigned i
 	if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
 	    !capable(CAP_SYS_RESOURCE))
 		return -EPERM;
-	if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
-		return -EPERM;
+	if (resource == RLIMIT_NOFILE) {
+		if (new_rlim.rlim_max == RLIM_INFINITY)
+			new_rlim.rlim_max = sysctl_nr_open;
+		if (new_rlim.rlim_cur == RLIM_INFINITY)
+			new_rlim.rlim_cur = sysctl_nr_open;
+		if (new_rlim.rlim_max > sysctl_nr_open)
+			return -EPERM;
+	}
 
 	retval = security_task_setrlimit(resource, &new_rlim);
 	if (retval)

             reply	other threads:[~2008-09-09  7:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-09  7:14 Adam Tkac [this message]
2008-09-10 21:31 ` Andrew Morton
2008-09-11  7:54   ` Adam Tkac
2008-09-11 19:22     ` Andrew Morton
2008-09-12 11:06       ` Adam Tkac
2008-09-12 11:20         ` Andreas Schwab
2008-09-12 11:52           ` Adam Tkac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080909071406.GA3814@traged.atkac.englab.brq.redhat.com \
    --to=vonsch@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®