lkml.org 
[lkml]   [2000]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: setrlimit() and 2.4.0-test11
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/
\
 
 \ /
  Last update: 2005-03-22 12:47    [W:0.045 / U:0.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site