mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Rekorajski <baggins@sith.mimuw.edu.pl>
To: linux-kernel@vger.kernel.org
Cc: torvalds@transmeta.com
Subject: Re: setrlimit() and 2.4.0-test11
Date: Sun, 26 Nov 2000 20:33:07 +0100	[thread overview]
Message-ID: <20001126203307.A24710@sith.mimuw.edu.pl> (raw)
In-Reply-To: <20001122171731.B13272@pld.ORG.PL>
In-Reply-To: <20001122171731.B13272@pld.ORG.PL>; from misiek@pld.ORG.PL on Wed, Nov 22, 2000 at 05:17:31PM +0100

On Wed, 22 Nov 2000, Arkadiusz Miskiewicz wrote:

> 
> Is probably broken (I didnt't saw any disscusion about this here,
> I missed it?).
> 
> when I try to start first user process I get:
> 4366  fork()                            = -1 EAGAIN (Resource temporarily unavailable)
> but strace show proper value passed to setrlimit() -- 40 max number of processes:
> 4366  setrlimit(0x6 /* RLIMIT_??? */, {rlim_cur=40, rlim_max=40}) = 0
> 
> On test10 everything is ok.

No, you are just lucky.
The problem is that root (uid=0) is not a special case anymore, and you can't
do something like this:

setrlimit(NPROC)
fork()
setuid(user)

setrlimit() and fork() are executed in root context, so sterlimit
apllies to root, not the user you're setuid to :(

Why is this so? root should be able to do fork() regardless of any limits,
and IMHO the following patch is the right thing.

--- linux/kernel/fork.c~	Tue Sep  5 23:48:59 2000
+++ linux/kernel/fork.c	Sun Nov 26 20:22:20 2000
@@ -560,7 +560,8 @@
 	*p = *current;
 
 	retval = -EAGAIN;
-	if (atomic_read(&p->user->processes) >= p->rlim[RLIMIT_NPROC].rlim_cur)
+	if (p->user->uid &&
+	   (atomic_read(&p->user->processes) >= p->rlim[RLIMIT_NPROC].rlim_cur))
 		goto bad_fork_free;
 	atomic_inc(&p->user->__count);
 	atomic_inc(&p->user->processes);

Jan
-- 
Jan Rękorajski            |  ALL SUSPECTS ARE GUILTY. PERIOD!
baggins<at>mimuw.edu.pl   |  OTHERWISE THEY WOULDN'T BE SUSPECTS, WOULD THEY?
BOFH, type MANIAC         |                   -- TROOPS by Kevin Rubio
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

      reply	other threads:[~2000-11-26 20:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-22 16:17 Arkadiusz Miskiewicz
2000-11-26 19:33 ` Jan Rekorajski [this message]

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=20001126203307.A24710@sith.mimuw.edu.pl \
    --to=baggins@sith.mimuw.edu.pl \
    --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

all inboxes | Powered by JetHome®