Merge branch 'work.namei' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[platform/kernel/linux-starfive.git] / fs / proc / proc_sysctl.c
index 6606f21..5d66fae 100644 (file)
@@ -94,14 +94,9 @@ static void sysctl_print_dir(struct ctl_dir *dir)
 
 static int namecmp(const char *name1, int len1, const char *name2, int len2)
 {
-       int minlen;
        int cmp;
 
-       minlen = len1;
-       if (minlen > len2)
-               minlen = len2;
-
-       cmp = memcmp(name1, name2, minlen);
+       cmp = memcmp(name1, name2, min(len1, len2));
        if (cmp == 0)
                cmp = len1 - len2;
        return cmp;
@@ -1108,6 +1103,11 @@ static int sysctl_check_table_array(const char *path, struct ctl_table *table)
                        err |= sysctl_err(path, table, "array not allowed");
        }
 
+       if (table->proc_handler == proc_dou8vec_minmax) {
+               if (table->maxlen != sizeof(u8))
+                       err |= sysctl_err(path, table, "array not allowed");
+       }
+
        return err;
 }
 
@@ -1123,6 +1123,7 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
                    (table->proc_handler == proc_douintvec) ||
                    (table->proc_handler == proc_douintvec_minmax) ||
                    (table->proc_handler == proc_dointvec_minmax) ||
+                   (table->proc_handler == proc_dou8vec_minmax) ||
                    (table->proc_handler == proc_dointvec_jiffies) ||
                    (table->proc_handler == proc_dointvec_userhz_jiffies) ||
                    (table->proc_handler == proc_dointvec_ms_jiffies) ||
@@ -1562,7 +1563,7 @@ err_register_leaves:
 }
 
 /**
- * register_sysctl_table_path - register a sysctl table hierarchy
+ * register_sysctl_paths - register a sysctl table hierarchy
  * @path: The path to the directory the sysctl table is in.
  * @table: the top-level table structure
  *