[PATCH] Reserve N process to root

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Date: Tuesday, October 9, 2007 - 7:48 pm

I think it's necessary to reserve some pids to the super user.
5 must be sufficient.

Signed-off-by: Gustavo Chain <g@0xff.cl>
---
 kernel/fork.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index 33f12f4..db23cb3 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1367,11 +1367,17 @@ long do_fork(unsigned long clone_flags,
              int __user *parent_tidptr,
              int __user *child_tidptr)
 {
+#define RESERVED_PIDS   5
+
        struct task_struct *p;
        int trace = 0;
        struct pid *pid = alloc_pid();
        long nr;
 
+       if (!capable(CAP_SYS_ADMIN) && nr_threads >= max_threads
- RESERVED_PIDS) {
+               return -EAGAIN;
+       }
+
        if (!pid)
                return -EAGAIN;
        nr = pid->nr;

-- 
Gustavo Chaín Dumit
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Reserve N process to root, Gustavo Chain, (Tue Oct 9, 7:48 pm)
Re: [PATCH] Reserve N process to root, David Newall, (Tue Oct 9, 9:49 pm)
Re: [PATCH] Reserve N process to root, Gustavo Chain, (Wed Oct 10, 1:15 am)
Re: [PATCH] Reserve N process to root, David Newall, (Wed Oct 10, 1:44 am)
Re: [PATCH] Reserve N process to root, Gustavo Chain, (Wed Oct 10, 9:46 am)
Re: [PATCH] Reserve N process to root, , (Wed Oct 10, 3:50 pm)
Re: [PATCH] Reserve N process to root, David Newall, (Wed Oct 10, 8:05 pm)
Re: [PATCH] Reserve N process to root, , (Wed Oct 10, 5:02 pm)
Re: [PATCH] Reserve N process to root, David Newall, (Wed Oct 10, 10:13 am)