lkml.org 
[lkml]   [1999]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Serious bug in recent Linux kernels
Guest section DW schrieb:
> ... must not produce a negative timeout. The change below makes sure of that ...
>
> + 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;
>
> [the expression (timeout*HZ+999)/1000+1 is also a bit peculiar,
> but I have not changed it]

timeout*HZ can overflow and produce a bad positive result for
some values of timeout, I think. Assuming timeout is
a long (I don't have the source handy), how about
if ((timeout < 0) || (timeout > LONG_MAX/HZ))
timeout = MAX_SCHEDULE_TIMEOUT;
else if (timeout > 0)
timeout = (timeout*HZ+999)/1000+1;
?
- Dan

--
Speaking only for myself, not for my employer

-
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.033 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site