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: <20160609121603.GB30935@twins.programming.kicks-ass.net>
Date:	Thu, 9 Jun 2016 14:16:03 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Minfei Huang <mnghuan@...il.com>
Cc:	bp@...e.de, pbonzini@...hat.com, luto@...nel.org, hpa@...or.com,
	mingo@...hat.com, tglx@...utronix.de, x86@...nel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3 V2] pvclock: Get rid of __pvclock_read_cycles in
 function pvclock_read_flags

On Sat, May 28, 2016 at 08:27:43PM +0800, Minfei Huang wrote:
> +++ b/arch/x86/kernel/pvclock.c
> @@ -61,11 +61,14 @@ void pvclock_resume(void)
>  u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
>  {
>  	unsigned version;
> -	cycle_t ret;
>  	u8 flags;
>  
>  	do {
> -		version = __pvclock_read_cycles(src, &ret, &flags);
> +		version = src->version;
> +		/* Make the latest version visible */
> +		smp_rmb();
> +
> +		flags = src->flags;

Using a seqcount to load a single byte is insane ;-)

>  		/* Make sure that the version double-check is last. */
>  		smp_rmb();
>  	} while ((src->version & 1) || version != src->version);


What's wrong with:

	u8 flags = READ_ONCE(src->flags);

?

(and have the flags store be done using WRITE_ONCE() of course).

Sure, if your total state is larger than one word you need the
seqcount for integrity, but reading _one_ byte, shees.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ