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: <6762443004f96d279cba77b7c412163769c930fe.camel@synopsys.com>
Date:   Mon, 9 Jul 2018 14:30:41 +0000
From:   Alexey Brodkin <Alexey.Brodkin@...opsys.com>
To:     "peterz@...radead.org" <peterz@...radead.org>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "rostedt@...dmis.org" <rostedt@...dmis.org>,
        "josh@...htriplett.org" <josh@...htriplett.org>,
        "linux@...linux.org.uk" <linux@...linux.org.uk>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "dvhart@...radead.org" <dvhart@...radead.org>,
        "linux-snps-arc@...ts.infradead.org" 
        <linux-snps-arc@...ts.infradead.org>,
        "paulmck@...ux.vnet.ibm.com" <paulmck@...ux.vnet.ibm.com>,
        "will.deacon@....com" <will.deacon@....com>,
        "boqun.feng@...il.com" <boqun.feng@...il.com>,
        "jiangshanlai@...il.com" <jiangshanlai@...il.com>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "David.Laight@...LAB.COM" <David.Laight@...LAB.COM>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "shuah@...nel.org" <shuah@...nel.org>,
        "arnd@...db.de" <arnd@...db.de>,
        "linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
        "geert@...ux-m68k.org" <geert@...ux-m68k.org>,
        "mathieu.desnoyers@...icios.com" <mathieu.desnoyers@...icios.com>
Subject: Re: [PATCH] atomic{64}_t: Explicitly specify data storage length
 and alignment

Hi Peter,

On Mon, 2018-07-09 at 15:35 +0200, Peter Zijlstra wrote:
> On Mon, Jul 09, 2018 at 03:47:41PM +0300, Alexey Brodkin wrote:
> > diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
> > index 8d28eb010d0d..b94b749b5952 100644
> > --- a/include/asm-generic/atomic64.h
> > +++ b/include/asm-generic/atomic64.h
> > @@ -13,7 +13,7 @@
> >  #define _ASM_GENERIC_ATOMIC64_H
> >  
> >  typedef struct {
> > -	long long counter;
> > +	u64 __aligned(8) counter;
> >  } atomic64_t;
> 
> The type is wrong, atomic is signed, the alignment also really doesn't
> matter, generic atomic64 is utter crap.

Hm, any thoughts on why it's "u64" for 32-bit x86?
See https://elixir.bootlin.com/linux/latest/source/arch/x86/include/asm/atomic64_32.h#L12
------------------------->8-----------------------
/* An 64bit atomic type */

typedef struct {
	u64 __aligned(8) counter;
} atomic64_t;
------------------------->8-----------------------

> >  #define ATOMIC64_INIT(i)	{ (i) }
> > diff --git a/include/linux/types.h b/include/linux/types.h
> > index 9834e90aa010..e2f631782621 100644
> > --- a/include/linux/types.h
> > +++ b/include/linux/types.h
> > @@ -174,12 +174,12 @@ typedef phys_addr_t resource_size_t;
> >  typedef unsigned long irq_hw_number_t;
> >  
> >  typedef struct {
> > -	int counter;
> > +	u32 __aligned(4) counter;
> >  } atomic_t;
> 
> u32 is wrong, the atomic type is signed.
> 
> Also, if an architecture doesn't properly align its native machine word
> size but requires alignment for atomics it's a broken architecture.

Ok we may not touch 32-bit atomics as there's a hope most of arches
properly align native machine words.

> >  
> >  #ifdef CONFIG_64BIT
> >  typedef struct {
> > -	long counter;
> > +	u64 __aligned(8) counter;
> >  } atomic64_t;
> >  #endif
> >  
> 
> Similar for this one, on 64bit archs that support atomics the native
> 64bit types (long included) had better already imply this alignment.

Ok agree.

-Alexey

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ