torture: Make stutter less vulnerable to compilers and races
[linux-2.6-microblaze.git] / kernel / sysctl.c
index 9576bd5..557d467 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/proc_fs.h>
 #include <linux/security.h>
 #include <linux/ctype.h>
-#include <linux/kmemcheck.h>
 #include <linux/kmemleak.h>
 #include <linux/fs.h>
 #include <linux/init.h>
@@ -67,6 +66,7 @@
 #include <linux/kexec.h>
 #include <linux/bpf.h>
 #include <linux/mount.h>
+#include <linux/pipe_fs_i.h>
 
 #include <linux/uaccess.h>
 #include <asm/processor.h>
@@ -1173,15 +1173,6 @@ static struct ctl_table kern_table[] = {
                .extra1         = &zero,
                .extra2         = &one_thousand,
        },
-#endif
-#ifdef CONFIG_KMEMCHECK
-       {
-               .procname       = "kmemcheck",
-               .data           = &kmemcheck_enabled,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = proc_dointvec,
-       },
 #endif
        {
                .procname       = "panic_on_warn",
@@ -1366,6 +1357,15 @@ static struct ctl_table vm_table[] = {
                .mode           = 0644,
                .proc_handler   = &hugetlb_mempolicy_sysctl_handler,
        },
+       {
+               .procname               = "numa_stat",
+               .data                   = &sysctl_vm_numa_stat,
+               .maxlen                 = sizeof(int),
+               .mode                   = 0644,
+               .proc_handler   = sysctl_vm_numa_stat_handler,
+               .extra1                 = &zero,
+               .extra2                 = &one,
+       },
 #endif
         {
                .procname       = "hugetlb_shm_group",
@@ -1817,7 +1817,7 @@ static struct ctl_table fs_table[] = {
        {
                .procname       = "pipe-max-size",
                .data           = &pipe_max_size,
-               .maxlen         = sizeof(int),
+               .maxlen         = sizeof(pipe_max_size),
                .mode           = 0644,
                .proc_handler   = &pipe_proc_fn,
                .extra1         = &pipe_min_size,
@@ -2576,12 +2576,13 @@ static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
        if (write) {
                unsigned int val = *lvalp;
 
+               if (*lvalp > UINT_MAX)
+                       return -EINVAL;
+
                if ((param->min && *param->min > val) ||
                    (param->max && *param->max < val))
                        return -ERANGE;
 
-               if (*lvalp > UINT_MAX)
-                       return -EINVAL;
                *valp = val;
        } else {
                unsigned int val = *valp;
@@ -2621,6 +2622,48 @@ int proc_douintvec_minmax(struct ctl_table *table, int write,
                                 do_proc_douintvec_minmax_conv, &param);
 }
 
+struct do_proc_dopipe_max_size_conv_param {
+       unsigned int *min;
+};
+
+static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
+                                       unsigned int *valp,
+                                       int write, void *data)
+{
+       struct do_proc_dopipe_max_size_conv_param *param = data;
+
+       if (write) {
+               unsigned int val;
+
+               if (*lvalp > UINT_MAX)
+                       return -EINVAL;
+
+               val = round_pipe_size(*lvalp);
+               if (val == 0)
+                       return -EINVAL;
+
+               if (param->min && *param->min > val)
+                       return -ERANGE;
+
+               *valp = val;
+       } else {
+               unsigned int val = *valp;
+               *lvalp = (unsigned long) val;
+       }
+
+       return 0;
+}
+
+int proc_dopipe_max_size(struct ctl_table *table, int write,
+                        void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       struct do_proc_dopipe_max_size_conv_param param = {
+               .min = (unsigned int *) table->extra1,
+       };
+       return do_proc_douintvec(table, write, buffer, lenp, ppos,
+                                do_proc_dopipe_max_size_conv, &param);
+}
+
 static void validate_coredump_safety(void)
 {
 #ifdef CONFIG_COREDUMP
@@ -3084,14 +3127,12 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
                        else
                                bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
                }
-               kfree(tmp_bitmap);
                *lenp -= left;
                *ppos += *lenp;
-               return 0;
-       } else {
-               kfree(tmp_bitmap);
-               return err;
        }
+
+       kfree(tmp_bitmap);
+       return err;
 }
 
 #else /* CONFIG_PROC_SYSCTL */
@@ -3126,6 +3167,12 @@ int proc_douintvec_minmax(struct ctl_table *table, int write,
        return -ENOSYS;
 }
 
+int proc_dopipe_max_size(struct ctl_table *table, int write,
+                        void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       return -ENOSYS;
+}
+
 int proc_dointvec_jiffies(struct ctl_table *table, int write,
                    void __user *buffer, size_t *lenp, loff_t *ppos)
 {
@@ -3169,6 +3216,7 @@ EXPORT_SYMBOL(proc_douintvec);
 EXPORT_SYMBOL(proc_dointvec_jiffies);
 EXPORT_SYMBOL(proc_dointvec_minmax);
 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
+EXPORT_SYMBOL_GPL(proc_dopipe_max_size);
 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
 EXPORT_SYMBOL(proc_dostring);