aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-10-18 06:05:54 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-18 17:37:23 -0400
commitfc6cd25b738c2369d7ed3a6ef2ca248b51fcd2d4 (patch)
treebd3708eac72edf06097a8a2ed72c3a3fea0b0998 /kernel/sysctl.c
parentf429cd37a21b8efc825bdbb22db7f033564cbc98 (diff)
sysctl: Error on bad sysctl tables
After going through the kernels sysctl tables several times it has become clear that code review and testing is just not effective in prevent problematic sysctl tables from being used in the stable kernel. I certainly can't seem to fix the problems as fast as they are introduced. Therefore this patch adds sysctl_check_table which is called when a sysctl table is registered and checks to see if we have a problematic sysctl table. The biggest part of the code is the table of valid binary sysctl entries, but since we have frozen our set of binary sysctls this table should not need to change, and it makes it much easier to detect when someone unintentionally adds a new binary sysctl value. As best as I can determine all of the several hundred errors spewed on boot up now are legitimate. [bunk@kernel.org: kernel/sysctl_check.c must #include <linux/string.h>] Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Cc: Alexey Dobriyan <adobriyan@sw.ru> Signed-off-by: Adrian Bunk <bunk@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index c7150af631b5..62e53a0de4a3 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1461,7 +1461,9 @@ static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1461 1461
1462static __init int sysctl_init(void) 1462static __init int sysctl_init(void)
1463{ 1463{
1464 int err;
1464 sysctl_set_parent(NULL, root_table); 1465 sysctl_set_parent(NULL, root_table);
1466 err = sysctl_check_table(root_table);
1465 return 0; 1467 return 0;
1466} 1468}
1467 1469
@@ -1546,6 +1548,10 @@ struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1546 tmp->used = 0; 1548 tmp->used = 0;
1547 tmp->unregistering = NULL; 1549 tmp->unregistering = NULL;
1548 sysctl_set_parent(NULL, table); 1550 sysctl_set_parent(NULL, table);
1551 if (sysctl_check_table(tmp->ctl_table)) {
1552 kfree(tmp);
1553 return NULL;
1554 }
1549 spin_lock(&sysctl_lock); 1555 spin_lock(&sysctl_lock);
1550 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry); 1556 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1551 spin_unlock(&sysctl_lock); 1557 spin_unlock(&sysctl_lock);