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]
Date: Fri, 3 May 2024 22:08:40 -0700
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Boqun Feng <boqun.feng@...il.com>, Marco Elver <elver@...gle.com>,
	Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Dmitry Vyukov <dvyukov@...gle.com>,
	syzbot <syzbot+b7c3ba8cdc2f6cf83c21@...kaller.appspotmail.com>,
	linux-kernel@...r.kernel.org, syzkaller-bugs@...glegroups.com,
	Nathan Chancellor <nathan@...nel.org>,
	Arnd Bergmann <arnd@...nel.org>, Al Viro <viro@...iv.linux.org.uk>,
	Jiri Slaby <jirislaby@...nel.org>
Subject: Re: [PATCH v3] tty: tty_io: remove hung_up_tty_fops

On Fri, May 03, 2024 at 05:14:22PM -0700, Linus Torvalds wrote:
> On Fri, 3 May 2024 at 16:59, Paul E. McKenney <paulmck@...nel.org> wrote:
> >
> > Hmmm...  Maybe something like this very lightly tested patch?
> 
> I'm a bit nervous about using the built-in atomics, when it's not
> clear what the compiler will do on various architectures.
> 
> Gcc documentation talks about __atomic_is_lock_free(), which makes me
> think that on various architectures it might end up doing some "fall
> back to helper functions" cases (possibly for odd architectures).

Right now, both GCC and Clang complain if you give __atomic_load_n()
something other than a pointer or a sufficiently small scalar on x86.

Let's see, starting with READ_ONCE()...

ARM7-a Clang complains about even single bytes (ARM7-a GCC is
fine).

ARMv8 works like x86 for both GCC and Clang, 

AVR GCC and M68K Clang generate calls to helper functions, so they
need to implement {READ,WRITE}_ONCE_MERGEABLE() in terms of the
current {READ,WRITE}_ONCE() macros.

M68K GCC works like x86, but generates a call to a helper function
for an 8-byte load.  Which means that the 8-byte case needs to
generate a build error.

Hexagon Clang works like x86.

Loongarch GCC works like x86.  Ditto S390, sh, and xtensa GCC.

MIPS Clang works like x86, but throws a build error for long long,
which might be OK given 32-bit.  MIPS GCC handles long long also.

MIPS64 and MIPS EL GCC and Clang work like x86, as do both compilers
for POWERPC and POWERPC LE.  And for RISC-V 32 and 64 bit.

I based these on this godbolt:  https://godbolt.org/z/rrKnnE8nb
The #ifs on lines select the 8-byte and structure case, respectively,
and you can pick your compiler.  I just used the latest versions
of each compiler for each architecture, so there might well be
a few more surprises.

> IOW: I don't think the patch is wrong, but I do think we need to
> verify that all compilers we support generate the obvious code for
> this, and we don't have some "fall back to function calls".

You are right, this is going to need some arch-specific code for a few
of the architectures.  Hey, I was hoping!!!

The compilers do not currently optimize these things, but things appear
to me to be heading in that direction.

						Thanx, Paul

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ