Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932291AbWBFUKb (ORCPT ); Mon, 6 Feb 2006 15:10:31 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932363AbWBFUKa (ORCPT ); Mon, 6 Feb 2006 15:10:30 -0500 Received: from ebiederm.dsl.xmission.com ([166.70.28.69]:56448 "EHLO ebiederm.dsl.xmission.com") by vger.kernel.org with ESMTP id S932291AbWBFUK2 (ORCPT ); Mon, 6 Feb 2006 15:10:28 -0500 To: Cc: , Herbert Poetzl , "Serge E. Hallyn" , Alan Cox , Dave Hansen , Arjan van de Ven , Suleiman Souhlal , Hubertus Franke , Cedric Le Goater , Kyle Moffett , Kirill Korotaev , Greg , Linus Torvalds , Andrew Morton , Greg KH , Rik van Riel , Alexey Kuznetsov , Andrey Savochkin , Kirill Korotaev , Andi Kleen , Benjamin Herrenschmidt , Jeff Garzik , Trond Myklebust , Jes Sorensen Subject: [RFC][PATCH 19/20] pspace: Upcate the pid_max sysctl to work in a per pspace fashion References: From: ebiederm@xmission.com (Eric W. Biederman) Date: Mon, 06 Feb 2006 13:07:56 -0700 In-Reply-To: (Eric W. Biederman's message of "Mon, 06 Feb 2006 13:05:34 -0700") Message-ID: User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4192 Lines: 155 It is a pain to export anything in sysctl that is not a global variable but it is possible. So for backwards compatibility. Signed-off-by: Eric W. Biederman --- kernel/sysctl.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 75 insertions(+), 4 deletions(-) dc9bb041416aeaa92add46c7fe7689099768d8fa diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 8e1bdc5..89476f6 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -64,7 +65,6 @@ extern int core_uses_pid; extern int suid_dumpable; extern char core_pattern[]; extern int cad_pid; -extern int pid_max; extern int min_free_kbytes; extern int printk_ratelimit_jiffies; extern int printk_ratelimit_burst; @@ -132,6 +132,11 @@ static int parse_table(int __user *, int ctl_table *, void **); static int proc_doutsstring(ctl_table *table, int write, struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos); +static int proc_pidmax(ctl_table *table, int write, struct file *filp, + void __user *buffer, size_t *lenp, loff_t *ppos); +static int sysctl_pidmax(ctl_table *table, int __user *name, int nlen, + void __user *oldval, size_t __user *oldlenp, + void __user *newval, size_t newlen, void **context); static ctl_table root_table[]; static struct ctl_table_header root_table_header = @@ -579,11 +584,11 @@ static ctl_table kern_table[] = { { .ctl_name = KERN_PIDMAX, .procname = "pid_max", - .data = &pid_max, + .data = (void *)1, .maxlen = sizeof (int), .mode = 0644, - .proc_handler = &proc_dointvec_minmax, - .strategy = sysctl_intvec, + .proc_handler = &proc_pidmax, + .strategy = sysctl_pidmax, .extra1 = &pid_max_min, .extra2 = &pid_max_max, }, @@ -2157,6 +2162,29 @@ int proc_dointvec_ms_jiffies(ctl_table * do_proc_dointvec_ms_jiffies_conv, NULL); } +static int do_pidmax_conv(int *negp, unsigned long *lvalp, + int *valp, int write, void *data) +{ + if (write) { + int val = *negp ? -*lvalp : *lvalp; + if ((pid_max_min > val) || (pid_max_max < val)) + return -EINVAL; + current->pspace->max = val; + } else { + *negp = 0; + *lvalp = (unsigned long)(current->pspace->max); + } + return 0; +} + +static int proc_pidmax(ctl_table *table, int write, struct file *filp, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, + do_pidmax_conv, NULL); +} + + #else /* CONFIG_PROC_FS */ int proc_dostring(ctl_table *table, int write, struct file *filp, @@ -2222,6 +2250,12 @@ int proc_doulongvec_ms_jiffies_minmax(ct } +static int proc_pidmax(ctl_table *table, int write, struct file *filp, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return -ENOSYS; +} + #endif /* CONFIG_PROC_FS */ @@ -2367,6 +2401,43 @@ int sysctl_ms_jiffies(ctl_table *table, return 1; } +static int sysctl_pidmax(ctl_table *table, int __user *name, int nlen, + void __user *oldval, size_t __user *oldlenp, + void __user *newval, size_t newlen, void **context) +{ + int result = 0; + if (oldval && oldlenp) { + size_t len; + if (get_user(len, oldlenp)) + return -EFAULT; + if (len < sizeof(int)) + return -EINVAL; + if (put_user(current->pspace->max, oldval)) + return -EFAULT; + if (put_user(sizeof(int), oldlenp)) + return -EFAULT; + result = 1; + } + if (newval && newlen) { + int __user *vec = (int __user *)newval; + int value; + + if (newlen != sizeof(int)) + return -EINVAL; + + if (get_user(value, vec)) + return -EFAULT; + if (value < pid_max_min) + return -EINVAL; + if (value > pid_max_max) + return -EINVAL; + + current->pspace->max = value; + result = 1; + } + return result; +} + #else /* CONFIG_SYSCTL */ -- 1.1.5.g3480 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/