public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kingsley Cheung <kingsley@aurema.com>
To: Rik van Riel <riel@conectiva.com.br>
Cc: Rusty Trivial Russell <rusty@rustcorp.com.au>,
	Linus Torvalds <torvalds@transmeta.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [TRIVIAL] Re: setrlimit incorrectly allows hard limits to exceed soft limits
Date: Mon, 9 Dec 2002 10:22:56 +1100	[thread overview]
Message-ID: <20021209102256.C12270@aurema.com> (raw)
In-Reply-To: <Pine.LNX.4.50L.0212061106050.22252-100000@duckman.distro.conectiva>; from riel@conectiva.com.br on Fri, Dec 06, 2002 at 11:07:00AM -0200

On Fri, Dec 06, 2002 at 11:07:00AM -0200, Rik van Riel wrote:
> On Fri, 6 Dec 2002, Rusty Trivial Russell wrote:
> 
> > > Just try "ulimit -H -m 10000" for memory limits that were not
> > > previously set.  You end up with (hard limit = 10000) < (soft limit =
> > > unlimited).
> 
> > +       if (new_rlim.rlim_cur > new_rlim.rlim_max)
> > +               return -EINVAL;
> 
> Wouldn't it be better to simply take the soft limit down
> to min(new_rlim.rlim_cur, new_rlim.rlim_max) ?

Another way to do it would be to adjust the max limit up to the soft
limit only if the process had CAP_SYS_RESOURCE, just like in the
function svr4_ulimit in abi/svr4/ulimit.c.

In both cases, however, changing it will mean changing a limit on
behalf of the process.  But IMHO wouldn't most applications would
expect rlimits modified with setrlimit successfully to be set to the
rlimits that they specified as the argument?  Any child processes they
spawn would expect the same set of modified rlimits to be inherited as
well.  If we fix an incorrect pair of rlimits on their behalf, they
would then see different rlimit values with getrlimit later.

In light of that wouldn't it be better just to return an error and
insist that broken applications get fixed?  Unless of course there are
just too many broken apps out there : ) 

--
		Kingsley

  reply	other threads:[~2002-12-08 23:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-06  3:26 [TRIVIAL] Re: setrlimit incorrectly allows hard limits to exceed soft limits Rusty Trivial Russell
2002-12-06 13:07 ` Rik van Riel
2002-12-08 23:22   ` Kingsley Cheung [this message]
2002-12-08 23:34   ` Rusty Russell
     [not found] <1054753245@toto.iv>
2002-12-09  2:47 ` Peter Chubb
2002-12-09 12:27   ` Rik van Riel
2002-12-09 19:28     ` Peter Chubb
2002-12-09 20:14       ` Rik van Riel

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=20021209102256.C12270@aurema.com \
    --to=kingsley@aurema.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=riel@conectiva.com.br \
    --cc=rusty@rustcorp.com.au \
    --cc=torvalds@transmeta.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