no RLIMIT_NPROC for root, please
Subsystems (3)
PATCH 1/1 no RLIMIT_NPROC for root, please
Why is RLIMIT_NPROC apllied to root(uid 0) processes? It's not kernel job to prevent admin from shooting him/her self in the foot.
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/
kernel/fork.c line 564
Quoted 9 lines · Jan Rekorajski
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))
Jan,
Hardcoding things signifying special treatment of uid=0 is almost always a bad idea. If you _really_ think that superuser (whatever entity that might be) should be exempt from RLIMIT_NPROC and can prove that (SuSv2 seems to be silent so you may be right), then you should use capable() to do proper capability test and not that horrible explicit uid test as in your patch above.
Regards,
Tigran
-
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/
Quoted 11 lines · Jan Rekorajski
kernel/fork.c line 564
Quoted 9 lines
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))
On a totally unrelated to the resourcesnote, for your benefit, Jan:
the ->user->uid is maintained for a reason completely different from your usage above (see kernel/user.c to learn why -- it is to easily find out given user_struct which real uid it belongs to in uid_hash_find()). If you wanted this process' uid you should have used p->uid. If you wanted this process' effective uid (more likely) then you should have used p->euid.
Regards,
Tigran
-
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/
kernel/fork.c line 563
Quoted 4 lines · Jan R_korajski
Why is
RLIMIT_NPROCapllied to root(uid 0) processes? It's not kernel job to prevent admin from shooting him/her self in the foot.kernel/fork.c renamed from kernel/fork.c~ +0
-1-if (atomic_read (&p->user->processes) >= p->rlim[RLIMIT_NPROC ].rlim_cur)
By default, root has no real process limits anyways, so this test should always succeed. However, it would be nice to be _able_ to set process limits on root for one reason or another. Also, as we move towards more secure systems, it is bad (IMHO) to special case root (uid=0) cases. It just makes more to fix to get a system where root != god.
Quoted 2 lines
root should be able to do
fork()regardless of any limits, and IMHO the following patch is the right thing.
Then set the rlim_cur to unlimited, and blow your system up as you like.
Cheers, Andreas
Signature · 7 lines
Andreas Dilger \ "If a man ate a pound of pasta and a pound of antipasto,
\ would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/ -- Dogbert
-
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/Quoted 13 lines · Tigran Aivazian
kernel/fork.c line 564
Quoted 9 lines · Jan Rekorajski
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))Jan,
Quoted 6 lines
Hardcoding things signifying special treatment of uid=0 is almost always a bad idea. If you _really_ think that superuser (whatever entity that might be) should be exempt from
RLIMIT_NPROCand can prove that (SuSv2 seems to be silent so you may be right), then you should usecapable()to do proper capability test and not that horrible explicit uid test as in your patch above.
Ok, how about setting limits on login? When this looks like:
--- uid = 0 heresetrlimit(RLIMIT_NPROC, n)fork() <- this will fail if root has >n processes
setuid(user)
and it is hard to change this sequence, all PAM enabled apps depend on it :(
The other scenario may be when root has already n processes, call them system stuff, and cannot login or even kill anything because of limits.
Is this patch better? I put CAP_SYS_RESOURCE, but maybe it should be CAP_SYS_ADMIN.
kernel/fork.c renamed from kernel/fork.c~ +2 -1
@@ -562,7 +562,8 @@ *p = *current; retval = -EAGAIN ; -if (atomic_read (&p->user->processes) >= p->rlim[RLIMIT_NPROC ].rlim_cur) +if ((atomic_read (&p->user->processes) >= p->rlim[RLIMIT_NPROC ].rlim_cur) && + !capable (CAP_SYS_RESOURCE )) 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/
Jan Rekorajski <[email protected]> writes:
|> Why is RLIMIT_NPROC apllied to root(uid 0) processes? It's not kernel job to |> prevent admin from shooting him/her self in the foot. |> |> root should be able to do fork() regardless of any limits, |> and IMHO the following patch is the right thing.
AFAICS, _all_ resource limits are equally applied to root processes. Why should NPROC be different?
Andreas.
Signature · 8 lines
Andreas Schwab "And now for something SuSE Labs completely different." [email protected] SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg - 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/
Quoted 10 lines · Andreas Schwab
Jan Rekorajski <[email protected]> writes:
|> Why is RLIMIT_NPROC apllied to root(uid 0) processes? It's not kernel job to |> prevent admin from shooting him/her self in the foot. |> |> root should be able to do fork() regardless of any limits, |> and IMHO the following patch is the right thing.AFAICS, _all_ resource limits are equally applied to root processes. Why should NPROC be different?
Because you want to be able to kill <pid>?
And if you are over-limits you can't?
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/
Quoted 6 lines
Quoted 1 line
AFAICS, _all_ resource limits are equally applied to root processes. =
Why
Quoted 1 line
should NPROC be different?
Because you want to be able to
kill <pid>?
And if you are over-limits you can't?
Wrong. limit is a shell built in
-
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/
Quoted 3 lines · Alan Cox
Quoted 2 lines
Because you want to be able to
kill <pid>?
And if you are over-limits you can't?Wrong. limit is a shell built in
I assume you mean kill is a shell builtin. Depending on your shell. :-). It's still a real pain when you want to get the pid of the offending proces(ses). You could of course do something like
for a in /proc/*; do echo -en "$a "; cat $a/cmdline; echo; done (it'll barf a lot, but give a reasonable picture)...
Anyways, this is all not relevant, imho the whole point is moot. "I don't like root having rlimits."
"So don't setrlimit root."
No reason to ditch functionality.
Signature · 7 lines
Frank v Waveren
fvw@[var.cx|stack.nl|chello.nl|dse.nl]
ICQ# 10074100
-
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/In article <[email protected]>,
Quoted 6 lines · Frank v Waveren
Quoted 3 lines · Alan Cox
Quoted 2 lines
Because you want to be able to
kill <pid>?
And if you are over-limits you can't?Wrong. limit is a shell built in
I assume you mean kill is a shell builtin. Depending on your shell. :-).
No. Think about it.
Mike.
-
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/
Quoted 6 lines
Why is
RLIMIT_NPROCapllied to root(uid 0) processes? It's not kernel j= ob to
prevent admin from shooting him/her self in the foot.root should be able to do
fork()regardless of any limits, and IMHO the following patch is the right thing.
This patch is bogus. root can always raise their limit. But having root tasks by default not take out the box is good
-
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/
Quoted 9 lines · Alan Cox
Quoted 6 lines
Why is
RLIMIT_NPROCapllied to root(uid 0) processes? It's not kernel j= ob to
prevent admin from shooting him/her self in the foot.root should be able to do
fork()regardless of any limits, and IMHO the following patch is the right thing.This patch is bogus. root can always raise their limit. But having root tasks by default not take out the box is good
OK, I just fix applications that assume root = no limits ;)
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/
Hi!
Quoted 22 lines
Quoted 13 lines · Jan Rekorajski
kernel/fork.c line 564
Quoted 9 lines
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))Jan,
Quoted 6 lines
Hardcoding things signifying special treatment of uid=0 is almost always a bad idea. If you _really_ think that superuser (whatever entity that might be) should be exempt from
RLIMIT_NPROCand can prove that (SuSv2 seems to be silent so you may be right), then you should usecapable()to do proper capability test and not that horrible explicit uid test as in your patch above.Ok, how about setting limits on login? When this looks like:
Quoted 7 lines
--- uid = 0 here
setrlimit(RLIMIT_NPROC, n)fork()<- this will fail if root has >n processes
setuid(user)and it is hard to change this sequence, all PAM enabled apps depend on it :(
So PAM dictates kernel changes? Fix pam, do not break kernel.
Pavel
Signature · 6 lines
I'm [email protected]. "In my country we have almost anarchy and I don't care." Panos Katsaloulis describing me w.r.t. patents at [email protected] - 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/
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Hardcoding things signifying special treatment of uid=0 is almost always a bad idea. If you _really_ think that superuser (whatever entity that might be) should be exempt from
RLIMIT_NPROCand can prove that (SuSv2 seems to be silent so you may be right), then you should usecapable()to do proper capability test and not that horrible explicit uid test as in your patch above.
I totally agree with you, Pavel. But while we are on this subject -- shouldn't the explicit check like this:
/*
* Use a reserved one if we're the superuser
*/
if (files_stat.nr_free_files && !current->euid)
goto used_one;in fs/file_table.c:get_empty_filp() be switched to capabilities? I.e. is the hardcoded euid=0 value intentional there or is it an omission?
Regards,
Tigran
-
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/
Quoted 29 lines · Pavel Machek
Hi!
Quoted 27 lines
Quoted 13 lines · Jan Rekorajski
kernel/fork.c line 564
Quoted 9 lines
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))Jan,
Quoted 6 lines
Hardcoding things signifying special treatment of uid=0 is almost always a bad idea. If you _really_ think that superuser (whatever entity that might be) should be exempt from
RLIMIT_NPROCand can prove that (SuSv2 seems to be silent so you may be right), then you should usecapable()to do proper capability test and not that horrible explicit uid test as in your patch above.Ok, how about setting limits on login? When this looks like:
--- uid = 0 here
setrlimit(RLIMIT_NPROC, n)fork()<- this will fail if root has >n processes
setuid(user)
Quoted 4 lines
Quoted 2 lines
and it is hard to change this sequence, all PAM enabled apps depend on it :(
So PAM dictates kernel changes? Fix pam, do not break kernel.
Fixed :)
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/