Re: [PATCH] fs/pipe: fix shift by 64 in F_SETPIPE_SZ

From: Vegard Nossum
Date: Mon Aug 15 2016 - 04:56:08 EST


On 08/15/2016 10:34 AM, Willy Tarreau wrote:
On Mon, Aug 15, 2016 at 10:22:38AM +0200, Vegard Nossum wrote:
In both cases I found it better to be more conservative in what we
accept, i.e. I haven't checked whether the rest of the code would
support pipe buffers > INT_MAX on 64-bit and I think it's a slightly
bigger job to check that (not just for the person making the change, but
for everybody else looking at/reviewing it) -- it's already tricky
enough to verify that this change by itself is safe and correct IMHO.

Well in fact in my opinion it's the opposite, because if we ensure the
function works well over all its argument type's range, the caller has
less trouble figuring what sub-part of the range is OK. This is exactly
the current issue where you have to ensure that :

unsigned int arg <= INT_MAX

It's not just about this one function, but all the other code in pipe.c
now has to cope with pipe buffers > INT_MAX as well.

For example all the fields in struct pipe_inode_info referring to
buffers are unsigned int (nrbufs, curbuf, buffers). Unless we also
change those to unsigned long, the code will definitely not support
buffer sizes up to LONG_MAX on 64-bit.

That's why I think it's a much, much bigger task to review (and make)
such a change.


Vegard