Skip to contentSkip to conversation

setrlimit() and 2.4.0-test11

PATCH Arkadiusz Miskiewicz 2 participants 2 messages Nov 22, 2000 – Nov 26, 2000

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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.

This change broke test11 ?

fs/proc/array.c Tue Nov 14 11:22:36 2000 renamed from linux/fs/proc/array.c Tue Oct 31 12:42:27 2000 +1 -1
diff -u --recursive --new-file v2.4.0-test10/linux/fs/proc/array.c linux/fs/proc/array.c
@@ -372,7 +372,7 @@
                task->start_time,
                vsize,
                mm ? mm->rss : 0, /* you might want to shift this left 3 */
-               task->rlim ? task->rlim[RLIMIT_RSS].rlim_cur : 0,
+               task->rlim[RLIMIT_RSS].rlim_cur,
                mm ? mm->start_code : 0,
                mm ? mm->end_code : 0,
                mm ? mm->start_stack : 0,

I need patch.

Signature · 6 lines
Arkadiusz Miśkiewicz, AM2-6BONE    [ PLD GNU/Linux IPv6 ]
http://www.t17.ds.pwr.wroc.pl/~misiek/ipv6/   [ enabled ]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#1 lore raw
Quoted 10 lines · Arkadiusz Miskiewicz

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.

kernel/fork.c renamed from kernel/fork.c~ +2 -1
@@ -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

Signature · 7 lines
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 [email protected]
Please read the FAQ at http://www.tux.org/lkml/