public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Chain <g@0xff.cl>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Reserve N process to root
Date: Tue, 9 Oct 2007 19:48:20 -0400	[thread overview]
Message-ID: <20071009194820.6c8d6e8d@0xff.cl> (raw)

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

             reply	other threads:[~2007-10-09 23:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-09 23:48 Gustavo Chain [this message]
2007-10-10  1:49 ` [PATCH] Reserve N process to root David Newall
2007-10-10  5:15   ` Gustavo Chain
2007-10-10  5:44     ` David Newall
2007-10-10 13:46       ` Gustavo Chain
2007-10-10 14:13         ` David Newall
2007-10-10 19:50         ` Valdis.Kletnieks
2007-10-10 21:02           ` g
2007-10-11  0:05           ` David Newall
  -- strict thread matches above, loose matches on Subject: below --
2007-10-11 21:02 Al Boldi
2007-10-12  2:42 ` Kyle Moffett
2007-10-12  5:37   ` Al Boldi
2007-10-12  5:49     ` Kyle Moffett
2007-10-12  6:29       ` Al Boldi
2007-10-13  1:34         ` Gustavo Chain
2007-10-13  5:01           ` Al Boldi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071009194820.6c8d6e8d@0xff.cl \
    --to=g@0xff.cl \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox