lkml.org 
[lkml]   [2006]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[RFC][PATCH 19/20] pspace: Upcate the pid_max sysctl to work in a per pspace fashion
    From
    Date

    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 <ebiederm@xmission.com>


    ---

    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 <linux/limits.h>
    #include <linux/dcache.h>
    #include <linux/syscalls.h>
    +#include <linux/pspace.h>

    #include <asm/uaccess.h>
    #include <asm/processor.h>
    @@ -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/

    \
     
     \ /
      Last update: 2006-02-06 21:13    [W:2.961 / U:0.216 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site