Thread (2 messages) flat view 2 messages, 2 authors, 2011-02-04

Re: [PATCH 1/6] sysctl: faster reimplementation of sysctl_check_table

From: Lucian Adrian Grijincu <hidden>
Date: 2011-02-04 21:34:37
Also in: lkml

On Fri, Feb 4, 2011 at 11:11 PM, Eric W. Biederman
[off-list ref] wrote:
quoted
+static int __sysctl_check_table(struct nsproxy *namespaces,
+     struct ctl_table *table, struct ctl_table **parents, int depth)
 {
+     const char *fail = NULL;
      int error = 0;
+
+     if (depth >= CTL_MAXNAME) {
This should be depth > CTL_MAXNAME.  Because there are only CTL_MAXNAME
entries in the array.

A bit lower in the array we access 'parents[depth]'.
So the correct check should be (depth >= CTL_MAXNAME) => error.

quoted
-                     sysctl_check_leaf(namespaces, table, &fail);
+                     parents[depth] = table;
+                     sysctl_check_leaf(namespaces, table, &fail,
+                                       parents, depth);
              }
quoted
+             if (table->child) {
+                     parents[depth] = table;
+                     error |= __sysctl_check_table(namespaces, table->child,
+                                                   parents, depth + 1);
+             }


-- 
 .
..: Lucian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help