Commit b29bc670 authored by William Lee Irwin III's avatar William Lee Irwin III Committed by Linus Torvalds

[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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 7c11d7fc
...@@ -36,7 +36,10 @@ int last_pid; ...@@ -36,7 +36,10 @@ int last_pid;
#define RESERVED_PIDS 300 #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 (PAGE_SIZE*8)
#define BITS_PER_PAGE_MASK (BITS_PER_PAGE-1) #define BITS_PER_PAGE_MASK (BITS_PER_PAGE-1)
#define mk_pid(map, off) (((map) - pidmap_array)*BITS_PER_PAGE + (off)) #define mk_pid(map, off) (((map) - pidmap_array)*BITS_PER_PAGE + (off))
......
...@@ -66,6 +66,7 @@ extern int sysctl_lower_zone_protection; ...@@ -66,6 +66,7 @@ extern int sysctl_lower_zone_protection;
extern int min_free_kbytes; extern int min_free_kbytes;
extern int printk_ratelimit_jiffies; extern int printk_ratelimit_jiffies;
extern int printk_ratelimit_burst; extern int printk_ratelimit_burst;
extern int pid_max_min, pid_max_max;
#if defined(CONFIG_X86_LOCAL_APIC) && defined(__i386__) #if defined(CONFIG_X86_LOCAL_APIC) && defined(__i386__)
int unknown_nmi_panic; int unknown_nmi_panic;
...@@ -575,7 +576,10 @@ static ctl_table kern_table[] = { ...@@ -575,7 +576,10 @@ static ctl_table kern_table[] = {
.data = &pid_max, .data = &pid_max,
.maxlen = sizeof (int), .maxlen = sizeof (int),
.mode = 0644, .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, .ctl_name = KERN_PANIC_ON_OOPS,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment