[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wijG2dSOOFr8CCYygwxZQxdTUj73rfB8=tyZP-3G-8-og@mail.gmail.com>
Date: Sun, 6 Apr 2025 19:04:29 -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 18:33, Kees Cook <kees@...nel.org> wrote:
>
> I should have said "libcall optimizations". It's not just blindly constructing calls.
But it's *WRONG*.
It's stupid. It's not an optimization, it makes things worse.
> This is the same kind of thing that has been heavily discussed before for bcmp() and stpcpy()
And it makes a bit more sense at least for stpcpy(), because the
implementation there is basically "strlen+memcpy". Both of which we
want the compiler to work on - even if we're not interested in it ever
using stpcpy().
IOF, for stpcpy, there's at least a *reason* for the compiler to do it.
For something like wcslen() the answer is "DON'T DO THIS". Because
there is absolutely zero upside to trying to recognize this pattern,
and there is real downside.
See?
Don't work around the compiler doing stupid things. Fix the compiler
options to tell the compiler to "Don'tDoThatThen(tm)".
Linus
Powered by blists - more mailing lists