lkml.org 
[lkml]   [2012]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] sysctl: fix improper indication of integer sysctl parameter
David Howells <dhowells@redhat.com> writes:

> Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com> wrote:
>
>> When we read the sysctl parameter, they are always treated
>> as signed integer, and are casted into unsigned long type
>> in the current kernel. If we set a value equivalent to
>> (the maximum value in signed integer + 1)
>
> Wouldn't it be better to return EINVAL or EDOM?

Yes we should definitely fail the write in the case where we write an
unsigned value and we can not fit that value in an integer.

There will still remain the bug of reading the integer
where (-val == val) && val < 0. In that case we do want to an
(unsigned int) before storing it in an unsinged long.

The decription of the patch is confusing.

The problem is not the cast to unsigned long, the problem is
the implicit cast to signed long which happens before the cast
to unsigned long. I think this is a case where C's casting rules
get it wrong. If I have an explicit cast why add an implicit
cast to do sign extension. Sigh.

Mitsuo since you are looking at this do you think you could fix the
write side of the problem as well, and check to make cetain the
unsigned value we write will fit in an interger.

Eric


\
 
 \ /
  Last update: 2012-07-31 17:21    [W:0.628 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site