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: <20140227185306.GN30003@mudshark.cambridge.arm.com>
Date:	Thu, 27 Feb 2014 18:53:07 +0000
From:	Will Deacon <will.deacon@....com>
To:	Davidlohr Bueso <davidlohr@...com>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"rkuo@...eaurora.org" <rkuo@...eaurora.org>,
	"arnd@...db.de" <arnd@...db.de>,
	"paulus@...ba.org" <paulus@...ba.org>
Subject: Re: [PATCH 1/2] asm-generic: rwsem: ensure sem->cnt is only accessed
 via atomic_long_*

On Thu, Feb 27, 2014 at 05:28:24AM +0000, Davidlohr Bueso wrote:
> On Fri, 2014-02-21 at 17:22 +0000, Will Deacon wrote:
> > The asm-generic rwsem implementation directly acceses sem->cnt when
> > performing a __down_read_trylock operation. Whilst this is probably safe
> > on all architectures, we should stick to the atomic_long_* API and use
> > atomic_long_read instead.
> > 
> > Signed-off-by: Will Deacon <will.deacon@....com>
> > ---
> >  include/asm-generic/rwsem.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/asm-generic/rwsem.h b/include/asm-generic/rwsem.h
> > index bb1e2cdeb9bf..75af612f54f8 100644
> > --- a/include/asm-generic/rwsem.h
> > +++ b/include/asm-generic/rwsem.h
> > @@ -41,7 +41,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
> >  {
> >  	long tmp;
> >  
> > -	while ((tmp = sem->count) >= 0) {
> > +	while ((tmp = atomic_long_read((atomic_long_t *)&sem->count)) >= 0) {
> 
> That's pretty ugly, how about having infinite look and just do the tmp
> assign separately from the conditional?
> 
> It also looks like a cpu_relax() could help here between iterations.

Sure, I can do these in a separate patch (this patch is just a simple fix).

> Reviewed-by: Davidlohr Bueso <davidlohr@...com>

Thanks,

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