lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.00.0902041412420.3247@localhost.localdomain>
Date:	Wed, 4 Feb 2009 14:16:23 -0800 (PST)
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Ingo Molnar <mingo@...e.hu>
cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [git pull] timer fix



On Wed, 4 Feb 2009, Linus Torvalds wrote:
> 
> Either cast the result of the subtract to "s32" (or "int", whatever), or 
> cast _both_ of them to (s32) so that the subtract is done in a signed 
> type, and then the expansion to (long) will still be right - but 
> unnecessary - in the sign.

Btw, doing it with a nice helper macro or function is also perhaps a good 
idea, at least if these "compare hpet values" things happen more than 
once. 

Look at "time_after()" in <linux/jiffies.h> to see how to do these kinds 
of "comparisons of things that may overflow" really carefully. You 
absolutely need to do the compare in a size that is no larger than the 
size of the actual values (and in the case of HPET, it's 32-bit, at least 
the way we do things now - I guess HPET's _could_ be 64-bit, but we don't 
read more than 32 bits or whatever).

So <linux/jiffies.h> does the cast to "(long)", but it does so because the 
incoming values really have type "unsigned long" and are valid in all 
bits.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ