Re: bug reading /proc/sys/kernel/*: only first byte read.

From: Eric W. Biederman
Date: Tue Jan 30 2007 - 10:09:26 EST


Oleg Nesterov <oleg@xxxxxxxxxx> writes:

> 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?

I think there is an issue worth fixing her.

However as far as I can tell the code has this limitation
deliberately for simplicity.

Getting the string side of this fixed even by itself is
worthwhile, although it might be worth teach people
about sys_uname and /bin/uname. It seems is the biggest thing
people look at /proc/sys/ for...

For the non-string data the only way we can do this is to
generate it into a temporary buffer and the read out the
part of the buffer the user is requesting. Isn't there
something in seq_file that will do this?

On the other side I'm fairly certain we can't support
short writes to magic sysctl files on the write side of things.

I do have to say I like Oleg short version of this patch.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/