lkml.org 
[lkml]   [2005]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] sysctl_string() return 1 on success.
From
Date
Hello,

I think sysctl_string() should return 1 on success.
I verified that variables (for example, modprobe_path[]
and hotplug_path[]) that use sysctl_string() for strategy
function are NOT '\0'-terminated if newlen > sizeof(variables).

I also think ctl_perm() should be called before
calling table->strategy, for strategy function may do
read/write operations.

Best Regards.

---------- START OF PATCH ----------
--- linux-2.6.13.4/kernel/sysctl.c 2005-10-11 03:54:29.000000000 +0900
+++ linux-2.6.13.4-sysctl/kernel/sysctl.c 2005-10-21 15:33:26.000000000 +0900
@@ -16,6 +16,8 @@
* Wendling.
* The list_for_each() macro wasn't appropriate for the sysctl loop.
* Removed it and replaced it with older style, 03/23/00, Bill Wendling
+ * sysctl_string() return 1 on success, 10/21/05, Tetsuo Handa
+ * Added ctl_perm() check for non-leaf nodes, 10/21/05, Tetsuo Handa
*/

#include <linux/config.h>
@@ -1088,6 +1090,12 @@
if (ctl_perm(table, 001))
return -EPERM;
if (table->strategy) {
+ /* Need to check permission, for
+ table->strategy() might do r/w */
+ int op = 0;
+ if (oldval) op |= 004;
+ if (newval) op |= 002;
+ if (ctl_perm(table, op)) return -EPERM;
error = table->strategy(
table, name, nlen,
oldval, oldlenp,
@@ -2146,7 +2154,7 @@
len--;
((char *) table->data)[len] = 0;
}
- return 0;
+ return 1;
}

/*
---------- END OF PATCH ----------
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-10-21 14:32    [W:0.076 / U:0.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site