Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-drm-fsl-dcu.git] / kernel / sysctl.c
index 8bff2c18fb5ae1f697cd764feb4d7fb963309f83..e0ac6cd79fcf6955c6105815b4c8ab4d9d53e97f 100644 (file)
@@ -54,6 +54,7 @@ extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
 
 #ifdef CONFIG_X86
 #include <asm/nmi.h>
+#include <asm/stacktrace.h>
 #endif
 
 #if defined(CONFIG_SYSCTL)
@@ -64,7 +65,6 @@ extern int sysctl_overcommit_memory;
 extern int sysctl_overcommit_ratio;
 extern int sysctl_panic_on_oom;
 extern int max_threads;
-extern int sysrq_enabled;
 extern int core_uses_pid;
 extern int suid_dumpable;
 extern char core_pattern[];
@@ -91,7 +91,9 @@ extern char modprobe_path[];
 extern int sg_big_buff;
 #endif
 #ifdef CONFIG_SYSVIPC
-static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp,
+static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
+               void __user *buffer, size_t *lenp, loff_t *ppos);
+static int proc_ipc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
                void __user *buffer, size_t *lenp, loff_t *ppos);
 #endif
 
@@ -130,15 +132,27 @@ extern int max_lock_depth;
 
 #ifdef CONFIG_SYSCTL_SYSCALL
 static int parse_table(int __user *, int, void __user *, size_t __user *,
-               void __user *, size_t, ctl_table *, void **);
+               void __user *, size_t, ctl_table *);
 #endif
 
 static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
                  void __user *buffer, size_t *lenp, loff_t *ppos);
 
+static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
+                 void __user *oldval, size_t __user *oldlenp,
+                 void __user *newval, size_t newlen);
+
+#ifdef CONFIG_SYSVIPC
+static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
+                 void __user *oldval, size_t __user *oldlenp,
+                 void __user *newval, size_t newlen);
+#endif
+
 #ifdef CONFIG_PROC_SYSCTL
 static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
                  void __user *buffer, size_t *lenp, loff_t *ppos);
+static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp,
+                              void __user *buffer, size_t *lenp, loff_t *ppos);
 #endif
 
 static ctl_table root_table[];
@@ -162,6 +176,41 @@ extern ctl_table inotify_table[];
 int sysctl_legacy_va_layout;
 #endif
 
+
+static void *get_uts(ctl_table *table, int write)
+{
+       char *which = table->data;
+#ifdef CONFIG_UTS_NS
+       struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
+       which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
+#endif
+       if (!write)
+               down_read(&uts_sem);
+       else
+               down_write(&uts_sem);
+       return which;
+}
+
+static void put_uts(ctl_table *table, int write, void *which)
+{
+       if (!write)
+               up_read(&uts_sem);
+       else
+               up_write(&uts_sem);
+}
+
+#ifdef CONFIG_SYSVIPC
+static void *get_ipc(ctl_table *table, int write)
+{
+       char *which = table->data;
+       struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
+       which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns;
+       return which;
+}
+#else
+#define get_ipc(T,W) ((T)->data)
+#endif
+
 /* /proc declarations: */
 
 #ifdef CONFIG_PROC_SYSCTL
@@ -170,7 +219,7 @@ static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
 static int proc_opensys(struct inode *, struct file *);
 
-struct file_operations proc_sys_file_operations = {
+const struct file_operations proc_sys_file_operations = {
        .open           = proc_opensys,
        .read           = proc_readsys,
        .write          = proc_writesys,
@@ -228,7 +277,6 @@ static ctl_table root_table[] = {
 };
 
 static ctl_table kern_table[] = {
-#ifndef CONFIG_UTS_NS
        {
                .ctl_name       = KERN_OSTYPE,
                .procname       = "ostype",
@@ -236,7 +284,7 @@ static ctl_table kern_table[] = {
                .maxlen         = sizeof(init_uts_ns.name.sysname),
                .mode           = 0444,
                .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
+               .strategy       = &sysctl_uts_string,
        },
        {
                .ctl_name       = KERN_OSRELEASE,
@@ -245,7 +293,7 @@ static ctl_table kern_table[] = {
                .maxlen         = sizeof(init_uts_ns.name.release),
                .mode           = 0444,
                .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
+               .strategy       = &sysctl_uts_string,
        },
        {
                .ctl_name       = KERN_VERSION,
@@ -254,7 +302,7 @@ static ctl_table kern_table[] = {
                .maxlen         = sizeof(init_uts_ns.name.version),
                .mode           = 0444,
                .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
+               .strategy       = &sysctl_uts_string,
        },
        {
                .ctl_name       = KERN_NODENAME,
@@ -263,7 +311,7 @@ static ctl_table kern_table[] = {
                .maxlen         = sizeof(init_uts_ns.name.nodename),
                .mode           = 0644,
                .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
+               .strategy       = &sysctl_uts_string,
        },
        {
                .ctl_name       = KERN_DOMAINNAME,
@@ -272,56 +320,8 @@ static ctl_table kern_table[] = {
                .maxlen         = sizeof(init_uts_ns.name.domainname),
                .mode           = 0644,
                .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
+               .strategy       = &sysctl_uts_string,
        },
-#else  /* !CONFIG_UTS_NS */
-       {
-               .ctl_name       = KERN_OSTYPE,
-               .procname       = "ostype",
-               .data           = NULL,
-               /* could maybe use __NEW_UTS_LEN here? */
-               .maxlen         = FIELD_SIZEOF(struct new_utsname, sysname),
-               .mode           = 0444,
-               .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
-       },
-       {
-               .ctl_name       = KERN_OSRELEASE,
-               .procname       = "osrelease",
-               .data           = NULL,
-               .maxlen         = FIELD_SIZEOF(struct new_utsname, release),
-               .mode           = 0444,
-               .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
-       },
-       {
-               .ctl_name       = KERN_VERSION,
-               .procname       = "version",
-               .data           = NULL,
-               .maxlen         = FIELD_SIZEOF(struct new_utsname, version),
-               .mode           = 0444,
-               .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
-       },
-       {
-               .ctl_name       = KERN_NODENAME,
-               .procname       = "hostname",
-               .data           = NULL,
-               .maxlen         = FIELD_SIZEOF(struct new_utsname, nodename),
-               .mode           = 0644,
-               .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
-       },
-       {
-               .ctl_name       = KERN_DOMAINNAME,
-               .procname       = "domainname",
-               .data           = NULL,
-               .maxlen         = FIELD_SIZEOF(struct new_utsname, domainname),
-               .mode           = 0644,
-               .proc_handler   = &proc_do_uts_string,
-               .strategy       = &sysctl_string,
-       },
-#endif /* !CONFIG_UTS_NS */
        {
                .ctl_name       = KERN_PANIC,
                .procname       = "panic",
@@ -347,14 +347,16 @@ static ctl_table kern_table[] = {
                .proc_handler   = &proc_dostring,
                .strategy       = &sysctl_string,
        },
+#ifdef CONFIG_PROC_SYSCTL
        {
                .ctl_name       = KERN_TAINTED,
                .procname       = "tainted",
                .data           = &tainted,
                .maxlen         = sizeof(int),
-               .mode           = 0444,
-               .proc_handler   = &proc_dointvec,
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec_taint,
        },
+#endif
        {
                .ctl_name       = KERN_CAP_BSET,
                .procname       = "cap-bound",
@@ -480,65 +482,72 @@ static ctl_table kern_table[] = {
        {
                .ctl_name       = KERN_SHMMAX,
                .procname       = "shmmax",
-               .data           = NULL,
-               .maxlen         = sizeof (size_t),
+               .data           = &init_ipc_ns.shm_ctlmax,
+               .maxlen         = sizeof (init_ipc_ns.shm_ctlmax),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_doulongvec_minmax,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_SHMALL,
                .procname       = "shmall",
-               .data           = NULL,
-               .maxlen         = sizeof (size_t),
+               .data           = &init_ipc_ns.shm_ctlall,
+               .maxlen         = sizeof (init_ipc_ns.shm_ctlall),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_doulongvec_minmax,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_SHMMNI,
                .procname       = "shmmni",
-               .data           = NULL,
-               .maxlen         = sizeof (int),
+               .data           = &init_ipc_ns.shm_ctlmni,
+               .maxlen         = sizeof (init_ipc_ns.shm_ctlmni),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_dointvec,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_MSGMAX,
                .procname       = "msgmax",
-               .data           = NULL,
-               .maxlen         = sizeof (int),
+               .data           = &init_ipc_ns.msg_ctlmax,
+               .maxlen         = sizeof (init_ipc_ns.msg_ctlmax),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_dointvec,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_MSGMNI,
                .procname       = "msgmni",
-               .data           = NULL,
-               .maxlen         = sizeof (int),
+               .data           = &init_ipc_ns.msg_ctlmni,
+               .maxlen         = sizeof (init_ipc_ns.msg_ctlmni),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_dointvec,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_MSGMNB,
                .procname       =  "msgmnb",
-               .data           = NULL,
-               .maxlen         = sizeof (int),
+               .data           = &init_ipc_ns.msg_ctlmnb,
+               .maxlen         = sizeof (init_ipc_ns.msg_ctlmnb),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_dointvec,
+               .strategy       = sysctl_ipc_data,
        },
        {
                .ctl_name       = KERN_SEM,
                .procname       = "sem",
-               .data           = NULL,
+               .data           = &init_ipc_ns.sem_ctls,
                .maxlen         = 4*sizeof (int),
                .mode           = 0644,
-               .proc_handler   = &proc_do_ipc_string,
+               .proc_handler   = &proc_ipc_dointvec,
+               .strategy       = sysctl_ipc_data,
        },
 #endif
 #ifdef CONFIG_MAGIC_SYSRQ
        {
                .ctl_name       = KERN_SYSRQ,
                .procname       = "sysrq",
-               .data           = &sysrq_enabled,
+               .data           = &__sysrq_enabled,
                .maxlen         = sizeof (int),
                .mode           = 0644,
                .proc_handler   = &proc_dointvec,
@@ -707,6 +716,14 @@ static ctl_table kern_table[] = {
                .mode           = 0444,
                .proc_handler   = &proc_dointvec,
        },
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "kstack_depth_to_print",
+               .data           = &kstack_depth_to_print,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec,
+       },
 #endif
 #if defined(CONFIG_MMU)
        {
@@ -977,17 +994,6 @@ static ctl_table vm_table[] = {
                .extra1         = &zero,
        },
 #endif
-#ifdef CONFIG_SWAP
-       {
-               .ctl_name       = VM_SWAP_TOKEN_TIMEOUT,
-               .procname       = "swap_token_timeout",
-               .data           = &swap_token_default_timeout,
-               .maxlen         = sizeof(swap_token_default_timeout),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec_jiffies,
-               .strategy       = &sysctl_jiffies,
-       },
-#endif
 #ifdef CONFIG_NUMA
        {
                .ctl_name       = VM_ZONE_RECLAIM_MODE,
@@ -1241,7 +1247,6 @@ int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *ol
        do {
                struct ctl_table_header *head =
                        list_entry(tmp, struct ctl_table_header, ctl_entry);
-               void *context = NULL;
 
                if (!use_table(head))
                        continue;
@@ -1249,9 +1254,7 @@ int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *ol
                spin_unlock(&sysctl_lock);
 
                error = parse_table(name, nlen, oldval, oldlenp, 
-                                       newval, newlen, head->ctl_table,
-                                       &context);
-               kfree(context);
+                                       newval, newlen, head->ctl_table);
 
                spin_lock(&sysctl_lock);
                unuse_table(head);
@@ -1307,7 +1310,7 @@ static inline int ctl_perm(ctl_table *table, int op)
 static int parse_table(int __user *name, int nlen,
                       void __user *oldval, size_t __user *oldlenp,
                       void __user *newval, size_t newlen,
-                      ctl_table *table, void **context)
+                      ctl_table *table)
 {
        int n;
 repeat:
@@ -1315,7 +1318,9 @@ repeat:
                return -ENOTDIR;
        if (get_user(n, name))
                return -EFAULT;
-       for ( ; table->ctl_name; table++) {
+       for ( ; table->ctl_name || table->procname; table++) {
+               if (!table->ctl_name)
+                       continue;
                if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
                        int error;
                        if (table->child) {
@@ -1325,7 +1330,7 @@ repeat:
                                        error = table->strategy(
                                                table, name, nlen,
                                                oldval, oldlenp,
-                                               newval, newlen, context);
+                                               newval, newlen);
                                        if (error)
                                                return error;
                                }
@@ -1336,7 +1341,7 @@ repeat:
                        }
                        error = do_sysctl_strategy(table, name, nlen,
                                                   oldval, oldlenp,
-                                                  newval, newlen, context);
+                                                  newval, newlen);
                        return error;
                }
        }
@@ -1347,7 +1352,7 @@ repeat:
 int do_sysctl_strategy (ctl_table *table, 
                        int __user *name, int nlen,
                        void __user *oldval, size_t __user *oldlenp,
-                       void __user *newval, size_t newlen, void **context)
+                       void __user *newval, size_t newlen)
 {
        int op = 0, rc;
        size_t len;
@@ -1361,7 +1366,7 @@ int do_sysctl_strategy (ctl_table *table,
 
        if (table->strategy) {
                rc = table->strategy(table, name, nlen, oldval, oldlenp,
-                                    newval, newlen, context);
+                                    newval, newlen);
                if (rc < 0)
                        return rc;
                if (rc > 0)
@@ -1532,7 +1537,7 @@ static void register_proc_table(ctl_table * table, struct proc_dir_entry *root,
        int len;
        mode_t mode;
        
-       for (; table->ctl_name; table++) {
+       for (; table->ctl_name || table->procname; table++) {
                /* Can't do anything without a proc name. */
                if (!table->procname)
                        continue;
@@ -1579,7 +1584,7 @@ static void register_proc_table(ctl_table * table, struct proc_dir_entry *root,
 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
 {
        struct proc_dir_entry *de;
-       for (; table->ctl_name; table++) {
+       for (; table->ctl_name || table->procname; table++) {
                if (!(de = table->de))
                        continue;
                if (de->mode & S_IFDIR) {
@@ -1614,7 +1619,7 @@ static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
                          size_t count, loff_t *ppos)
 {
        int op;
-       struct proc_dir_entry *de = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *de = PDE(file->f_path.dentry->d_inode);
        struct ctl_table *table;
        size_t res;
        ssize_t error = -ENOTDIR;
@@ -1681,13 +1686,12 @@ static int _proc_do_string(void* data, int maxlen, int write,
        size_t len;
        char __user *p;
        char c;
-       
-       if (!data || !maxlen || !*lenp ||
-           (*ppos && !write)) {
+
+       if (!data || !maxlen || !*lenp) {
                *lenp = 0;
                return 0;
        }
-       
+
        if (write) {
                len = 0;
                p = buffer;
@@ -1708,6 +1712,15 @@ static int _proc_do_string(void* data, int maxlen, int write,
                len = strlen(data);
                if (len > maxlen)
                        len = maxlen;
+
+               if (*ppos > len) {
+                       *lenp = 0;
+                       return 0;
+               }
+
+               data += *ppos;
+               len  -= *ppos;
+
                if (len > *lenp)
                        len = *lenp;
                if (len)
@@ -1753,66 +1766,17 @@ int proc_dostring(ctl_table *table, int write, struct file *filp,
  *     Special case of dostring for the UTS structure. This has locks
  *     to observe. Should this be in kernel/sys.c ????
  */
-#ifndef CONFIG_UTS_NS
-static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
-                 void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       int r;
 
-       if (!write) {
-               down_read(&uts_sem);
-               r=proc_dostring(table,0,filp,buffer,lenp, ppos);
-               up_read(&uts_sem);
-       } else {
-               down_write(&uts_sem);
-               r=proc_dostring(table,1,filp,buffer,lenp, ppos);
-               up_write(&uts_sem);
-       }
-       return r;
-}
-#else /* !CONFIG_UTS_NS */
 static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
                  void __user *buffer, size_t *lenp, loff_t *ppos)
 {
        int r;
-       struct uts_namespace* uts_ns = current->nsproxy->uts_ns;
-       char* which;
-
-       switch (table->ctl_name) {
-       case KERN_OSTYPE:
-               which = uts_ns->name.sysname;
-               break;
-       case KERN_NODENAME:
-               which = uts_ns->name.nodename;
-               break;
-       case KERN_OSRELEASE:
-               which = uts_ns->name.release;
-               break;
-       case KERN_VERSION:
-               which = uts_ns->name.version;
-               break;
-       case KERN_DOMAINNAME:
-               which = uts_ns->name.domainname;
-               break;
-       default:
-               r = -EINVAL;
-               goto out;
-       }
-
-       if (!write) {
-               down_read(&uts_sem);
-               r=_proc_do_string(which,table->maxlen,0,filp,buffer,lenp, ppos);
-               up_read(&uts_sem);
-       } else {
-               down_write(&uts_sem);
-               r=_proc_do_string(which,table->maxlen,1,filp,buffer,lenp, ppos);
-               up_write(&uts_sem);
-       }
- out:
+       void *which;
+       which = get_uts(table, write);
+       r = _proc_do_string(which, table->maxlen,write,filp,buffer,lenp, ppos);
+       put_uts(table, write, which);
        return r;
 }
-#endif /* !CONFIG_UTS_NS */
 
 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
                                 int *valp,
@@ -1884,7 +1848,7 @@ static int __do_proc_dointvec(void *tbl_data, ctl_table *table,
                        p = buf;
                        if (*p == '-' && left > 1) {
                                neg = 1;
-                               left--, p++;
+                               p++;
                        }
                        if (*p < '0' || *p > '9')
                                break;
@@ -1977,8 +1941,6 @@ int proc_dointvec(ctl_table *table, int write, struct file *filp,
 #define OP_SET 0
 #define OP_AND 1
 #define OP_OR  2
-#define OP_MAX 3
-#define OP_MIN 4
 
 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
                                      int *valp,
@@ -1991,12 +1953,6 @@ static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
                case OP_SET:    *valp = val; break;
                case OP_AND:    *valp &= val; break;
                case OP_OR:     *valp |= val; break;
-               case OP_MAX:    if(*valp < val)
-                                       *valp = val;
-                               break;
-               case OP_MIN:    if(*valp > val)
-                               *valp = val;
-                               break;
                }
        } else {
                int val = *valp;
@@ -2020,7 +1976,7 @@ int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
 {
        int op;
 
-       if (!capable(CAP_SYS_MODULE)) {
+       if (write && !capable(CAP_SYS_MODULE)) {
                return -EPERM;
        }
 
@@ -2029,6 +1985,22 @@ int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
                                do_proc_dointvec_bset_conv,&op);
 }
 
+/*
+ *     Taint values can only be increased
+ */
+static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp,
+                              void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       int op;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       op = OP_OR;
+       return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
+                               do_proc_dointvec_bset_conv,&op);
+}
+
 struct do_proc_dointvec_minmax_conv_param {
        int *min;
        int *max;
@@ -2135,7 +2107,7 @@ static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write,
                        p = buf;
                        if (*p == '-' && left > 1) {
                                neg = 1;
-                               left--, p++;
+                               p++;
                        }
                        if (*p < '0' || *p > '9')
                                break;
@@ -2391,46 +2363,24 @@ int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
 }
 
 #ifdef CONFIG_SYSVIPC
-static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp,
-               void __user *buffer, size_t *lenp, loff_t *ppos)
+static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
+       void __user *buffer, size_t *lenp, loff_t *ppos)
 {
-       void *data;
-       struct ipc_namespace *ns;
-
-       ns = current->nsproxy->ipc_ns;
-
-       switch (table->ctl_name) {
-       case KERN_SHMMAX:
-               data = &ns->shm_ctlmax;
-               goto proc_minmax;
-       case KERN_SHMALL:
-               data = &ns->shm_ctlall;
-               goto proc_minmax;
-       case KERN_SHMMNI:
-               data = &ns->shm_ctlmni;
-               break;
-       case KERN_MSGMAX:
-               data = &ns->msg_ctlmax;
-               break;
-       case KERN_MSGMNI:
-               data = &ns->msg_ctlmni;
-               break;
-       case KERN_MSGMNB:
-               data = &ns->msg_ctlmnb;
-               break;
-       case KERN_SEM:
-               data = &ns->sem_ctls;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return __do_proc_dointvec(data, table, write, filp, buffer,
+       void *which;
+       which = get_ipc(table, write);
+       return __do_proc_dointvec(which, table, write, filp, buffer,
                        lenp, ppos, NULL, NULL);
-proc_minmax:
-       return __do_proc_doulongvec_minmax(data, table, write, filp, buffer,
+}
+
+static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
+       struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       void *which;
+       which = get_ipc(table, write);
+       return __do_proc_doulongvec_minmax(which, table, write, filp, buffer,
                        lenp, ppos, 1l, 1l);
 }
+
 #endif
 
 static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
@@ -2475,6 +2425,17 @@ static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp,
 {
        return -ENOSYS;
 }
+static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
+               void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       return -ENOSYS;
+}
+static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
+               struct file *filp, void __user *buffer,
+               size_t *lenp, loff_t *ppos)
+{
+       return -ENOSYS;
+}
 #endif
 
 int proc_dointvec(ctl_table *table, int write, struct file *filp,
@@ -2539,7 +2500,7 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
 /* The generic string strategy routine: */
 int sysctl_string(ctl_table *table, int __user *name, int nlen,
                  void __user *oldval, size_t __user *oldlenp,
-                 void __user *newval, size_t newlen, void **context)
+                 void __user *newval, size_t newlen)
 {
        if (!table->data || !table->maxlen) 
                return -ENOTDIR;
@@ -2585,7 +2546,7 @@ int sysctl_string(ctl_table *table, int __user *name, int nlen,
  */
 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
                void __user *oldval, size_t __user *oldlenp,
-               void __user *newval, size_t newlen, void **context)
+               void __user *newval, size_t newlen)
 {
 
        if (newval && newlen) {
@@ -2621,19 +2582,25 @@ int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
 /* Strategy function to convert jiffies to seconds */ 
 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
                void __user *oldval, size_t __user *oldlenp,
-               void __user *newval, size_t newlen, void **context)
+               void __user *newval, size_t newlen)
 {
-       if (oldval) {
+       if (oldval && oldlenp) {
                size_t olen;
-               if (oldlenp) { 
-                       if (get_user(olen, oldlenp))
+
+               if (get_user(olen, oldlenp))
+                       return -EFAULT;
+               if (olen) {
+                       int val;
+
+                       if (olen < sizeof(int))
+                               return -EINVAL;
+
+                       val = *(int *)(table->data) / HZ;
+                       if (put_user(val, (int __user *)oldval))
+                               return -EFAULT;
+                       if (put_user(sizeof(int), oldlenp))
                                return -EFAULT;
-                       if (olen!=sizeof(int))
-                               return -EINVAL; 
                }
-               if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
-                   (oldlenp && put_user(sizeof(int),oldlenp)))
-                       return -EFAULT;
        }
        if (newval && newlen) { 
                int new;
@@ -2649,19 +2616,25 @@ int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
 /* Strategy function to convert jiffies to seconds */ 
 int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
                void __user *oldval, size_t __user *oldlenp,
-               void __user *newval, size_t newlen, void **context)
+               void __user *newval, size_t newlen)
 {
-       if (oldval) {
+       if (oldval && oldlenp) {
                size_t olen;
-               if (oldlenp) { 
-                       if (get_user(olen, oldlenp))
+
+               if (get_user(olen, oldlenp))
+                       return -EFAULT;
+               if (olen) {
+                       int val;
+
+                       if (olen < sizeof(int))
+                               return -EINVAL;
+
+                       val = jiffies_to_msecs(*(int *)(table->data));
+                       if (put_user(val, (int __user *)oldval))
+                               return -EFAULT;
+                       if (put_user(sizeof(int), oldlenp))
                                return -EFAULT;
-                       if (olen!=sizeof(int))
-                               return -EINVAL; 
                }
-               if (put_user(jiffies_to_msecs(*(int *)(table->data)), (int __user *)oldval) ||
-                   (oldlenp && put_user(sizeof(int),oldlenp)))
-                       return -EFAULT;
        }
        if (newval && newlen) { 
                int new;
@@ -2674,50 +2647,142 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
        return 1;
 }
 
+
+/* The generic string strategy routine: */
+static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
+                 void __user *oldval, size_t __user *oldlenp,
+                 void __user *newval, size_t newlen)
+{
+       struct ctl_table uts_table;
+       int r, write;
+       write = newval && newlen;
+       memcpy(&uts_table, table, sizeof(uts_table));
+       uts_table.data = get_uts(table, write);
+       r = sysctl_string(&uts_table, name, nlen,
+               oldval, oldlenp, newval, newlen);
+       put_uts(table, write, uts_table.data);
+       return r;
+}
+
+#ifdef CONFIG_SYSVIPC
+/* The generic sysctl ipc data routine. */
+static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
+               void __user *oldval, size_t __user *oldlenp,
+               void __user *newval, size_t newlen)
+{
+       size_t len;
+       void *data;
+
+       /* Get out of I don't have a variable */
+       if (!table->data || !table->maxlen)
+               return -ENOTDIR;
+
+       data = get_ipc(table, 1);
+       if (!data)
+               return -ENOTDIR;
+
+       if (oldval && oldlenp) {
+               if (get_user(len, oldlenp))
+                       return -EFAULT;
+               if (len) {
+                       if (len > table->maxlen)
+                               len = table->maxlen;
+                       if (copy_to_user(oldval, data, len))
+                               return -EFAULT;
+                       if (put_user(len, oldlenp))
+                               return -EFAULT;
+               }
+       }
+
+       if (newval && newlen) {
+               if (newlen > table->maxlen)
+                       newlen = table->maxlen;
+
+               if (copy_from_user(data, newval, newlen))
+                       return -EFAULT;
+       }
+       return 1;
+}
+#endif
+
 #else /* CONFIG_SYSCTL_SYSCALL */
 
 
 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
 {
        static int msg_count;
+       struct __sysctl_args tmp;
+       int name[CTL_MAXNAME];
+       int i;
+
+       /* Read in the sysctl name for better debug message logging */
+       if (copy_from_user(&tmp, args, sizeof(tmp)))
+               return -EFAULT;
+       if (tmp.nlen <= 0 || tmp.nlen >= CTL_MAXNAME)
+               return -ENOTDIR;
+       for (i = 0; i < tmp.nlen; i++)
+               if (get_user(name[i], tmp.name + i))
+                       return -EFAULT;
+
+       /* Ignore accesses to kernel.version */
+       if ((tmp.nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
+               goto out;
 
        if (msg_count < 5) {
                msg_count++;
                printk(KERN_INFO
                        "warning: process `%s' used the removed sysctl "
-                       "system call\n", current->comm);
+                       "system call with ", current->comm);
+               for (i = 0; i < tmp.nlen; i++)
+                       printk("%d.", name[i]);
+               printk("\n");
        }
+out:
        return -ENOSYS;
 }
 
 int sysctl_string(ctl_table *table, int __user *name, int nlen,
                  void __user *oldval, size_t __user *oldlenp,
-                 void __user *newval, size_t newlen, void **context)
+                 void __user *newval, size_t newlen)
 {
        return -ENOSYS;
 }
 
 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
                void __user *oldval, size_t __user *oldlenp,
-               void __user *newval, size_t newlen, void **context)
+               void __user *newval, size_t newlen)
 {
        return -ENOSYS;
 }
 
 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
                void __user *oldval, size_t __user *oldlenp,
-               void __user *newval, size_t newlen, void **context)
+               void __user *newval, size_t newlen)
 {
        return -ENOSYS;
 }
 
 int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
                void __user *oldval, size_t __user *oldlenp,
-               void __user *newval, size_t newlen, void **context)
+               void __user *newval, size_t newlen)
 {
        return -ENOSYS;
 }
 
+static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
+                 void __user *oldval, size_t __user *oldlenp,
+                 void __user *newval, size_t newlen)
+{
+       return -ENOSYS;
+}
+#ifdef CONFIG_SYSVIPC
+static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
+               void __user *oldval, size_t __user *oldlenp,
+               void __user *newval, size_t newlen)
+{
+       return -ENOSYS;
+}
+#endif
 #endif /* CONFIG_SYSCTL_SYSCALL */
 
 /*