]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[PATCH] Fix false old value return of sysctl
authorYi Yang <yang.y.yi@gmail.com>
Fri, 30 Dec 2005 08:37:10 +0000 (16:37 +0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sat, 31 Dec 2005 01:22:08 +0000 (17:22 -0800)
For the sysctl syscall, if the user wants to get the old value of a
sysctl entry and set a new value for it in the same syscall, the old
value is always overwritten by the new value if the sysctl entry is of
string type and if the user sets its strategy to sysctl_string.  This
issue lies in the strategy being run twice if the strategy is set to
sysctl_string, the general strategy sysctl_string always returns 0 if
success.

Such strategy routines as sysctl_jiffies and sysctl_jiffies_ms return 1
because they do read and write for the sysctl entry.

The strategy routine sysctl_string return 0 although it actually read
and write the sysctl entry.

According to my analysis, if a strategy routine do read and write, it
should return 1, if it just does some necessary check but not read and
write, it should return 0, for example sysctl_intvec.

Signed-off-by: Yi Yang <yang.y.yi@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
kernel/sysctl.c

index ad0425a8f7099d27ee46e95b833897eb2d4dc475..e5102ea6e1042764b6357ef9630f42df4ef8782d 100644 (file)
@@ -2221,7 +2221,7 @@ int sysctl_string(ctl_table *table, int __user *name, int nlen,
                        len--;
                ((char *) table->data)[len] = 0;
        }
-       return 0;
+       return 1;
 }
 
 /*