]> git.hungrycats.org Git - linux/commitdiff
[PATCH] pidhashing: enforce PID_MAX_LIMIT in sysctls
authorWilliam Lee Irwin III <wli@holomorphy.com>
Tue, 19 Oct 2004 01:10:55 +0000 (18:10 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 19 Oct 2004 01:10:55 +0000 (18:10 -0700)
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>
kernel/pid.c
kernel/sysctl.c

index 382c9b2b1f36646f0d568b058f60186f027018cb..21024b7ae37c2fb0962c5a87eb660ad7f67aeaf9 100644 (file)
@@ -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))
index 469cf0c2f26ecedb22826baea2fb826c6ad82953..80bf15f035cde21fce001b19ac051c2f20aa11a4 100644 (file)
@@ -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,