Subject: [PATCH] More usuable pspace size calculation. From: Eric W. Biederman Date: 1129746928 -0600 Allocating an arbitrary 1/256 of the nr_pids works but is extremely arbitrary. Instead make that the default and use RLIMIT_NPROC as the size of the pspace to allocate if it is set. --- kernel/pid.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) 53777e560c2b91e830aa44630378c497401ea9f4 diff --git a/kernel/pid.c b/kernel/pid.c index 4bd186f..2f13c43 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -313,17 +313,18 @@ int copy_pspace(int flags, struct task_s if (!(flags & CLONE_NEWPSPACE)) return 0; - /* For now allocate 1/256 of the pidspace */ - pids = p->pspace->max >> 8; + /* Figure out how many pids I can allocate for the pspace */ + if (p->signal->rlim[RLIMIT_NPROC].rlim_cur != RLIM_INFINITY) { + pids = p->signal->rlim[RLIMIT_NPROC].rlim_cur; + } else { + /* Default to 1/256 of the pspace */ + pids = p->pspace->max >> 8; + } - /* Verify this could fit in my rlimit */ - if ((atomic_read(&p->user->processes) + pids) >= - p->signal->rlim[RLIMIT_NPROC].rlim_cur) { - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) && - p->user != &root_user) { - put_pspace(p->pspace); - return -EAGAIN; - } + /* Verify I am allocating at least one pid */ + if (pids < 1) { + put_pspace(p->pspace); + return -EAGAIN; } pid = -1; -- 1.0.GIT