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: <0cca6df4-ec77-40d4-8714-b46a18cc6a82@paulmck-laptop>
Date: Wed, 26 Feb 2025 16:35:18 -0800
From: "Paul E. McKenney" <paulmck@...nel.org>
To: David Laight <david.laight.linux@...il.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
	Martin Uecker <uecker@...raz.at>, Ralf Jung <post@...fj.de>,
	Alice Ryhl <aliceryhl@...gle.com>,
	Ventura Jack <venturajack85@...il.com>,
	Kent Overstreet <kent.overstreet@...ux.dev>,
	Gary Guo <gary@...yguo.net>, airlied@...il.com,
	boqun.feng@...il.com, ej@...i.de, gregkh@...uxfoundation.org,
	hch@...radead.org, hpa@...or.com, ksummit@...ts.linux.dev,
	linux-kernel@...r.kernel.org, miguel.ojeda.sandonis@...il.com,
	rust-for-linux@...r.kernel.org
Subject: Re: C aggregate passing (Rust kernel policy)

On Wed, Feb 26, 2025 at 10:54:12PM +0000, David Laight wrote:
> On Wed, 26 Feb 2025 13:21:41 -0800
> Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> 
> > On Wed, 26 Feb 2025 at 13:14, Linus Torvalds
> > <torvalds@...ux-foundation.org> wrote:
> > >
> > > That "single read done as multiple reads" is sadly still accepted by
> > > the C standard, as far as I can tell. Because the standard still
> > > considers it "unobservable" unless I've missed some update.  
> > 
> > I want to clarify that I'm talking about perfectly normal and entirely
> > unannotated variable accesses.
> > 
> > Don't say "programmers should annotate their special accesses with
> > volatile if they want to avoid compiler-introduced TOCTOU issues".
> > 
> > Having humans have to work around failures in the language is not the way to go.
> > 
> > Particularly when there isn't even any advantage to it. I'm pretty
> > sure neither clang nor gcc actually rematerialize reads from memory,
> 
> I thought some of the very early READ_ONCE() were added because there
> was an actual problem with the generated code.
> But it has got entirely silly.
> In many cases gcc will generate an extra register-register transfer
> for a volatile read - I've seen it do a byte read, register move and
> then and with 0xff.
> I think adding a separate memory barrier would stop the read being
> rematerialized - but you also need to stop it doing (for example)
> two byte accesses for a 16bit variable - arm32 has a limited offset
> for 16bit memory accesses, so the compiler might be tempted to do
> two byte writes.

Perhaps some day GCC __atomic_load_n(__ATOMIC_RELAXED) will do what we
want for READ_ONCE().  Not holding my breath, though.  ;-)

							Thanx, Paul

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ