[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20111129174741.GA32209@redhat.com>
Date: Tue, 29 Nov 2011 18:47:41 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Pavel Emelyanov <xemul@...allels.com>
Cc: Tejun Heo <tj@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Cyrill Gorcunov <gorcunov@...nvz.org>
Subject: Re: [PATCH] sysctl: Add the kernel.ns_last_pid control
On 11/28, Pavel Emelyanov wrote:
>
> --- a/kernel/pid_namespace.c
> +++ b/kernel/pid_namespace.c
> @@ -191,9 +191,40 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
> return;
> }
>
> +static int pid_ns_ctl_handler(struct ctl_table *table, int write,
> + void __user *buffer, size_t *lenp, loff_t *ppos)
> +{
> + struct ctl_table tmp = *table;
> +
> + if (write && !capable(CAP_SYS_ADMIN))
> + return -EPERM;
> +
> + /*
> + * Writing directly to ns' last_pid field is OK, since this field
> + * is volatile in a living namespace anyway and a code writing to
> + * it should synchronize its usage with external means.
> + */
> +
> + tmp.data = ¤t->nsproxy->pid_ns->last_pid;
> + return proc_dointvec(&tmp, write, buffer, lenp, ppos);
> +}
> +
> +static struct ctl_table pid_ns_ctl_table[] = {
> + {
> + .procname = "ns_last_pid",
> + .maxlen = sizeof(int),
> + .mode = 0666, /* permissions are checked in the handler */
> + .proc_handler = pid_ns_ctl_handler,
> + },
> + { }
> +};
> +
> +static struct ctl_path kern_path[] = { { .procname = "kernel", }, { } };
> +
> static __init int pid_namespaces_init(void)
> {
> pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC);
> + register_sysctl_paths(kern_path, pid_ns_ctl_table);
> return 0;
> }
Hmm. This way it depends on CONFIG_PID_NS.
Can't we simply add an entry into kern_table[] ? And without ns_, just
/proc/sys/kernel/last_pid.
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists