]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.12-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 May 2025 15:19:50 +0000 (17:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 May 2025 15:19:50 +0000 (17:19 +0200)
added patches:
fix-mis-uses-of-cc-option-for-warning-disablement.patch
gcc-15-disable-wunterminated-string-initialization-entirely-for-now-a-commit-9d7a0577c9db35c4cc52db90bc415ea248446472-upstream.patch
gcc-15-make-unterminated-string-initialization-just-a-warning.patch
kbuild-properly-disable-wunterminated-string-initialization-for-clang.patch

queue-6.12/fix-mis-uses-of-cc-option-for-warning-disablement.patch [new file with mode: 0644]
queue-6.12/gcc-15-disable-wunterminated-string-initialization-entirely-for-now-a-commit-9d7a0577c9db35c4cc52db90bc415ea248446472-upstream.patch [new file with mode: 0644]
queue-6.12/gcc-15-make-unterminated-string-initialization-just-a-warning.patch [new file with mode: 0644]
queue-6.12/kbuild-properly-disable-wunterminated-string-initialization-for-clang.patch [new file with mode: 0644]
queue-6.12/series

diff --git a/queue-6.12/fix-mis-uses-of-cc-option-for-warning-disablement.patch b/queue-6.12/fix-mis-uses-of-cc-option-for-warning-disablement.patch
new file mode 100644 (file)
index 0000000..73a7621
--- /dev/null
@@ -0,0 +1,121 @@
+From ed91ac5bb04aa893ac0e53ea6dc274633527d039 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Wed, 23 Apr 2025 10:08:29 -0700
+Subject: Fix mis-uses of 'cc-option' for warning disablement
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit a79be02bba5c31f967885c7f3bf3a756d77d11d9 upstream.
+
+This was triggered by one of my mis-uses causing odd build warnings on
+sparc in linux-next, but while figuring out why the "obviously correct"
+use of cc-option caused such odd breakage, I found eight other cases of
+the same thing in the tree.
+
+The root cause is that 'cc-option' doesn't work for checking negative
+warning options (ie things like '-Wno-stringop-overflow') because gcc
+will silently accept options it doesn't recognize, and so 'cc-option'
+ends up thinking they are perfectly fine.
+
+And it all works, until you have a situation where _another_ warning is
+emitted.  At that point the compiler will go "Hmm, maybe the user
+intended to disable this warning but used that wrong option that I
+didn't recognize", and generate a warning for the unrecognized negative
+option.
+
+Which explains why we have several cases of this in the tree: the
+'cc-option' test really doesn't work for this situation, but most of the
+time it simply doesn't matter that ity doesn't work.
+
+The reason my recently added case caused problems on sparc was pointed
+out by Thomas Weißschuh: the sparc build had a previous explicit warning
+that then triggered the new one.
+
+I think the best fix for this would be to make 'cc-option' a bit smarter
+about this sitation, possibly by adding an intentional warning to the
+test case that then triggers the unrecognized option warning reliably.
+
+But the short-term fix is to replace 'cc-option' with an existing helper
+designed for this exact case: 'cc-disable-warning', which picks the
+negative warning but uses the positive form for testing the compiler
+support.
+
+Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
+Link: https://lore.kernel.org/all/20250422204718.0b4e3f81@canb.auug.org.au/
+Explained-by: Thomas Weißschuh <linux@weissschuh.net>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile                       |    4 ++--
+ arch/loongarch/kernel/Makefile |    8 ++++----
+ arch/loongarch/kvm/Makefile    |    2 +-
+ arch/riscv/kernel/Makefile     |    4 ++--
+ scripts/Makefile.extrawarn     |    2 +-
+ 5 files changed, 10 insertions(+), 10 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -998,11 +998,11 @@ NOSTDINC_FLAGS += -nostdinc
+ KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
+ #Currently, disable -Wstringop-overflow for GCC 11, globally.
+-KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
++KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-disable-warning, stringop-overflow)
+ KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
+ #Currently, disable -Wunterminated-string-initialization as broken
+-KBUILD_CFLAGS += $(call cc-option, -Wno-unterminated-string-initialization)
++KBUILD_CFLAGS += $(call cc-disable-warning, unterminated-string-initialization)
+ # disable invalid "can't wrap" optimizations for signed / pointers
+ KBUILD_CFLAGS += -fno-strict-overflow
+--- a/arch/loongarch/kernel/Makefile
++++ b/arch/loongarch/kernel/Makefile
+@@ -21,10 +21,10 @@ obj-$(CONFIG_CPU_HAS_LBT)  += lbt.o
+ obj-$(CONFIG_ARCH_STRICT_ALIGN)       += unaligned.o
+-CFLAGS_module.o               += $(call cc-option,-Wno-override-init,)
+-CFLAGS_syscall.o      += $(call cc-option,-Wno-override-init,)
+-CFLAGS_traps.o                += $(call cc-option,-Wno-override-init,)
+-CFLAGS_perf_event.o   += $(call cc-option,-Wno-override-init,)
++CFLAGS_module.o               += $(call cc-disable-warning, override-init)
++CFLAGS_syscall.o      += $(call cc-disable-warning, override-init)
++CFLAGS_traps.o                += $(call cc-disable-warning, override-init)
++CFLAGS_perf_event.o   += $(call cc-disable-warning, override-init)
+ ifdef CONFIG_FUNCTION_TRACER
+   ifndef CONFIG_DYNAMIC_FTRACE
+--- a/arch/loongarch/kvm/Makefile
++++ b/arch/loongarch/kvm/Makefile
+@@ -19,4 +19,4 @@ kvm-y += tlb.o
+ kvm-y += vcpu.o
+ kvm-y += vm.o
+-CFLAGS_exit.o += $(call cc-option,-Wno-override-init,)
++CFLAGS_exit.o += $(call cc-disable-warning, override-init)
+--- a/arch/riscv/kernel/Makefile
++++ b/arch/riscv/kernel/Makefile
+@@ -9,8 +9,8 @@ CFLAGS_REMOVE_patch.o  = $(CC_FLAGS_FTRAC
+ CFLAGS_REMOVE_sbi.o   = $(CC_FLAGS_FTRACE)
+ CFLAGS_REMOVE_return_address.o        = $(CC_FLAGS_FTRACE)
+ endif
+-CFLAGS_syscall_table.o        += $(call cc-option,-Wno-override-init,)
+-CFLAGS_compat_syscall_table.o += $(call cc-option,-Wno-override-init,)
++CFLAGS_syscall_table.o        += $(call cc-disable-warning, override-init)
++CFLAGS_compat_syscall_table.o += $(call cc-disable-warning, override-init)
+ ifdef CONFIG_KEXEC_CORE
+ AFLAGS_kexec_relocate.o := -mcmodel=medany $(call cc-option,-mno-relax)
+--- a/scripts/Makefile.extrawarn
++++ b/scripts/Makefile.extrawarn
+@@ -15,7 +15,7 @@ KBUILD_CFLAGS += -Werror=return-type
+ KBUILD_CFLAGS += -Werror=strict-prototypes
+ KBUILD_CFLAGS += -Wno-format-security
+ KBUILD_CFLAGS += -Wno-trigraphs
+-KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
++KBUILD_CFLAGS += $(call cc-disable-warning, frame-address)
+ KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
+ KBUILD_CFLAGS += -Wmissing-declarations
+ KBUILD_CFLAGS += -Wmissing-prototypes
diff --git a/queue-6.12/gcc-15-disable-wunterminated-string-initialization-entirely-for-now-a-commit-9d7a0577c9db35c4cc52db90bc415ea248446472-upstream.patch b/queue-6.12/gcc-15-disable-wunterminated-string-initialization-entirely-for-now-a-commit-9d7a0577c9db35c4cc52db90bc415ea248446472-upstream.patch
new file mode 100644 (file)
index 0000000..9efd9a4
--- /dev/null
@@ -0,0 +1,80 @@
+From 50c02d93990e94bc6bacc1ce71e7895b40316b5a Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Sun, 20 Apr 2025 15:30:53 -0700
+Subject: gcc-15: disable '-Wunterminated-string-initialization' entirely for now
+
+commit 9d7a0577c9db35c4cc52db90bc415ea248446472 upstream.
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+I had left the warning around but as a non-fatal error to get my gcc-15
+builds going, but fixed up some of the most annoying warning cases so
+that it wouldn't be *too* verbose.
+
+Because I like the _concept_ of the warning, even if I detested the
+implementation to shut it up.
+
+It turns out the implementation to shut it up is even more broken than I
+thought, and my "shut up most of the warnings" patch just caused fatal
+errors on gcc-14 instead.
+
+I had tested with clang, but when I upgrade my development environment,
+I try to do it on all machines because I hate having different systems
+to maintain, and hadn't realized that gcc-14 now had issues.
+
+The ACPI case is literally why I wanted to have a *type* that doesn't
+trigger the warning (see commit d5d45a7f2619: "gcc-15: make
+'unterminated string initialization' just a warning"), instead of
+marking individual places as "__nonstring".
+
+But gcc-14 doesn't like that __nonstring location that shut gcc-15 up,
+because it's on an array of char arrays, not on one single array:
+
+  drivers/acpi/tables.c:399:1: error: 'nonstring' attribute ignored on objects of type 'const char[][4]' [-Werror=attributes]
+    399 | static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst __nonstring = {
+        | ^~~~~~
+
+and my attempts to nest it properly with a type had failed, because of
+how gcc doesn't like marking the types as having attributes, only
+symbols.
+
+There may be some trick to it, but I was already annoyed by the bad
+attribute design, now I'm just entirely fed up with it.
+
+I wish gcc had a proper way to say "this type is a *byte* array, not a
+string".
+
+The obvious thing would be to distinguish between "char []" and an
+explicitly signed "unsigned char []" (as opposed to an implicitly
+unsigned char, which is typically an architecture-specific default, but
+for the kernel is universal thanks to '-funsigned-char').
+
+But any "we can typedef a 8-bit type to not become a string just because
+it's an array" model would be fine.
+
+But "__attribute__((nonstring))" is sadly not that sane model.
+
+Reported-by: Chris Clayton <chris2553@googlemail.com>
+Fixes: 4b4bd8c50f48 ("gcc-15: acpi: sprinkle random '__nonstring' crumbles around")
+Fixes: d5d45a7f2619 ("gcc-15: make 'unterminated string initialization' just a warning")
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+[nathan: drivers/acpi diff dropped due to lack of 4b4bd8c50f48 in stable]
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -1001,8 +1001,8 @@ KBUILD_CFLAGS += $(call cc-option, -fstr
+ KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
+ KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
+-#Currently, disable -Wunterminated-string-initialization as an error
+-KBUILD_CFLAGS += $(call cc-option, -Wno-error=unterminated-string-initialization)
++#Currently, disable -Wunterminated-string-initialization as broken
++KBUILD_CFLAGS += $(call cc-option, -Wno-unterminated-string-initialization)
+ # disable invalid "can't wrap" optimizations for signed / pointers
+ KBUILD_CFLAGS += -fno-strict-overflow
diff --git a/queue-6.12/gcc-15-make-unterminated-string-initialization-just-a-warning.patch b/queue-6.12/gcc-15-make-unterminated-string-initialization-just-a-warning.patch
new file mode 100644 (file)
index 0000000..e1c8033
--- /dev/null
@@ -0,0 +1,83 @@
+From 796e12921f3e4c298de97d5ad9775e052faa5eb6 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Sun, 20 Apr 2025 10:33:23 -0700
+Subject: gcc-15: make 'unterminated string initialization' just a warning
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit d5d45a7f26194460964eb5677a9226697f7b7fdd upstream.
+
+gcc-15 enabling -Wunterminated-string-initialization in -Wextra by
+default was done with the best intentions, but the warning is still
+quite broken.
+
+What annoys me about the warning is that this is a very traditional AND
+CORRECT way to initialize fixed byte arrays in C:
+
+       unsigned char hex[16] = "0123456789abcdef";
+
+and we use this all over the kernel.  And the warning is fine, but gcc
+developers apparently never made a reasonable way to disable it.  As is
+(sadly) tradition with these things.
+
+Yes, there's "__attribute__((nonstring))", and we have a macro to make
+that absolutely disgusting syntax more palatable (ie the kernel syntax
+for that monstrosity is just "__nonstring").
+
+But that attribute is misdesigned.  What you'd typically want to do is
+tell the compiler that you are using a type that isn't a string but a
+byte array, but that doesn't work at all:
+
+       warning: ‘nonstring’ attribute does not apply to types [-Wattributes]
+
+and because of this fundamental mis-design, you then have to mark each
+instance of that pattern.
+
+This is particularly noticeable in our ACPI code, because ACPI has this
+notion of a 4-byte "type name" that gets used all over, and is exactly
+this kind of byte array.
+
+This is a sad oversight, because the warning is useful, but really would
+be so much better if gcc had also given a sane way to indicate that we
+really just want a byte array type at a type level, not the broken "each
+and every array definition" level.
+
+So now instead of creating a nice "ACPI name" type using something like
+
+       typedef char acpi_name_t[4] __nonstring;
+
+we have to do things like
+
+       char name[ACPI_NAMESEG_SIZE] __nonstring;
+
+in every place that uses this concept and then happens to have the
+typical initializers.
+
+This is annoying me mainly because I think the warning _is_ a good
+warning, which is why I'm not just turning it off in disgust.  But it is
+hampered by this bad implementation detail.
+
+[ And obviously I'm doing this now because system upgrades for me are
+  something that happen in the middle of the release cycle: don't do it
+  before or during travel, or just before or during the busy merge
+  window period. ]
+
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -1001,6 +1001,9 @@ KBUILD_CFLAGS += $(call cc-option, -fstr
+ KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
+ KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
++#Currently, disable -Wunterminated-string-initialization as an error
++KBUILD_CFLAGS += $(call cc-option, -Wno-error=unterminated-string-initialization)
++
+ # disable invalid "can't wrap" optimizations for signed / pointers
+ KBUILD_CFLAGS += -fno-strict-overflow
diff --git a/queue-6.12/kbuild-properly-disable-wunterminated-string-initialization-for-clang.patch b/queue-6.12/kbuild-properly-disable-wunterminated-string-initialization-for-clang.patch
new file mode 100644 (file)
index 0000000..2e59ffb
--- /dev/null
@@ -0,0 +1,101 @@
+From 8ca4ef650ff1b1fd0f52985d81a0f4bd806bedf9 Mon Sep 17 00:00:00 2001
+From: Nathan Chancellor <nathan@kernel.org>
+Date: Wed, 30 Apr 2025 15:56:34 -0700
+Subject: kbuild: Properly disable -Wunterminated-string-initialization for clang
+
+From: Nathan Chancellor <nathan@kernel.org>
+
+commit 4f79eaa2ceac86a0e0f304b0bab556cca5bf4f30 upstream.
+
+Clang and GCC have different behaviors around disabling warnings
+included in -Wall and -Wextra and the order in which flags are
+specified, which is exposed by clang's new support for
+-Wunterminated-string-initialization.
+
+  $ cat test.c
+  const char foo[3] = "FOO";
+  const char bar[3] __attribute__((__nonstring__)) = "BAR";
+
+  $ clang -fsyntax-only -Wextra test.c
+  test.c:1:21: warning: initializer-string for character array is too long, array size is 3 but initializer has size 4 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Wunterminated-string-initialization]
+      1 | const char foo[3] = "FOO";
+        |                     ^~~~~
+  $ clang -fsyntax-only -Wextra -Wno-unterminated-string-initialization test.c
+  $ clang -fsyntax-only -Wno-unterminated-string-initialization -Wextra test.c
+  test.c:1:21: warning: initializer-string for character array is too long, array size is 3 but initializer has size 4 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Wunterminated-string-initialization]
+      1 | const char foo[3] = "FOO";
+        |                     ^~~~~
+
+  $ gcc -fsyntax-only -Wextra test.c
+  test.c:1:21: warning: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (4 chars into 3 available) [-Wunterminated-string-initialization]
+      1 | const char foo[3] = "FOO";
+        |                     ^~~~~
+  $ gcc -fsyntax-only -Wextra -Wno-unterminated-string-initialization test.c
+  $ gcc -fsyntax-only -Wno-unterminated-string-initialization -Wextra test.c
+
+Move -Wextra up right below -Wall in Makefile.extrawarn to ensure these
+flags are at the beginning of the warning options list. Move the couple
+of warning options that have been added to the main Makefile since
+commit e88ca24319e4 ("kbuild: consolidate warning flags in
+scripts/Makefile.extrawarn") to scripts/Makefile.extrawarn after -Wall /
+-Wextra to ensure they get properly disabled for all compilers.
+
+Fixes: 9d7a0577c9db ("gcc-15: disable '-Wunterminated-string-initialization' entirely for now")
+Link: https://github.com/llvm/llvm-project/issues/10359
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile                   |    7 -------
+ scripts/Makefile.extrawarn |    9 ++++++++-
+ 2 files changed, 8 insertions(+), 8 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -997,13 +997,6 @@ NOSTDINC_FLAGS += -nostdinc
+ # perform bounds checking.
+ KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
+-#Currently, disable -Wstringop-overflow for GCC 11, globally.
+-KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-disable-warning, stringop-overflow)
+-KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
+-
+-#Currently, disable -Wunterminated-string-initialization as broken
+-KBUILD_CFLAGS += $(call cc-disable-warning, unterminated-string-initialization)
+-
+ # disable invalid "can't wrap" optimizations for signed / pointers
+ KBUILD_CFLAGS += -fno-strict-overflow
+--- a/scripts/Makefile.extrawarn
++++ b/scripts/Makefile.extrawarn
+@@ -8,6 +8,7 @@
+ # Default set of warnings, always enabled
+ KBUILD_CFLAGS += -Wall
++KBUILD_CFLAGS += -Wextra
+ KBUILD_CFLAGS += -Wundef
+ KBUILD_CFLAGS += -Werror=implicit-function-declaration
+ KBUILD_CFLAGS += -Werror=implicit-int
+@@ -68,6 +69,13 @@ KBUILD_CFLAGS += -Wno-pointer-sign
+ # globally built with -Wcast-function-type.
+ KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
++# Currently, disable -Wstringop-overflow for GCC 11, globally.
++KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-disable-warning, stringop-overflow)
++KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
++
++# Currently, disable -Wunterminated-string-initialization as broken
++KBUILD_CFLAGS += $(call cc-disable-warning, unterminated-string-initialization)
++
+ # The allocators already balk at large sizes, so silence the compiler
+ # warnings for bounds checks involving those possible values. While
+ # -Wno-alloc-size-larger-than would normally be used here, earlier versions
+@@ -97,7 +105,6 @@ KBUILD_CFLAGS += $(call cc-option,-Wenum
+ # Explicitly clear padding bits during variable initialization
+ KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
+-KBUILD_CFLAGS += -Wextra
+ KBUILD_CFLAGS += -Wunused
+ #
index 3a9c131b2ec82117e7259d1caf4d01f59bafb2ba..f79301cee1a7cbc6d19238827c5d09819a4fb12a 100644 (file)
@@ -613,3 +613,7 @@ spi-spi-fsl-dspi-restrict-register-range-for-regmap-.patch
 spi-spi-fsl-dspi-halt-the-module-after-a-new-message.patch
 spi-spi-fsl-dspi-reset-sr-flags-before-sending-a-new.patch
 err.h-move-iomem_err_ptr-to-err.h.patch
+gcc-15-make-unterminated-string-initialization-just-a-warning.patch
+gcc-15-disable-wunterminated-string-initialization-entirely-for-now-a-commit-9d7a0577c9db35c4cc52db90bc415ea248446472-upstream.patch
+fix-mis-uses-of-cc-option-for-warning-disablement.patch
+kbuild-properly-disable-wunterminated-string-initialization-for-clang.patch