lkml.org 
[lkml]   [2007]   [Jan]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: bug reading /proc/sys/kernel/*: only first byte read.
On 01/30, Oleg Nesterov wrote:
>
> On 01/30, Andrew Morton wrote:
> >
> > + if (len + pos < maxlen) {
> ^^^^^^^^^^^^^^^^^^^^^^^
> Shouldn't this be
> if (len < *lenp)
>
> ?

On the other hand. If we may assume that original code was correct,
we can make a simpler patch?

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 6.19/kernel/sysctl.c~ 2006-11-17 19:42:31.000000000 +0300
+++ 6.19/kernel/sysctl.c 2007-01-30 16:46:00.000000000 +0300
@@ -1683,13 +1683,12 @@ static int _proc_do_string(void* data, i
size_t len;
char __user *p;
char c;
-
- if (!data || !maxlen || !*lenp ||
- (*ppos && !write)) {
+
+ if (!data || !maxlen || !*lenp) {
*lenp = 0;
return 0;
}
-
+
if (write) {
len = 0;
p = buffer;
@@ -1710,6 +1709,15 @@ static int _proc_do_string(void* data, i
len = strlen(data);
if (len > maxlen)
len = maxlen;
+
+ if (*ppos > len) {
+ *lenp = 0;
+ return 0;
+ }
+
+ data += *ppos;
+ len -= *ppos;
+
if (len > *lenp)
len = *lenp;
if (len)
-
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: 2007-01-30 15:01    [from the cache]
©2003-2011 Jasper Spaans