lkml.org 
[lkml]   [2007]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Reserve N process to root
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-10-10 09:55    [W:0.194 / U:0.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site