aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/proc/internal.h3
-rw-r--r--fs/proc/proc_sysctl.c622
-rw-r--r--include/linux/sysctl.h16
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/sysctl.c464
-rw-r--r--kernel/sysctl_check.c160
6 files changed, 625 insertions, 641 deletions
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 292577531ad1..3b5ecd960d6a 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -10,12 +10,15 @@
10 */ 10 */
11 11
12#include <linux/proc_fs.h> 12#include <linux/proc_fs.h>
13struct ctl_table_header;
13 14
14extern struct proc_dir_entry proc_root; 15extern struct proc_dir_entry proc_root;
15#ifdef CONFIG_PROC_SYSCTL 16#ifdef CONFIG_PROC_SYSCTL
16extern int proc_sys_init(void); 17extern int proc_sys_init(void);
18extern void sysctl_head_put(struct ctl_table_header *head);
17#else 19#else
18static inline void proc_sys_init(void) { } 20static inline void proc_sys_init(void) { }
21static inline void sysctl_head_put(struct ctl_table_header *head) { }
19#endif 22#endif
20#ifdef CONFIG_NET 23#ifdef CONFIG_NET
21extern int proc_net_init(void); 24extern int proc_net_init(void);
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 9d29d28af577..06e6f10ee8ec 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -7,6 +7,7 @@
7#include <linux/proc_fs.h> 7#include <linux/proc_fs.h>
8#include <linux/security.h> 8#include <linux/security.h>
9#include <linux/namei.h> 9#include <linux/namei.h>
10#include <linux/module.h>
10#include "internal.h" 11#include "internal.h"
11 12
12static const struct dentry_operations proc_sys_dentry_operations; 13static const struct dentry_operations proc_sys_dentry_operations;
@@ -24,6 +25,209 @@ void proc_sys_poll_notify(struct ctl_table_poll *poll)
24 wake_up_interruptible(&poll->wait); 25 wake_up_interruptible(&poll->wait);
25} 26}
26 27
28static struct ctl_table root_table[1];
29static struct ctl_table_root sysctl_table_root;
30static struct ctl_table_header root_table_header = {
31 {{.count = 1,
32 .ctl_table = root_table,
33 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}},
34 .root = &sysctl_table_root,
35 .set = &sysctl_table_root.default_set,
36};
37static struct ctl_table_root sysctl_table_root = {
38 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
39 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
40};
41
42static DEFINE_SPINLOCK(sysctl_lock);
43
44/* called under sysctl_lock */
45static int use_table(struct ctl_table_header *p)
46{
47 if (unlikely(p->unregistering))
48 return 0;
49 p->used++;
50 return 1;
51}
52
53/* called under sysctl_lock */
54static void unuse_table(struct ctl_table_header *p)
55{
56 if (!--p->used)
57 if (unlikely(p->unregistering))
58 complete(p->unregistering);
59}
60
61/* called under sysctl_lock, will reacquire if has to wait */
62static void start_unregistering(struct ctl_table_header *p)
63{
64 /*
65 * if p->used is 0, nobody will ever touch that entry again;
66 * we'll eliminate all paths to it before dropping sysctl_lock
67 */
68 if (unlikely(p->used)) {
69 struct completion wait;
70 init_completion(&wait);
71 p->unregistering = &wait;
72 spin_unlock(&sysctl_lock);
73 wait_for_completion(&wait);
74 spin_lock(&sysctl_lock);
75 } else {
76 /* anything non-NULL; we'll never dereference it */
77 p->unregistering = ERR_PTR(-EINVAL);
78 }
79 /*
80 * do not remove from the list until nobody holds it; walking the
81 * list in do_sysctl() relies on that.
82 */
83 list_del_init(&p->ctl_entry);
84}
85
86static void sysctl_head_get(struct ctl_table_header *head)
87{
88 spin_lock(&sysctl_lock);
89 head->count++;
90 spin_unlock(&sysctl_lock);
91}
92
93void sysctl_head_put(struct ctl_table_header *head)
94{
95 spin_lock(&sysctl_lock);
96 if (!--head->count)
97 kfree_rcu(head, rcu);
98 spin_unlock(&sysctl_lock);
99}
100
101static struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
102{
103 if (!head)
104 BUG();
105 spin_lock(&sysctl_lock);
106 if (!use_table(head))
107 head = ERR_PTR(-ENOENT);
108 spin_unlock(&sysctl_lock);
109 return head;
110}
111
112static void sysctl_head_finish(struct ctl_table_header *head)
113{
114 if (!head)
115 return;
116 spin_lock(&sysctl_lock);
117 unuse_table(head);
118 spin_unlock(&sysctl_lock);
119}
120
121static struct ctl_table_set *
122lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
123{
124 struct ctl_table_set *set = &root->default_set;
125 if (root->lookup)
126 set = root->lookup(root, namespaces);
127 return set;
128}
129
130static struct list_head *
131lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
132{
133 struct ctl_table_set *set = lookup_header_set(root, namespaces);
134 return &set->list;
135}
136
137static struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
138 struct ctl_table_header *prev)
139{
140 struct ctl_table_root *root;
141 struct list_head *header_list;
142 struct ctl_table_header *head;
143 struct list_head *tmp;
144
145 spin_lock(&sysctl_lock);
146 if (prev) {
147 head = prev;
148 tmp = &prev->ctl_entry;
149 unuse_table(prev);
150 goto next;
151 }
152 tmp = &root_table_header.ctl_entry;
153 for (;;) {
154 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
155
156 if (!use_table(head))
157 goto next;
158 spin_unlock(&sysctl_lock);
159 return head;
160 next:
161 root = head->root;
162 tmp = tmp->next;
163 header_list = lookup_header_list(root, namespaces);
164 if (tmp != header_list)
165 continue;
166
167 do {
168 root = list_entry(root->root_list.next,
169 struct ctl_table_root, root_list);
170 if (root == &sysctl_table_root)
171 goto out;
172 header_list = lookup_header_list(root, namespaces);
173 } while (list_empty(header_list));
174 tmp = header_list->next;
175 }
176out:
177 spin_unlock(&sysctl_lock);
178 return NULL;
179}
180
181static struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
182{
183 return __sysctl_head_next(current->nsproxy, prev);
184}
185
186void register_sysctl_root(struct ctl_table_root *root)
187{
188 spin_lock(&sysctl_lock);
189 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
190 spin_unlock(&sysctl_lock);
191}
192
193/*
194 * sysctl_perm does NOT grant the superuser all rights automatically, because
195 * some sysctl variables are readonly even to root.
196 */
197
198static int test_perm(int mode, int op)
199{
200 if (!current_euid())
201 mode >>= 6;
202 else if (in_egroup_p(0))
203 mode >>= 3;
204 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
205 return 0;
206 return -EACCES;
207}
208
209static int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
210{
211 int mode;
212
213 if (root->permissions)
214 mode = root->permissions(root, current->nsproxy, table);
215 else
216 mode = table->mode;
217
218 return test_perm(mode, op);
219}
220
221static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
222{
223 for (; table->procname; table++) {
224 table->parent = parent;
225 if (table->child)
226 sysctl_set_parent(table, table->child);
227 }
228}
229
230
27static struct inode *proc_sys_make_inode(struct super_block *sb, 231static struct inode *proc_sys_make_inode(struct super_block *sb,
28 struct ctl_table_header *head, struct ctl_table *table) 232 struct ctl_table_header *head, struct ctl_table *table)
29{ 233{
@@ -435,6 +639,21 @@ static int proc_sys_delete(const struct dentry *dentry)
435 return !!PROC_I(dentry->d_inode)->sysctl->unregistering; 639 return !!PROC_I(dentry->d_inode)->sysctl->unregistering;
436} 640}
437 641
642static int sysctl_is_seen(struct ctl_table_header *p)
643{
644 struct ctl_table_set *set = p->set;
645 int res;
646 spin_lock(&sysctl_lock);
647 if (p->unregistering)
648 res = 0;
649 else if (!set->is_seen)
650 res = 1;
651 else
652 res = set->is_seen(set);
653 spin_unlock(&sysctl_lock);
654 return res;
655}
656
438static int proc_sys_compare(const struct dentry *parent, 657static int proc_sys_compare(const struct dentry *parent,
439 const struct inode *pinode, 658 const struct inode *pinode,
440 const struct dentry *dentry, const struct inode *inode, 659 const struct dentry *dentry, const struct inode *inode,
@@ -460,6 +679,409 @@ static const struct dentry_operations proc_sys_dentry_operations = {
460 .d_compare = proc_sys_compare, 679 .d_compare = proc_sys_compare,
461}; 680};
462 681
682static struct ctl_table *is_branch_in(struct ctl_table *branch,
683 struct ctl_table *table)
684{
685 struct ctl_table *p;
686 const char *s = branch->procname;
687
688 /* branch should have named subdirectory as its first element */
689 if (!s || !branch->child)
690 return NULL;
691
692 /* ... and nothing else */
693 if (branch[1].procname)
694 return NULL;
695
696 /* table should contain subdirectory with the same name */
697 for (p = table; p->procname; p++) {
698 if (!p->child)
699 continue;
700 if (p->procname && strcmp(p->procname, s) == 0)
701 return p;
702 }
703 return NULL;
704}
705
706/* see if attaching q to p would be an improvement */
707static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
708{
709 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
710 struct ctl_table *next;
711 int is_better = 0;
712 int not_in_parent = !p->attached_by;
713
714 while ((next = is_branch_in(by, to)) != NULL) {
715 if (by == q->attached_by)
716 is_better = 1;
717 if (to == p->attached_by)
718 not_in_parent = 1;
719 by = by->child;
720 to = next->child;
721 }
722
723 if (is_better && not_in_parent) {
724 q->attached_by = by;
725 q->attached_to = to;
726 q->parent = p;
727 }
728}
729
730#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
731static int sysctl_depth(struct ctl_table *table)
732{
733 struct ctl_table *tmp;
734 int depth;
735
736 depth = 0;
737 for (tmp = table; tmp->parent; tmp = tmp->parent)
738 depth++;
739
740 return depth;
741}
742
743static struct ctl_table *sysctl_parent(struct ctl_table *table, int n)
744{
745 int i;
746
747 for (i = 0; table && i < n; i++)
748 table = table->parent;
749
750 return table;
751}
752
753
754static void sysctl_print_path(struct ctl_table *table)
755{
756 struct ctl_table *tmp;
757 int depth, i;
758 depth = sysctl_depth(table);
759 if (table->procname) {
760 for (i = depth; i >= 0; i--) {
761 tmp = sysctl_parent(table, i);
762 printk("/%s", tmp->procname?tmp->procname:"");
763 }
764 }
765 printk(" ");
766}
767
768static struct ctl_table *sysctl_check_lookup(struct nsproxy *namespaces,
769 struct ctl_table *table)
770{
771 struct ctl_table_header *head;
772 struct ctl_table *ref, *test;
773 int depth, cur_depth;
774
775 depth = sysctl_depth(table);
776
777 for (head = __sysctl_head_next(namespaces, NULL); head;
778 head = __sysctl_head_next(namespaces, head)) {
779 cur_depth = depth;
780 ref = head->ctl_table;
781repeat:
782 test = sysctl_parent(table, cur_depth);
783 for (; ref->procname; ref++) {
784 int match = 0;
785 if (cur_depth && !ref->child)
786 continue;
787
788 if (test->procname && ref->procname &&
789 (strcmp(test->procname, ref->procname) == 0))
790 match++;
791
792 if (match) {
793 if (cur_depth != 0) {
794 cur_depth--;
795 ref = ref->child;
796 goto repeat;
797 }
798 goto out;
799 }
800 }
801 }
802 ref = NULL;
803out:
804 sysctl_head_finish(head);
805 return ref;
806}
807
808static void set_fail(const char **fail, struct ctl_table *table, const char *str)
809{
810 if (*fail) {
811 printk(KERN_ERR "sysctl table check failed: ");
812 sysctl_print_path(table);
813 printk(" %s\n", *fail);
814 dump_stack();
815 }
816 *fail = str;
817}
818
819static void sysctl_check_leaf(struct nsproxy *namespaces,
820 struct ctl_table *table, const char **fail)
821{
822 struct ctl_table *ref;
823
824 ref = sysctl_check_lookup(namespaces, table);
825 if (ref && (ref != table))
826 set_fail(fail, table, "Sysctl already exists");
827}
828
829static int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table)
830{
831 int error = 0;
832 for (; table->procname; table++) {
833 const char *fail = NULL;
834
835 if (table->parent) {
836 if (!table->parent->procname)
837 set_fail(&fail, table, "Parent without procname");
838 }
839 if (table->child) {
840 if (table->data)
841 set_fail(&fail, table, "Directory with data?");
842 if (table->maxlen)
843 set_fail(&fail, table, "Directory with maxlen?");
844 if ((table->mode & (S_IRUGO|S_IXUGO)) != table->mode)
845 set_fail(&fail, table, "Writable sysctl directory");
846 if (table->proc_handler)
847 set_fail(&fail, table, "Directory with proc_handler");
848 if (table->extra1)
849 set_fail(&fail, table, "Directory with extra1");
850 if (table->extra2)
851 set_fail(&fail, table, "Directory with extra2");
852 } else {
853 if ((table->proc_handler == proc_dostring) ||
854 (table->proc_handler == proc_dointvec) ||
855 (table->proc_handler == proc_dointvec_minmax) ||
856 (table->proc_handler == proc_dointvec_jiffies) ||
857 (table->proc_handler == proc_dointvec_userhz_jiffies) ||
858 (table->proc_handler == proc_dointvec_ms_jiffies) ||
859 (table->proc_handler == proc_doulongvec_minmax) ||
860 (table->proc_handler == proc_doulongvec_ms_jiffies_minmax)) {
861 if (!table->data)
862 set_fail(&fail, table, "No data");
863 if (!table->maxlen)
864 set_fail(&fail, table, "No maxlen");
865 }
866#ifdef CONFIG_PROC_SYSCTL
867 if (!table->proc_handler)
868 set_fail(&fail, table, "No proc_handler");
869#endif
870 sysctl_check_leaf(namespaces, table, &fail);
871 }
872 if (table->mode > 0777)
873 set_fail(&fail, table, "bogus .mode");
874 if (fail) {
875 set_fail(&fail, table, NULL);
876 error = -EINVAL;
877 }
878 if (table->child)
879 error |= sysctl_check_table(namespaces, table->child);
880 }
881 return error;
882}
883#endif /* CONFIG_SYSCTL_SYSCALL_CHECK */
884
885/**
886 * __register_sysctl_paths - register a sysctl hierarchy
887 * @root: List of sysctl headers to register on
888 * @namespaces: Data to compute which lists of sysctl entries are visible
889 * @path: The path to the directory the sysctl table is in.
890 * @table: the top-level table structure
891 *
892 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
893 * array. A completely 0 filled entry terminates the table.
894 *
895 * The members of the &struct ctl_table structure are used as follows:
896 *
897 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
898 * enter a sysctl file
899 *
900 * data - a pointer to data for use by proc_handler
901 *
902 * maxlen - the maximum size in bytes of the data
903 *
904 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
905 *
906 * child - a pointer to the child sysctl table if this entry is a directory, or
907 * %NULL.
908 *
909 * proc_handler - the text handler routine (described below)
910 *
911 * de - for internal use by the sysctl routines
912 *
913 * extra1, extra2 - extra pointers usable by the proc handler routines
914 *
915 * Leaf nodes in the sysctl tree will be represented by a single file
916 * under /proc; non-leaf nodes will be represented by directories.
917 *
918 * sysctl(2) can automatically manage read and write requests through
919 * the sysctl table. The data and maxlen fields of the ctl_table
920 * struct enable minimal validation of the values being written to be
921 * performed, and the mode field allows minimal authentication.
922 *
923 * There must be a proc_handler routine for any terminal nodes
924 * mirrored under /proc/sys (non-terminals are handled by a built-in
925 * directory handler). Several default handlers are available to
926 * cover common cases -
927 *
928 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
929 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
930 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
931 *
932 * It is the handler's job to read the input buffer from user memory
933 * and process it. The handler should return 0 on success.
934 *
935 * This routine returns %NULL on a failure to register, and a pointer
936 * to the table header on success.
937 */
938struct ctl_table_header *__register_sysctl_paths(
939 struct ctl_table_root *root,
940 struct nsproxy *namespaces,
941 const struct ctl_path *path, struct ctl_table *table)
942{
943 struct ctl_table_header *header;
944 struct ctl_table *new, **prevp;
945 unsigned int n, npath;
946 struct ctl_table_set *set;
947
948 /* Count the path components */
949 for (npath = 0; path[npath].procname; ++npath)
950 ;
951
952 /*
953 * For each path component, allocate a 2-element ctl_table array.
954 * The first array element will be filled with the sysctl entry
955 * for this, the second will be the sentinel (procname == 0).
956 *
957 * We allocate everything in one go so that we don't have to
958 * worry about freeing additional memory in unregister_sysctl_table.
959 */
960 header = kzalloc(sizeof(struct ctl_table_header) +
961 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
962 if (!header)
963 return NULL;
964
965 new = (struct ctl_table *) (header + 1);
966
967 /* Now connect the dots */
968 prevp = &header->ctl_table;
969 for (n = 0; n < npath; ++n, ++path) {
970 /* Copy the procname */
971 new->procname = path->procname;
972 new->mode = 0555;
973
974 *prevp = new;
975 prevp = &new->child;
976
977 new += 2;
978 }
979 *prevp = table;
980 header->ctl_table_arg = table;
981
982 INIT_LIST_HEAD(&header->ctl_entry);
983 header->used = 0;
984 header->unregistering = NULL;
985 header->root = root;
986 sysctl_set_parent(NULL, header->ctl_table);
987 header->count = 1;
988#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
989 if (sysctl_check_table(namespaces, header->ctl_table)) {
990 kfree(header);
991 return NULL;
992 }
993#endif
994 spin_lock(&sysctl_lock);
995 header->set = lookup_header_set(root, namespaces);
996 header->attached_by = header->ctl_table;
997 header->attached_to = root_table;
998 header->parent = &root_table_header;
999 for (set = header->set; set; set = set->parent) {
1000 struct ctl_table_header *p;
1001 list_for_each_entry(p, &set->list, ctl_entry) {
1002 if (p->unregistering)
1003 continue;
1004 try_attach(p, header);
1005 }
1006 }
1007 header->parent->count++;
1008 list_add_tail(&header->ctl_entry, &header->set->list);
1009 spin_unlock(&sysctl_lock);
1010
1011 return header;
1012}
1013
1014/**
1015 * register_sysctl_table_path - register a sysctl table hierarchy
1016 * @path: The path to the directory the sysctl table is in.
1017 * @table: the top-level table structure
1018 *
1019 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1020 * array. A completely 0 filled entry terminates the table.
1021 *
1022 * See __register_sysctl_paths for more details.
1023 */
1024struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1025 struct ctl_table *table)
1026{
1027 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1028 path, table);
1029}
1030EXPORT_SYMBOL(register_sysctl_paths);
1031
1032/**
1033 * register_sysctl_table - register a sysctl table hierarchy
1034 * @table: the top-level table structure
1035 *
1036 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1037 * array. A completely 0 filled entry terminates the table.
1038 *
1039 * See register_sysctl_paths for more details.
1040 */
1041struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1042{
1043 static const struct ctl_path null_path[] = { {} };
1044
1045 return register_sysctl_paths(null_path, table);
1046}
1047EXPORT_SYMBOL(register_sysctl_table);
1048
1049/**
1050 * unregister_sysctl_table - unregister a sysctl table hierarchy
1051 * @header: the header returned from register_sysctl_table
1052 *
1053 * Unregisters the sysctl table and all children. proc entries may not
1054 * actually be removed until they are no longer used by anyone.
1055 */
1056void unregister_sysctl_table(struct ctl_table_header * header)
1057{
1058 might_sleep();
1059
1060 if (header == NULL)
1061 return;
1062
1063 spin_lock(&sysctl_lock);
1064 start_unregistering(header);
1065 if (!--header->parent->count) {
1066 WARN_ON(1);
1067 kfree_rcu(header->parent, rcu);
1068 }
1069 if (!--header->count)
1070 kfree_rcu(header, rcu);
1071 spin_unlock(&sysctl_lock);
1072}
1073EXPORT_SYMBOL(unregister_sysctl_table);
1074
1075void setup_sysctl_set(struct ctl_table_set *p,
1076 struct ctl_table_set *parent,
1077 int (*is_seen)(struct ctl_table_set *))
1078{
1079 INIT_LIST_HEAD(&p->list);
1080 p->parent = parent ? parent : &sysctl_table_root.default_set;
1081 p->is_seen = is_seen;
1082}
1083
1084
463int __init proc_sys_init(void) 1085int __init proc_sys_init(void)
464{ 1086{
465 struct proc_dir_entry *proc_sys_root; 1087 struct proc_dir_entry *proc_sys_root;
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 5e3532e9599f..08cabbfddacb 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -1073,17 +1073,6 @@ extern void setup_sysctl_set(struct ctl_table_set *p,
1073 struct ctl_table_set *parent, 1073 struct ctl_table_set *parent,
1074 int (*is_seen)(struct ctl_table_set *)); 1074 int (*is_seen)(struct ctl_table_set *));
1075 1075
1076extern void sysctl_head_get(struct ctl_table_header *);
1077extern void sysctl_head_put(struct ctl_table_header *);
1078extern int sysctl_is_seen(struct ctl_table_header *);
1079extern struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *);
1080extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev);
1081extern struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1082 struct ctl_table_header *prev);
1083extern void sysctl_head_finish(struct ctl_table_header *prev);
1084extern int sysctl_perm(struct ctl_table_root *root,
1085 struct ctl_table *table, int op);
1086
1087void register_sysctl_root(struct ctl_table_root *root); 1076void register_sysctl_root(struct ctl_table_root *root);
1088struct ctl_table_header *__register_sysctl_paths( 1077struct ctl_table_header *__register_sysctl_paths(
1089 struct ctl_table_root *root, struct nsproxy *namespaces, 1078 struct ctl_table_root *root, struct nsproxy *namespaces,
@@ -1093,7 +1082,6 @@ struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1093 struct ctl_table *table); 1082 struct ctl_table *table);
1094 1083
1095void unregister_sysctl_table(struct ctl_table_header * table); 1084void unregister_sysctl_table(struct ctl_table_header * table);
1096int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table);
1097 1085
1098extern int sysctl_init(void); 1086extern int sysctl_init(void);
1099#else /* CONFIG_SYSCTL */ 1087#else /* CONFIG_SYSCTL */
@@ -1118,10 +1106,6 @@ static inline void setup_sysctl_set(struct ctl_table_set *p,
1118{ 1106{
1119} 1107}
1120 1108
1121static inline void sysctl_head_put(struct ctl_table_header *head)
1122{
1123}
1124
1125#endif /* CONFIG_SYSCTL */ 1109#endif /* CONFIG_SYSCTL */
1126 1110
1127#endif /* __KERNEL__ */ 1111#endif /* __KERNEL__ */
diff --git a/kernel/Makefile b/kernel/Makefile
index 2d9de86b7e76..cb41b9547c9f 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -27,7 +27,6 @@ obj-y += power/
27 27
28obj-$(CONFIG_FREEZER) += freezer.o 28obj-$(CONFIG_FREEZER) += freezer.o
29obj-$(CONFIG_PROFILING) += profile.o 29obj-$(CONFIG_PROFILING) += profile.o
30obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
31obj-$(CONFIG_STACKTRACE) += stacktrace.o 30obj-$(CONFIG_STACKTRACE) += stacktrace.o
32obj-y += time/ 31obj-y += time/
33obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o 32obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ad460248acc7..b774909ed46c 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -192,20 +192,6 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
192 192
193#endif 193#endif
194 194
195static struct ctl_table root_table[1];
196static struct ctl_table_root sysctl_table_root;
197static struct ctl_table_header root_table_header = {
198 {{.count = 1,
199 .ctl_table = root_table,
200 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}},
201 .root = &sysctl_table_root,
202 .set = &sysctl_table_root.default_set,
203};
204static struct ctl_table_root sysctl_table_root = {
205 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
206 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
207};
208
209static struct ctl_table kern_table[]; 195static struct ctl_table kern_table[];
210static struct ctl_table vm_table[]; 196static struct ctl_table vm_table[];
211static struct ctl_table fs_table[]; 197static struct ctl_table fs_table[];
@@ -1559,459 +1545,12 @@ static struct ctl_table dev_table[] = {
1559 { } 1545 { }
1560}; 1546};
1561 1547
1562static DEFINE_SPINLOCK(sysctl_lock);
1563
1564/* called under sysctl_lock */
1565static int use_table(struct ctl_table_header *p)
1566{
1567 if (unlikely(p->unregistering))
1568 return 0;
1569 p->used++;
1570 return 1;
1571}
1572
1573/* called under sysctl_lock */
1574static void unuse_table(struct ctl_table_header *p)
1575{
1576 if (!--p->used)
1577 if (unlikely(p->unregistering))
1578 complete(p->unregistering);
1579}
1580
1581/* called under sysctl_lock, will reacquire if has to wait */
1582static void start_unregistering(struct ctl_table_header *p)
1583{
1584 /*
1585 * if p->used is 0, nobody will ever touch that entry again;
1586 * we'll eliminate all paths to it before dropping sysctl_lock
1587 */
1588 if (unlikely(p->used)) {
1589 struct completion wait;
1590 init_completion(&wait);
1591 p->unregistering = &wait;
1592 spin_unlock(&sysctl_lock);
1593 wait_for_completion(&wait);
1594 spin_lock(&sysctl_lock);
1595 } else {
1596 /* anything non-NULL; we'll never dereference it */
1597 p->unregistering = ERR_PTR(-EINVAL);
1598 }
1599 /*
1600 * do not remove from the list until nobody holds it; walking the
1601 * list in do_sysctl() relies on that.
1602 */
1603 list_del_init(&p->ctl_entry);
1604}
1605
1606void sysctl_head_get(struct ctl_table_header *head)
1607{
1608 spin_lock(&sysctl_lock);
1609 head->count++;
1610 spin_unlock(&sysctl_lock);
1611}
1612
1613void sysctl_head_put(struct ctl_table_header *head)
1614{
1615 spin_lock(&sysctl_lock);
1616 if (!--head->count)
1617 kfree_rcu(head, rcu);
1618 spin_unlock(&sysctl_lock);
1619}
1620
1621struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1622{
1623 if (!head)
1624 BUG();
1625 spin_lock(&sysctl_lock);
1626 if (!use_table(head))
1627 head = ERR_PTR(-ENOENT);
1628 spin_unlock(&sysctl_lock);
1629 return head;
1630}
1631
1632void sysctl_head_finish(struct ctl_table_header *head)
1633{
1634 if (!head)
1635 return;
1636 spin_lock(&sysctl_lock);
1637 unuse_table(head);
1638 spin_unlock(&sysctl_lock);
1639}
1640
1641static struct ctl_table_set *
1642lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1643{
1644 struct ctl_table_set *set = &root->default_set;
1645 if (root->lookup)
1646 set = root->lookup(root, namespaces);
1647 return set;
1648}
1649
1650static struct list_head *
1651lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1652{
1653 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1654 return &set->list;
1655}
1656
1657struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1658 struct ctl_table_header *prev)
1659{
1660 struct ctl_table_root *root;
1661 struct list_head *header_list;
1662 struct ctl_table_header *head;
1663 struct list_head *tmp;
1664
1665 spin_lock(&sysctl_lock);
1666 if (prev) {
1667 head = prev;
1668 tmp = &prev->ctl_entry;
1669 unuse_table(prev);
1670 goto next;
1671 }
1672 tmp = &root_table_header.ctl_entry;
1673 for (;;) {
1674 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1675
1676 if (!use_table(head))
1677 goto next;
1678 spin_unlock(&sysctl_lock);
1679 return head;
1680 next:
1681 root = head->root;
1682 tmp = tmp->next;
1683 header_list = lookup_header_list(root, namespaces);
1684 if (tmp != header_list)
1685 continue;
1686
1687 do {
1688 root = list_entry(root->root_list.next,
1689 struct ctl_table_root, root_list);
1690 if (root == &sysctl_table_root)
1691 goto out;
1692 header_list = lookup_header_list(root, namespaces);
1693 } while (list_empty(header_list));
1694 tmp = header_list->next;
1695 }
1696out:
1697 spin_unlock(&sysctl_lock);
1698 return NULL;
1699}
1700
1701struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1702{
1703 return __sysctl_head_next(current->nsproxy, prev);
1704}
1705
1706void register_sysctl_root(struct ctl_table_root *root)
1707{
1708 spin_lock(&sysctl_lock);
1709 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1710 spin_unlock(&sysctl_lock);
1711}
1712
1713/*
1714 * sysctl_perm does NOT grant the superuser all rights automatically, because
1715 * some sysctl variables are readonly even to root.
1716 */
1717
1718static int test_perm(int mode, int op)
1719{
1720 if (!current_euid())
1721 mode >>= 6;
1722 else if (in_egroup_p(0))
1723 mode >>= 3;
1724 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
1725 return 0;
1726 return -EACCES;
1727}
1728
1729int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
1730{
1731 int mode;
1732
1733 if (root->permissions)
1734 mode = root->permissions(root, current->nsproxy, table);
1735 else
1736 mode = table->mode;
1737
1738 return test_perm(mode, op);
1739}
1740
1741static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1742{
1743 for (; table->procname; table++) {
1744 table->parent = parent;
1745 if (table->child)
1746 sysctl_set_parent(table, table->child);
1747 }
1748}
1749
1750int __init sysctl_init(void) 1548int __init sysctl_init(void)
1751{ 1549{
1752 register_sysctl_table(sysctl_base_table); 1550 register_sysctl_table(sysctl_base_table);
1753 return 0; 1551 return 0;
1754} 1552}
1755 1553
1756static struct ctl_table *is_branch_in(struct ctl_table *branch,
1757 struct ctl_table *table)
1758{
1759 struct ctl_table *p;
1760 const char *s = branch->procname;
1761
1762 /* branch should have named subdirectory as its first element */
1763 if (!s || !branch->child)
1764 return NULL;
1765
1766 /* ... and nothing else */
1767 if (branch[1].procname)
1768 return NULL;
1769
1770 /* table should contain subdirectory with the same name */
1771 for (p = table; p->procname; p++) {
1772 if (!p->child)
1773 continue;
1774 if (p->procname && strcmp(p->procname, s) == 0)
1775 return p;
1776 }
1777 return NULL;
1778}
1779
1780/* see if attaching q to p would be an improvement */
1781static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1782{
1783 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1784 struct ctl_table *next;
1785 int is_better = 0;
1786 int not_in_parent = !p->attached_by;
1787
1788 while ((next = is_branch_in(by, to)) != NULL) {
1789 if (by == q->attached_by)
1790 is_better = 1;
1791 if (to == p->attached_by)
1792 not_in_parent = 1;
1793 by = by->child;
1794 to = next->child;
1795 }
1796
1797 if (is_better && not_in_parent) {
1798 q->attached_by = by;
1799 q->attached_to = to;
1800 q->parent = p;
1801 }
1802}
1803
1804/**
1805 * __register_sysctl_paths - register a sysctl hierarchy
1806 * @root: List of sysctl headers to register on
1807 * @namespaces: Data to compute which lists of sysctl entries are visible
1808 * @path: The path to the directory the sysctl table is in.
1809 * @table: the top-level table structure
1810 *
1811 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1812 * array. A completely 0 filled entry terminates the table.
1813 *
1814 * The members of the &struct ctl_table structure are used as follows:
1815 *
1816 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1817 * enter a sysctl file
1818 *
1819 * data - a pointer to data for use by proc_handler
1820 *
1821 * maxlen - the maximum size in bytes of the data
1822 *
1823 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1824 *
1825 * child - a pointer to the child sysctl table if this entry is a directory, or
1826 * %NULL.
1827 *
1828 * proc_handler - the text handler routine (described below)
1829 *
1830 * de - for internal use by the sysctl routines
1831 *
1832 * extra1, extra2 - extra pointers usable by the proc handler routines
1833 *
1834 * Leaf nodes in the sysctl tree will be represented by a single file
1835 * under /proc; non-leaf nodes will be represented by directories.
1836 *
1837 * sysctl(2) can automatically manage read and write requests through
1838 * the sysctl table. The data and maxlen fields of the ctl_table
1839 * struct enable minimal validation of the values being written to be
1840 * performed, and the mode field allows minimal authentication.
1841 *
1842 * There must be a proc_handler routine for any terminal nodes
1843 * mirrored under /proc/sys (non-terminals are handled by a built-in
1844 * directory handler). Several default handlers are available to
1845 * cover common cases -
1846 *
1847 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1848 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1849 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1850 *
1851 * It is the handler's job to read the input buffer from user memory
1852 * and process it. The handler should return 0 on success.
1853 *
1854 * This routine returns %NULL on a failure to register, and a pointer
1855 * to the table header on success.
1856 */
1857struct ctl_table_header *__register_sysctl_paths(
1858 struct ctl_table_root *root,
1859 struct nsproxy *namespaces,
1860 const struct ctl_path *path, struct ctl_table *table)
1861{
1862 struct ctl_table_header *header;
1863 struct ctl_table *new, **prevp;
1864 unsigned int n, npath;
1865 struct ctl_table_set *set;
1866
1867 /* Count the path components */
1868 for (npath = 0; path[npath].procname; ++npath)
1869 ;
1870
1871 /*
1872 * For each path component, allocate a 2-element ctl_table array.
1873 * The first array element will be filled with the sysctl entry
1874 * for this, the second will be the sentinel (procname == 0).
1875 *
1876 * We allocate everything in one go so that we don't have to
1877 * worry about freeing additional memory in unregister_sysctl_table.
1878 */
1879 header = kzalloc(sizeof(struct ctl_table_header) +
1880 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1881 if (!header)
1882 return NULL;
1883
1884 new = (struct ctl_table *) (header + 1);
1885
1886 /* Now connect the dots */
1887 prevp = &header->ctl_table;
1888 for (n = 0; n < npath; ++n, ++path) {
1889 /* Copy the procname */
1890 new->procname = path->procname;
1891 new->mode = 0555;
1892
1893 *prevp = new;
1894 prevp = &new->child;
1895
1896 new += 2;
1897 }
1898 *prevp = table;
1899 header->ctl_table_arg = table;
1900
1901 INIT_LIST_HEAD(&header->ctl_entry);
1902 header->used = 0;
1903 header->unregistering = NULL;
1904 header->root = root;
1905 sysctl_set_parent(NULL, header->ctl_table);
1906 header->count = 1;
1907#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1908 if (sysctl_check_table(namespaces, header->ctl_table)) {
1909 kfree(header);
1910 return NULL;
1911 }
1912#endif
1913 spin_lock(&sysctl_lock);
1914 header->set = lookup_header_set(root, namespaces);
1915 header->attached_by = header->ctl_table;
1916 header->attached_to = root_table;
1917 header->parent = &root_table_header;
1918 for (set = header->set; set; set = set->parent) {
1919 struct ctl_table_header *p;
1920 list_for_each_entry(p, &set->list, ctl_entry) {
1921 if (p->unregistering)
1922 continue;
1923 try_attach(p, header);
1924 }
1925 }
1926 header->parent->count++;
1927 list_add_tail(&header->ctl_entry, &header->set->list);
1928 spin_unlock(&sysctl_lock);
1929
1930 return header;
1931}
1932
1933/**
1934 * register_sysctl_table_path - register a sysctl table hierarchy
1935 * @path: The path to the directory the sysctl table is in.
1936 * @table: the top-level table structure
1937 *
1938 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1939 * array. A completely 0 filled entry terminates the table.
1940 *
1941 * See __register_sysctl_paths for more details.
1942 */
1943struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1944 struct ctl_table *table)
1945{
1946 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1947 path, table);
1948}
1949
1950/**
1951 * register_sysctl_table - register a sysctl table hierarchy
1952 * @table: the top-level table structure
1953 *
1954 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1955 * array. A completely 0 filled entry terminates the table.
1956 *
1957 * See register_sysctl_paths for more details.
1958 */
1959struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1960{
1961 static const struct ctl_path null_path[] = { {} };
1962
1963 return register_sysctl_paths(null_path, table);
1964}
1965
1966/**
1967 * unregister_sysctl_table - unregister a sysctl table hierarchy
1968 * @header: the header returned from register_sysctl_table
1969 *
1970 * Unregisters the sysctl table and all children. proc entries may not
1971 * actually be removed until they are no longer used by anyone.
1972 */
1973void unregister_sysctl_table(struct ctl_table_header * header)
1974{
1975 might_sleep();
1976
1977 if (header == NULL)
1978 return;
1979
1980 spin_lock(&sysctl_lock);
1981 start_unregistering(header);
1982 if (!--header->parent->count) {
1983 WARN_ON(1);
1984 kfree_rcu(header->parent, rcu);
1985 }
1986 if (!--header->count)
1987 kfree_rcu(header, rcu);
1988 spin_unlock(&sysctl_lock);
1989}
1990
1991int sysctl_is_seen(struct ctl_table_header *p)
1992{
1993 struct ctl_table_set *set = p->set;
1994 int res;
1995 spin_lock(&sysctl_lock);
1996 if (p->unregistering)
1997 res = 0;
1998 else if (!set->is_seen)
1999 res = 1;
2000 else
2001 res = set->is_seen(set);
2002 spin_unlock(&sysctl_lock);
2003 return res;
2004}
2005
2006void setup_sysctl_set(struct ctl_table_set *p,
2007 struct ctl_table_set *parent,
2008 int (*is_seen)(struct ctl_table_set *))
2009{
2010 INIT_LIST_HEAD(&p->list);
2011 p->parent = parent ? parent : &sysctl_table_root.default_set;
2012 p->is_seen = is_seen;
2013}
2014
2015#endif /* CONFIG_SYSCTL */ 1554#endif /* CONFIG_SYSCTL */
2016 1555
2017/* 1556/*
@@ -2977,6 +2516,3 @@ EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2977EXPORT_SYMBOL(proc_dostring); 2516EXPORT_SYMBOL(proc_dostring);
2978EXPORT_SYMBOL(proc_doulongvec_minmax); 2517EXPORT_SYMBOL(proc_doulongvec_minmax);
2979EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 2518EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2980EXPORT_SYMBOL(register_sysctl_table);
2981EXPORT_SYMBOL(register_sysctl_paths);
2982EXPORT_SYMBOL(unregister_sysctl_table);
diff --git a/kernel/sysctl_check.c b/kernel/sysctl_check.c
deleted file mode 100644
index 362da653813d..000000000000
--- a/kernel/sysctl_check.c
+++ /dev/null
@@ -1,160 +0,0 @@
1#include <linux/stat.h>
2#include <linux/sysctl.h>
3#include "../fs/xfs/xfs_sysctl.h"
4#include <linux/sunrpc/debug.h>
5#include <linux/string.h>
6#include <net/ip_vs.h>
7
8
9static int sysctl_depth(struct ctl_table *table)
10{
11 struct ctl_table *tmp;
12 int depth;
13
14 depth = 0;
15 for (tmp = table; tmp->parent; tmp = tmp->parent)
16 depth++;
17
18 return depth;
19}
20
21static struct ctl_table *sysctl_parent(struct ctl_table *table, int n)
22{
23 int i;
24
25 for (i = 0; table && i < n; i++)
26 table = table->parent;
27
28 return table;
29}
30
31
32static void sysctl_print_path(struct ctl_table *table)
33{
34 struct ctl_table *tmp;
35 int depth, i;
36 depth = sysctl_depth(table);
37 if (table->procname) {
38 for (i = depth; i >= 0; i--) {
39 tmp = sysctl_parent(table, i);
40 printk("/%s", tmp->procname?tmp->procname:"");
41 }
42 }
43 printk(" ");
44}
45
46static struct ctl_table *sysctl_check_lookup(struct nsproxy *namespaces,
47 struct ctl_table *table)
48{
49 struct ctl_table_header *head;
50 struct ctl_table *ref, *test;
51 int depth, cur_depth;
52
53 depth = sysctl_depth(table);
54
55 for (head = __sysctl_head_next(namespaces, NULL); head;
56 head = __sysctl_head_next(namespaces, head)) {
57 cur_depth = depth;
58 ref = head->ctl_table;
59repeat:
60 test = sysctl_parent(table, cur_depth);
61 for (; ref->procname; ref++) {
62 int match = 0;
63 if (cur_depth && !ref->child)
64 continue;
65
66 if (test->procname && ref->procname &&
67 (strcmp(test->procname, ref->procname) == 0))
68 match++;
69
70 if (match) {
71 if (cur_depth != 0) {
72 cur_depth--;
73 ref = ref->child;
74 goto repeat;
75 }
76 goto out;
77 }
78 }
79 }
80 ref = NULL;
81out:
82 sysctl_head_finish(head);
83 return ref;
84}
85
86static void set_fail(const char **fail, struct ctl_table *table, const char *str)
87{
88 if (*fail) {
89 printk(KERN_ERR "sysctl table check failed: ");
90 sysctl_print_path(table);
91 printk(" %s\n", *fail);
92 dump_stack();
93 }
94 *fail = str;
95}
96
97static void sysctl_check_leaf(struct nsproxy *namespaces,
98 struct ctl_table *table, const char **fail)
99{
100 struct ctl_table *ref;
101
102 ref = sysctl_check_lookup(namespaces, table);
103 if (ref && (ref != table))
104 set_fail(fail, table, "Sysctl already exists");
105}
106
107int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table)
108{
109 int error = 0;
110 for (; table->procname; table++) {
111 const char *fail = NULL;
112
113 if (table->parent) {
114 if (!table->parent->procname)
115 set_fail(&fail, table, "Parent without procname");
116 }
117 if (table->child) {
118 if (table->data)
119 set_fail(&fail, table, "Directory with data?");
120 if (table->maxlen)
121 set_fail(&fail, table, "Directory with maxlen?");
122 if ((table->mode & (S_IRUGO|S_IXUGO)) != table->mode)
123 set_fail(&fail, table, "Writable sysctl directory");
124 if (table->proc_handler)
125 set_fail(&fail, table, "Directory with proc_handler");
126 if (table->extra1)
127 set_fail(&fail, table, "Directory with extra1");
128 if (table->extra2)
129 set_fail(&fail, table, "Directory with extra2");
130 } else {
131 if ((table->proc_handler == proc_dostring) ||
132 (table->proc_handler == proc_dointvec) ||
133 (table->proc_handler == proc_dointvec_minmax) ||
134 (table->proc_handler == proc_dointvec_jiffies) ||
135 (table->proc_handler == proc_dointvec_userhz_jiffies) ||
136 (table->proc_handler == proc_dointvec_ms_jiffies) ||
137 (table->proc_handler == proc_doulongvec_minmax) ||
138 (table->proc_handler == proc_doulongvec_ms_jiffies_minmax)) {
139 if (!table->data)
140 set_fail(&fail, table, "No data");
141 if (!table->maxlen)
142 set_fail(&fail, table, "No maxlen");
143 }
144#ifdef CONFIG_PROC_SYSCTL
145 if (!table->proc_handler)
146 set_fail(&fail, table, "No proc_handler");
147#endif
148 sysctl_check_leaf(namespaces, table, &fail);
149 }
150 if (table->mode > 0777)
151 set_fail(&fail, table, "bogus .mode");
152 if (fail) {
153 set_fail(&fail, table, NULL);
154 error = -EINVAL;
155 }
156 if (table->child)
157 error |= sysctl_check_table(namespaces, table->child);
158 }
159 return error;
160}