Thread (9 messages) 9 messages, 5 authors, 2020-08-18

Re: [PATCH 1/4] Makefile: add -fno-builtin-stpcpy

flat view

From: Greg KH <gregkh@linuxfoundation.org>
Date: 2020-08-18 07:33:47
Also in: linux-kbuild, lkml

On Tue, Aug 18, 2020 at 09:29:39AM +0200, Ard Biesheuvel wrote:
On Tue, 18 Aug 2020 at 09:25, Greg KH [off-list ref] wrote:
quoted
On Tue, Aug 18, 2020 at 09:10:01AM +0200, Ard Biesheuvel wrote:
quoted
On Tue, 18 Aug 2020 at 00:02, Nick Desaulniers [off-list ref] wrote:
quoted
LLVM implemented a recent "libcall optimization" that lowers calls to
`sprintf(dest, "%s", str)` where the return value is used to
`stpcpy(dest, str) - dest`. This generally avoids the machinery involved
in parsing format strings. This optimization was introduced into
clang-12. Because the kernel does not provide an implementation of
stpcpy, we observe linkage failures for almost all targets when building
with ToT clang.

The interface is unsafe as it does not perform any bounds checking.
Disable this "libcall optimization" via `-fno-builtin-stpcpy`.

Unlike
commit 5f074f3e192f ("lib/string.c: implement a basic bcmp")
which cited failures with `-fno-builtin-*` flags being retained in LLVM
LTO, that bug seems to have been fixed by
https://reviews.llvm.org/D71193, so the above sha can now be reverted in
favor of `-fno-builtin-bcmp`.

Cc: stable@vger.kernel.org # 4.4
Why does a fix for Clang-12 have to be backported all the way to v4.4?
How does that meet the requirements for stable patches?
Because people like to build older kernels with new compliler versions.

And those "people" include me, who doesn't want to keep around old
compilers just because my distro moved to the latest one...

We've been doing this for the past 4+ years, for new versions of gcc,
keeping 4.4.y building properly with the bleeding edge of that compiler,
why is clang any different here?
Fair enough. I am just struggling to match stable-kernel-rules.rst
with the actual practices - perhaps it is time to update that
document?
The rules are tiny and simple for 99% of the issues involved.  Stuff
like "add patches to fix build failures and warnings for newer compiler
versions" are so rare (they only happen every 2 years or so), it's not
worth it.

thanks,

greg k-h
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help