lockd: Add helper to sanity check incoming NOTIFY requests
[safe/jmp/linux-2.6] / kernel / sysctl.c
index 911d846..4588b2c 100644 (file)
@@ -97,7 +97,7 @@ static int sixty = 60;
 static int neg_one = -1;
 #endif
 
-#ifdef CONFIG_MMU
+#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING)
 static int two = 2;
 #endif
 
@@ -159,6 +159,7 @@ static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *
 static struct ctl_table root_table[];
 static struct ctl_table_root sysctl_table_root;
 static struct ctl_table_header root_table_header = {
+       .count = 1,
        .ctl_table = root_table,
        .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
        .root = &sysctl_table_root,
@@ -1260,6 +1261,7 @@ static struct ctl_table fs_table[] = {
                .extra1         = &minolduid,
                .extra2         = &maxolduid,
        },
+#ifdef CONFIG_FILE_LOCKING
        {
                .ctl_name       = FS_LEASES,
                .procname       = "leases-enable",
@@ -1268,6 +1270,7 @@ static struct ctl_table fs_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec,
        },
+#endif
 #ifdef CONFIG_DNOTIFY
        {
                .ctl_name       = FS_DIR_NOTIFY,
@@ -1279,6 +1282,7 @@ static struct ctl_table fs_table[] = {
        },
 #endif
 #ifdef CONFIG_MMU
+#ifdef CONFIG_FILE_LOCKING
        {
                .ctl_name       = FS_LEASE_TIME,
                .procname       = "lease-break-time",
@@ -1290,6 +1294,7 @@ static struct ctl_table fs_table[] = {
                .extra1         = &zero,
                .extra2         = &two,
        },
+#endif
        {
                .procname       = "aio-nr",
                .data           = &aio_nr,
@@ -1680,43 +1685,45 @@ static __init int sysctl_init(void)
 
 core_initcall(sysctl_init);
 
-static int is_branch_in(struct ctl_table *branch, struct ctl_table *table)
+static struct ctl_table *is_branch_in(struct ctl_table *branch,
+                                     struct ctl_table *table)
 {
        struct ctl_table *p;
        const char *s = branch->procname;
 
        /* branch should have named subdirectory as its first element */
        if (!s || !branch->child)
-               return 0;
+               return NULL;
 
        /* ... and nothing else */
        if (branch[1].procname || branch[1].ctl_name)
-               return 0;
+               return NULL;
 
        /* table should contain subdirectory with the same name */
        for (p = table; p->procname || p->ctl_name; p++) {
                if (!p->child)
                        continue;
                if (p->procname && strcmp(p->procname, s) == 0)
-                       return 1;
+                       return p;
        }
-       return 0;
+       return NULL;
 }
 
 /* see if attaching q to p would be an improvement */
 static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
 {
        struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
+       struct ctl_table *next;
        int is_better = 0;
        int not_in_parent = !p->attached_by;
 
-       while (is_branch_in(by, to)) {
+       while ((next = is_branch_in(by, to)) != NULL) {
                if (by == q->attached_by)
                        is_better = 1;
                if (to == p->attached_by)
                        not_in_parent = 1;
                by = by->child;
-               to = to->child;
+               to = next->child;
        }
 
        if (is_better && not_in_parent) {