mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Stevens" <dlstevens@us.ibm.com>
To: linux-kernel@vger.kernel.org
Subject: setrlimit() nit
Date: Wed, 15 Aug 2001 23:53:25 -0700	[thread overview]
Message-ID: <OFDF9D5E45.762AD13F-ON88256AAA.00253EAC@boulder.ibm.com> (raw)

The setrlimit() system call doesn't enforce rlim_cur <= rlim_max. This can
lead
to some unexpected results. For example, if you call setrlimit() with
RLIMIT_CPU with a hard limit of 60 secs, and a soft limit of "unlimited",
nothing will ever happen-- the hard limit is ignored, because it's never
checked if the soft limit hasn't been exceeded first (see kernel/timer.c).
     BSD had the same flaw-- always annoyed me. Simple fix (below). Diffs
are for 2.4.8.

                              +-DLS


--- linux/kernel/sys.c   Thu Jul 26 13:43:33 2001
+++ linux.NEW/kernel/sys.c    Thu Aug 16 00:20:14 2001
@@ -1119,6 +1119,8 @@
          return -EINVAL;
     if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
          return -EFAULT;
+    if (new_rlim.rlim_cur > new_rlim.rlim_max)
+         new_rlim.rlim_cur = new_rlim.rlim_max;
     old_rlim = current->rlim + resource;
     if (((new_rlim.rlim_cur > old_rlim->rlim_max) ||
          (new_rlim.rlim_max > old_rlim->rlim_max)) &&



                 reply	other threads:[~2001-08-16  6:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=OFDF9D5E45.762AD13F-ON88256AAA.00253EAC@boulder.ibm.com \
    --to=dlstevens@us.ibm.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®