lkml.org 
[lkml]   [2011]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH][RESEND] mm: Fix off-by-one bug in print_nodes_state
Hi David,

I'm so sorry for my late reply.

On Mon, Dec 19, 2011 at 7:44 AM, David Rientjes <rientjes@google.com> wrote:
> On Sun, 18 Dec 2011, Ryota Ozaki wrote:
>
>> /sys/devices/system/node/{online,possible} involve a garbage byte
>> because print_nodes_state returns content size + 1. To fix the bug,
>> the patch changes the use of cpuset_sprintf_cpulist to follow the
>> use at other places, which is clearer and safer.
>>
>
> It's not a garbage byte, sysdev files use a buffer created with
> get_zeroed_page(), so extra byte is guaranteed to be zero since
> nodelist_scnprintf() won't write to it.  So the issue here is that
> print_nodes_state() returns a size that is off by one according to

I see. It's certainly not a garbage but just a zero-cleared byte.

> ISO C99 although it won't cause a problem in practice.
>
>> This bug was introduced since v2.6.24.
>>
>
> It's not a bug, the result of a 4-node system would be "0-3\n\0" and
> returns 5 correctly.  You can verify this very simply with strace.

Of course I confirmed the trailing '\0'. I'm sure it's not critical issue
but it actually influences my script; I have to change from rstrip("\n")
to rstrip("\n\0") in python. Yes, it's pretty trivial but enough to get
rid of the extra for me :-)

Anyway the subject and the comment of my patch need to be fixed. I'll
send a revised one later.

Thanks.
ozaki-r
--
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: 2011-12-20 05:47    [W:0.053 / U:0.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site