diff options
-rw-r--r-- | fs/proc/proc_sysctl.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index e0d3e7e59cbd..160d5781638e 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -52,6 +52,7 @@ static int sysctl_follow_link(struct ctl_table_header **phead, | |||
52 | struct ctl_table **pentry, struct nsproxy *namespaces); | 52 | struct ctl_table **pentry, struct nsproxy *namespaces); |
53 | static int insert_links(struct ctl_table_header *head); | 53 | static int insert_links(struct ctl_table_header *head); |
54 | static void put_links(struct ctl_table_header *header); | 54 | static void put_links(struct ctl_table_header *header); |
55 | static int sysctl_check_dups(struct ctl_dir *dir, struct ctl_table *table); | ||
55 | 56 | ||
56 | static void sysctl_print_dir(struct ctl_dir *dir) | 57 | static void sysctl_print_dir(struct ctl_dir *dir) |
57 | { | 58 | { |
@@ -123,6 +124,10 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) | |||
123 | { | 124 | { |
124 | int err; | 125 | int err; |
125 | 126 | ||
127 | err = sysctl_check_dups(dir, header->ctl_table); | ||
128 | if (err) | ||
129 | return err; | ||
130 | |||
126 | dir->header.nreg++; | 131 | dir->header.nreg++; |
127 | header->parent = dir; | 132 | header->parent = dir; |
128 | err = insert_links(header); | 133 | err = insert_links(header); |
@@ -891,7 +896,7 @@ static int sysctl_follow_link(struct ctl_table_header **phead, | |||
891 | return ret; | 896 | return ret; |
892 | } | 897 | } |
893 | 898 | ||
894 | static int sysctl_check_table_dups(const char *path, struct ctl_table *old, | 899 | static int sysctl_check_table_dups(struct ctl_dir *dir, struct ctl_table *old, |
895 | struct ctl_table *table) | 900 | struct ctl_table *table) |
896 | { | 901 | { |
897 | struct ctl_table *entry, *test; | 902 | struct ctl_table *entry, *test; |
@@ -900,8 +905,9 @@ static int sysctl_check_table_dups(const char *path, struct ctl_table *old, | |||
900 | for (entry = old; entry->procname; entry++) { | 905 | for (entry = old; entry->procname; entry++) { |
901 | for (test = table; test->procname; test++) { | 906 | for (test = table; test->procname; test++) { |
902 | if (strcmp(entry->procname, test->procname) == 0) { | 907 | if (strcmp(entry->procname, test->procname) == 0) { |
903 | printk(KERN_ERR "sysctl duplicate entry: %s/%s\n", | 908 | printk(KERN_ERR "sysctl duplicate entry: "); |
904 | path, test->procname); | 909 | sysctl_print_dir(dir); |
910 | printk(KERN_CONT "/%s\n", test->procname); | ||
905 | error = -EEXIST; | 911 | error = -EEXIST; |
906 | } | 912 | } |
907 | } | 913 | } |
@@ -909,8 +915,7 @@ static int sysctl_check_table_dups(const char *path, struct ctl_table *old, | |||
909 | return error; | 915 | return error; |
910 | } | 916 | } |
911 | 917 | ||
912 | static int sysctl_check_dups(struct ctl_dir *dir, | 918 | static int sysctl_check_dups(struct ctl_dir *dir, struct ctl_table *table) |
913 | const char *path, struct ctl_table *table) | ||
914 | { | 919 | { |
915 | struct ctl_table_set *set; | 920 | struct ctl_table_set *set; |
916 | struct ctl_table_header *head; | 921 | struct ctl_table_header *head; |
@@ -922,7 +927,7 @@ static int sysctl_check_dups(struct ctl_dir *dir, | |||
922 | continue; | 927 | continue; |
923 | if (head->parent != dir) | 928 | if (head->parent != dir) |
924 | continue; | 929 | continue; |
925 | error = sysctl_check_table_dups(path, head->ctl_table, table); | 930 | error = sysctl_check_table_dups(dir, head->ctl_table, table); |
926 | } | 931 | } |
927 | return error; | 932 | return error; |
928 | } | 933 | } |
@@ -1166,9 +1171,6 @@ struct ctl_table_header *__register_sysctl_table( | |||
1166 | } | 1171 | } |
1167 | 1172 | ||
1168 | spin_lock(&sysctl_lock); | 1173 | spin_lock(&sysctl_lock); |
1169 | if (sysctl_check_dups(dir, path, table)) | ||
1170 | goto fail_put_dir_locked; | ||
1171 | |||
1172 | if (insert_header(dir, header)) | 1174 | if (insert_header(dir, header)) |
1173 | goto fail_put_dir_locked; | 1175 | goto fail_put_dir_locked; |
1174 | 1176 | ||