lkml.org 
[lkml]   [1999]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: Serious bug in recent Linux kernels

On Sun, 10 Jan 1999, Guest section DW wrote:

> From owner-linux-kernel-outgoing@vger.rutgers.edu Sat Jan 9 10:32:53 1999
>
> There is a serious bug in recent kernels with the timeout of the poll()
> system call. The calculation to turn the timeout value from milliseconds
>
> Hmm - yesterday I complained that you should have been more precise
> with this `recent kernels', but I happened to come along this code in
> select.c for some other reason. It must not produce a negative timeout.
> The change below makes sure of that.

There is still a problem for values of timeout a little larger than
((unsigned long)-1 / HZ). eg. for HZ==100, a timeout of 42949673 gets
turned into a timeout of 2.

better is something like

if ((unsigned long)timeout > (unsigned long)-999 / HZ)
timeout = MAX_SCHEDULE_TIMEOUT;
else if (timeout)
timeout = (timeout*HZ+999)/1000+1;

>
> --- ../../../linux-2.2.0pre6/linux/fs/select.c Sun Nov 22 19:08:50 1998
> +++ select.c Sun Jan 10 08:15:04 1999
> @@ -331,10 +331,10 @@
> if (nfds > NR_OPEN)
> goto out;
>
> + if (timeout > 0)
> + timeout = (timeout*HZ+999)/1000+1;
> if (timeout < 0)
> timeout = MAX_SCHEDULE_TIMEOUT;
> - else if (timeout)
> - timeout = (timeout*HZ+999)/1000+1;
>
> err = -ENOMEM;
> if (timeout) {


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

\
 
 \ /
  Last update: 2005-03-22 13:49    [W:0.039 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site