diff --git a/kernel/pid.c b/kernel/pid.c index 5dc0d3fc5efe212dd3558ed8adfcae938a8797b3..d4df9c3387e1a5bd837d318ae19474ddf78db39a 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -40,6 +40,7 @@ #include #include #include +#include struct pid init_struct_pid = { .count = ATOMIC_INIT(1), @@ -189,7 +190,7 @@ struct pid *alloc_pid(struct pid_namespace *ns) * a partially initialized PID (see below). */ nr = idr_alloc_cyclic(&tmp->idr, NULL, pid_min, - task_active_pid_ns(current)->pid_max, + tmp->pid_max, GFP_ATOMIC); spin_unlock_irq(&pidmap_lock); idr_preload_end(); @@ -457,7 +458,7 @@ static int proc_dointvec_pidmax(struct ctl_table *table, int write, struct ctl_table tmp; tmp = *table; - tmp.data = ¤t->nsproxy->pid_ns_for_children->pid_max; + tmp.data = &task_active_pid_ns(current)->pid_max; return proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); } @@ -479,6 +480,7 @@ static struct ctl_path pid_kern_path[] = { { .procname = "kernel" }, {} }; void __init pid_idr_init(void) { + struct ctl_table_header *hdr; int pid_max = init_pid_ns.pid_max; /* Verify no one has done anything silly: */ @@ -498,5 +500,6 @@ void __init pid_idr_init(void) init_pid_ns.pid_cachep = KMEM_CACHE(pid, SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT); - register_sysctl_paths(pid_kern_path, pid_ctl_table); + hdr = register_sysctl_paths(pid_kern_path, pid_ctl_table); + kmemleak_not_leak(hdr); } diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index 80d39dc961d77c71cc3a157c59ec169543e86d53..d009d98e3fe2554552ab4adbad5d6675cfc4e52e 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c @@ -283,6 +283,8 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write, next = idr_get_cursor(&pid_ns->idr) - 1; tmp.data = &next; + tmp.extra2 = &pid_ns->pid_max; + ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); if (!ret && write) idr_set_cursor(&pid_ns->idr, next + 1);