mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: Adam Tkac <vonsch@gmail.com>
Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org, mtk.manpages@gmail.com
Subject: Re: [PATCH 2.6.27-rc5] Allow set RLIMIT_NOFILE to RLIM_INFINITY
Date: Fri, 12 Sep 2008 13:20:46 +0200	[thread overview]
Message-ID: <jesks5wqy9.fsf@sykes.suse.de> (raw)
In-Reply-To: <20080912110639.GA2706@traged.atkac.englab.brq.redhat.com> (Adam Tkac's message of "Fri, 12 Sep 2008 13:06:39 +0200")

Adam Tkac <vonsch@gmail.com> writes:

> diff -puN kernel/sys.c~rlimit-permit-setting-rlimit_nofile-to-rlim_infinity kernel/sys.c
> --- a/kernel/sys.c~rlimit-permit-setting-rlimit_nofile-to-rlim_infinity
> +++ a/kernel/sys.c
> @@ -1532,8 +1532,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;

This makes it possible to set cur > nr_open (when max = INF but nr_open
< cur < INF).  You need to check that cur <= max after adjustment.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

  reply	other threads:[~2008-09-12 11:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-09  7:14 Adam Tkac
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 [this message]
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=jesks5wqy9.fsf@sykes.suse.de \
    --to=schwab@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vonsch@gmail.com \
    /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®