diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 7bb5cb6..026681f 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -1018,7 +1018,9 @@ struct ctl_table int maxlen; mode_t mode; struct ctl_table *child; +#ifdef CONFIG_SYSCTL_SYSCALL_CHECK struct ctl_table *parent; /* Automatically set */ +#endif proc_handler *proc_handler; /* Callback for text formatting */ void *extra1; void *extra2; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index ae5cbb1..c5bade1 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1706,6 +1706,7 @@ int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) return test_perm(mode, op); } +#ifdef CONFIG_SYSCTL_SYSCALL_CHECK static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) { for (; table->procname; table++) { @@ -1714,11 +1715,13 @@ static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) sysctl_set_parent(table, table->child); } } +#endif + static __init int sysctl_init(void) { - sysctl_set_parent(NULL, root_table); #ifdef CONFIG_SYSCTL_SYSCALL_CHECK + sysctl_set_parent(NULL, root_table); sysctl_check_table(current->nsproxy, root_table); #endif return 0; @@ -1875,9 +1878,9 @@ struct ctl_table_header *__register_sysctl_paths( header->used = 0; header->unregistering = NULL; header->root = root; - sysctl_set_parent(NULL, header->ctl_table); header->count = 1; #ifdef CONFIG_SYSCTL_SYSCALL_CHECK + sysctl_set_parent(NULL, header->ctl_table); if (sysctl_check_table(namespaces, header->ctl_table)) { kfree(header); return NULL;