public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Trivial Russell <rusty@rustcorp.com.au>
To: torvalds@transmeta.com, linux-kernel@vger.kernel.org
Subject: [TRIVIAL] Re: setrlimit incorrectly allows hard limits to exceed soft limits
Date: Fri, 06 Dec 2002 14:26:30 +1100	[thread overview]
Message-ID: <20021206035756.2CD1A2C28C@lists.samba.org> (raw)

From:  Kingsley Cheung <kingsley@aurema.com>

  Oops, should be after the copy :-(
  

> In 2.4.19 (also 2.5.46) setrlimit code only ever makes a comparison to
> check the old soft limit with the new soft limit and the new hard
> limit with the old hard limit.  There is never a check to ensure the
> new soft limit never exceeds the new hard limit. 
> 
> Just try "ulimit -H -m 10000" for memory limits that were not
> previously set.  You end up with (hard limit = 10000) < (soft limit =
> unlimited).
> 
> Fix is trivial.


--- trivial-2.5-bk/kernel/sys.c.orig	2002-12-06 13:56:43.000000000 +1100
+++ trivial-2.5-bk/kernel/sys.c	2002-12-06 13:56:43.000000000 +1100
@@ -1233,6 +1233,8 @@
 		return -EINVAL;
 	if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
 		return -EFAULT;
+       if (new_rlim.rlim_cur > new_rlim.rlim_max)
+               return -EINVAL;
 	old_rlim = current->rlim + resource;
 	if (((new_rlim.rlim_cur > old_rlim->rlim_max) ||
 	     (new_rlim.rlim_max > old_rlim->rlim_max)) &&
-- 
  Don't blame me: the Monkey is driving
  File: Kingsley Cheung <kingsley@aurema.com>: Re: [PATCH] setrlimit incorrectly allows hard limits to exceed soft limits

             reply	other threads:[~2002-12-06  3:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-06  3:26 Rusty Trivial Russell [this message]
2002-12-06 13:07 ` [TRIVIAL] Re: setrlimit incorrectly allows hard limits to exceed soft limits Rik van Riel
2002-12-08 23:22   ` Kingsley Cheung
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=20021206035756.2CD1A2C28C@lists.samba.org \
    --to=rusty@rustcorp.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --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