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]
Date:	Thu, 03 Apr 2008 12:47:14 +0100
From:	James Courtier-Dutton <James@...erbug.co.uk>
To:	Andi Kleen <andi@...stfloor.org>
CC:	Tim Ricketts <tr@...th.li>, Michael Smith <msmith@...h.org>,
	linux-kernel@...r.kernel.org, Andy Wingo <wingo@...endo.com>,
	tglx@...utronix.de
Subject: Re: gettimeofday() jumping into the future


>> On Thu, 23 Aug 2007, Michael Smith wrote:
>>
>>     
> [...]
>   
>> +static inline u64 __get_nsec_offset(void)
>>   {
>>   	cycle_t cycle_now, cycle_delta;
>> -	s64 ns_offset;
>> +	u64 ns_offset;
>>
>>   	/* read clocksource: */
>>   	cycle_now = clocksource_read(clock);
>>
>> +	if (cycle_now < clock->cycle_last)
>> +		return 0;
>>     


That does not work as cycle_now can go backwards as well as wrap around.
The only way to catch all edge cases is to be able to make an assumption
on the maximum acceptable difference between cycle_now and cycle_last,
where difference is the shortest distance between values if they were
pointers into a ring buffer. If this maximum difference value is less
than half of the max value cycle_now can have, one can take a very
simple approach.
Treat the cycle_now, cycle_last value as signed.
If they have same sign, do the comparison as unsigned.
If they have different signs, do the comparision as signed.

James


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