summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorWilliam Lee Irwin III <wli@holomorphy.com>2004-10-18 18:10:55 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-10-18 18:10:55 -0700
commitb29bc67075152ce361292cd3f923d7faee1eeef7 (patch)
tree5c4981efe7c00731d8235f19320c534c03c8d2cd /kernel
parent7c11d7fc7017101d6910ef2fe03c83149513c29f (diff)
[PATCH] pidhashing: enforce PID_MAX_LIMIT in sysctls
The pid_max sysctl doesn't enforce PID_MAX_LIMIT or sane lower bounds. RESERVED_PIDS + 1 is the minimum pid_max that won't break alloc_pidmap(), and PID_MAX_LIMIT may not be aligned to 8*PAGE_SIZE boundaries for unusual values of PAGE_SIZE, so this also rounds up PID_MAX_LIMIT to it. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/pid.c5
-rw-r--r--kernel/sysctl.c6
2 files changed, 9 insertions, 2 deletions
diff --git a/kernel/pid.c b/kernel/pid.c
index 382c9b2b1f36..21024b7ae37c 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -36,7 +36,10 @@ int last_pid;
#define RESERVED_PIDS 300
-#define PIDMAP_ENTRIES (PID_MAX_LIMIT/PAGE_SIZE/8)
+int pid_max_min = RESERVED_PIDS + 1;
+int pid_max_max = PID_MAX_LIMIT;
+
+#define PIDMAP_ENTRIES ((PID_MAX_LIMIT + 8*PAGE_SIZE - 1)/PAGE_SIZE/8)
#define BITS_PER_PAGE (PAGE_SIZE*8)
#define BITS_PER_PAGE_MASK (BITS_PER_PAGE-1)
#define mk_pid(map, off) (((map) - pidmap_array)*BITS_PER_PAGE + (off))
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 469cf0c2f26e..80bf15f035cd 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -66,6 +66,7 @@ extern int sysctl_lower_zone_protection;
extern int min_free_kbytes;
extern int printk_ratelimit_jiffies;
extern int printk_ratelimit_burst;
+extern int pid_max_min, pid_max_max;
#if defined(CONFIG_X86_LOCAL_APIC) && defined(__i386__)
int unknown_nmi_panic;
@@ -575,7 +576,10 @@ static ctl_table kern_table[] = {
.data = &pid_max,
.maxlen = sizeof (int),
.mode = 0644,
- .proc_handler = &proc_dointvec,
+ .proc_handler = &proc_dointvec_minmax,
+ .strategy = sysctl_intvec,
+ .extra1 = &pid_max_min,
+ .extra2 = &pid_max_max,
},
{
.ctl_name = KERN_PANIC_ON_OOPS,