Messages in this thread | | | From | Greg Smart <> | Subject | RE: Serious bug in recent Linux kernels | Date | Tue, 12 Jan 1999 09:30:38 +1100 |
| |
hello, I'm not too sure about the use of this bit of code, but if the problem is overflow (i.e. timeout*HZ > 31 bits) then the problem could be fixed by throwing away a couple of bits of resolution (which doesn't really happen in practice) by using the following line.
timeout = (timeout*(HZ/4)+249)/250 + 1;
cheers Greg Smart
> -----Original Message----- > From: Linus Torvalds [SMTP:torvalds@transmeta.com] > Sent: Monday, January 11, 1999 5:33 PM > To: Alan Modra > Cc: Guest section DW; Jes.Sorensen@cern.ch; > linux-kernel@vger.rutgers.edu; jongk@cs.utwente.nl > Subject: Re: Serious bug in recent Linux kernels > > > > On Mon, 11 Jan 1999, Alan Modra wrote: > > > > 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; > > Heh. Even this is incorrect, but it's _really_ close to being right. > > The problem is that you're doing a signed division with 1000 if I'm not > mistaken, and thus even if "timeout*HZ+999" doesn't overflow in 32 bits, > it's enough that it oevrflows in 31.. > > Making the 1000 be "1000UL" should fix it. But I'm too lazy to test. > > Linus > > > - > 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/
- 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/
| |