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: <553B8DA9.3060600@surriel.com>
Date:	Sat, 25 Apr 2015 08:50:49 -0400
From:	Rik van Riel <riel@...riel.com>
To:	Heiko Carstens <heiko.carstens@...ibm.com>
CC:	linux-kernel@...r.kernel.org,
	Andy Lutomirsky <amluto@...capital.com>,
	Frederic Weisbecker <fweisbec@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>, williams@...hat.com
Subject: Re: [PATCH v2] context_tracking: remove local_irq_save from __acct_update_integrals

On 04/25/2015 05:43 AM, Heiko Carstens wrote:
> On Fri, Apr 24, 2015 at 11:16:53AM -0400, Rik van Riel wrote:
>> V2: introduce signed_cputime_t to deal with 64 bit cputime_t on
>>     32 bit architectures, and use READ_ONCE to ensure the value
>>     is always read atomically (Heiko Karstens)
> 
> Erm, that's not what I said ;)
> READ_ONCE() only fixes the isssue that with your previous code the
> compiler was free to generate code that accesses the memory value
> several times.

Ah indeed, you are right.

>> -		local_irq_save(flags);
>>  		time = stime + utime;
>> -		dtime = time - tsk->acct_timexpd;
>> +		dtime = time - READ_ONCE(tsk->acct_timexpd);
>> +		/*
>> +		 * This code is called both from irq context and from
>> +		 * task context. There is a race where irq context advances
>> +		 * tsk->acct_timexpd to a value larger than time, creating
>> +		 * a negative value. In that case, the irq has already
>> +		 * updated the statistics.
>> +		 */
>> +		if (unlikely((signed_cputime_t)dtime <= 0))
>> +			return;
>> +
> 
> ...the READ_ONCE() doesn't give you any guarantees about reading
> tsk->acct_timexpd in an atomic way.
> Well, actually you don't need atomic semantics, but only to make sure that
> the read access happens with a single instruction, since you want to protect
> against interrupts.
> But still: if the size of acct_timexpd is 64 bit READ_ONCE() may still result
> in two instructions on 32 bit architectures.
> (or isn't there currently no 32 bit architecture with 64 bit cputime_t left?)

Even if there is (maybe some ARM system?), can we even guarantee
that a single instruction to read 64 bits exists on such a system?

-- 
All rights reversed.
--
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