Re: [PATCH] poll(2) timeout values

From: Peter Staubach
Date: Fri Nov 11 2005 - 08:17:33 EST


Alan Cox wrote:

On Iau, 2005-11-10 at 16:49 -0800, Ulrich Drepper wrote:


On 11/10/05, Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> wrote:


No. The poll POSIX libc call takes an int. What the kernel ones does
with the top bits is irrelevant to applications.


The issue is that if the high bits are not handled special then
somebody might cause problems. E.g., overflowing the division or so. Therefore the kernel has to sanitize the argument and then why not use
the easiest way to do this?



Why does the kernel have to sanitize the input. Last time I checked
undefined inputs gave undefined outputs in the standards. fopen(NULL,
NULL) seems to crash glibc for example.

The kernel has to behave correctly given valid sensible inputs. Masking
the top bits is not behaving correctly

"sleep ages"
"no I'll sleep a short time"

Surely it would be far better to do

if((timeout >> 31) >> 1) return -EINVAL;

for 64bit systems


Given that the current, sole purpose of sys_poll() is to implement the poll(2)
system call, and that currently, that system call takes a 32 bit signed integer
third argument, then it seems safe to me to just ignore the top 32 bits. They
can be either masked off explicitly or implicitly via the use of a 32 bit
signed integer.

Is there a problem with making this change other than it is a change? Is
there a risk of something breaking?

Thanx...

ps
-
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/