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: <CAHk-=whrP0CLrx_7-A_3bZgyS4ihVYiuh817Vk-3xa6jG3sVLA@mail.gmail.com>
Date: Sun, 6 Apr 2025 12:31:49 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Kees Cook <kees@...nel.org>
Cc: linux-kernel@...r.kernel.org, Andrey Konovalov <andreyknvl@...il.com>, 
	Andy Shevchenko <andy@...nel.org>, Catalin Marinas <catalin.marinas@....com>, 
	Nathan Chancellor <nathan@...nel.org>, Peter Collingbourne <pcc@...gle.com>, 
	Vincenzo Frascino <vincenzo.frascino@....com>, Will Deacon <will@...nel.org>
Subject: Re: [GIT PULL] string fixes for v6.15-rc1

On Sun, 6 Apr 2025 at 12:04, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> When the function implementation is the stupid version, there is *no*
> advantage to a function call.

Side note: the reason we don't do -freestanding is that some functions
we really *really* want the compiler to optimize away the function
entirely.

Things like regular 'strlen()' are commonly used on compile-time fixed
strings. It needs to be dealt with by the compiler.

Same goes for the basic memcpy and memset functions.

So what the kernel really wants is basically "-freestanding" but with
a very targeted set of functions still dealt with by the compiler -
not ever because they should be turned into function calls, but
because they can be simplified to some entirely different form at
compile time.

(There are a _couple_ of other cases, but not many: we end up having
things like "constant prefix matching" patterns, where we want the
compiler to not only notice that 'strlen()' on a constant string is
just a compile-time constant value, but then also want to simplify
'strncmp()' or 'memcmp()' with a small constant size to basically be a
much simpler thing)

But we do not want the compiler to create out-of-line function calls
for code that wasn't a function call to begin with.  That's pretty
much the exact *opposite* of what we actually want.

We did try "-freestanding" at some point, because it's the obvious way
to avoid the compiler messing this very basic thing up, but those
"just deal with simple cases directly" are really really important.

I wish there was a version of -freestanding that did that "only
simplify calls" version, not the "recognize patterns and turn them
into calls that didn't exist".

            Linus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ