]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.1-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 22 Jan 2023 14:24:40 +0000 (15:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 22 Jan 2023 14:24:40 +0000 (15:24 +0100)
added patches:
arch-fix-broken-buildid-for-arm64-and-riscv.patch
x86-fpu-use-_alignof-to-avoid-undefined-behavior-in-type_align.patch

queue-6.1/arch-fix-broken-buildid-for-arm64-and-riscv.patch [new file with mode: 0644]
queue-6.1/series
queue-6.1/x86-fpu-use-_alignof-to-avoid-undefined-behavior-in-type_align.patch [new file with mode: 0644]

diff --git a/queue-6.1/arch-fix-broken-buildid-for-arm64-and-riscv.patch b/queue-6.1/arch-fix-broken-buildid-for-arm64-and-riscv.patch
new file mode 100644 (file)
index 0000000..e961381
--- /dev/null
@@ -0,0 +1,55 @@
+From 99cb0d917ffa1ab628bb67364ca9b162c07699b1 Mon Sep 17 00:00:00 2001
+From: Masahiro Yamada <masahiroy@kernel.org>
+Date: Tue, 27 Dec 2022 03:45:37 +0900
+Subject: arch: fix broken BuildID for arm64 and riscv
+
+From: Masahiro Yamada <masahiroy@kernel.org>
+
+commit 99cb0d917ffa1ab628bb67364ca9b162c07699b1 upstream.
+
+Dennis Gilmore reports that the BuildID is missing in the arm64 vmlinux
+since commit 994b7ac1697b ("arm64: remove special treatment for the
+link order of head.o").
+
+The issue is that the type of .notes section, which contains the BuildID,
+changed from NOTES to PROGBITS.
+
+Ard Biesheuvel figured out that whichever object gets linked first gets
+to decide the type of a section. The PROGBITS type is the result of the
+compiler emitting .note.GNU-stack as PROGBITS rather than NOTE.
+
+While Ard provided a fix for arm64, I want to fix this globally because
+the same issue is happening on riscv since commit 2348e6bf4421 ("riscv:
+remove special treatment for the link order of head.o"). This problem
+will happen in general for other architectures if they start to drop
+unneeded entries from scripts/head-object-list.txt.
+
+Discard .note.GNU-stack in include/asm-generic/vmlinux.lds.h.
+
+Link: https://lore.kernel.org/lkml/CAABkxwuQoz1CTbyb57n0ZX65eSYiTonFCU8-LCQc=74D=xE=rA@mail.gmail.com/
+Fixes: 994b7ac1697b ("arm64: remove special treatment for the link order of head.o")
+Fixes: 2348e6bf4421 ("riscv: remove special treatment for the link order of head.o")
+Reported-by: Dennis Gilmore <dennis@ausil.us>
+Suggested-by: Ard Biesheuvel <ardb@kernel.org>
+Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
+Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/asm-generic/vmlinux.lds.h |    5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/include/asm-generic/vmlinux.lds.h
++++ b/include/asm-generic/vmlinux.lds.h
+@@ -929,7 +929,12 @@
+ #define PRINTK_INDEX
+ #endif
++/*
++ * Discard .note.GNU-stack, which is emitted as PROGBITS by the compiler.
++ * Otherwise, the type of .notes section would become PROGBITS instead of NOTES.
++ */
+ #define NOTES                                                         \
++      /DISCARD/ : { *(.note.GNU-stack) }                              \
+       .notes : AT(ADDR(.notes) - LOAD_OFFSET) {                       \
+               __start_notes = .;                                      \
+               KEEP(*(.note.*))                                        \
index fcd6d95ddd7fa5ba87e4de67df90975d6a5c3331..dc7814ce36c40cb552cf10f262dac5d95521e820 100644 (file)
@@ -156,3 +156,5 @@ panic-introduce-warn_limit.patch
 panic-expose-warn_count-to-sysfs.patch
 docs-fix-path-paste-o-for-sys-kernel-warn_count.patch
 exit-use-read_once-for-all-oops-warn-limit-reads.patch
+x86-fpu-use-_alignof-to-avoid-undefined-behavior-in-type_align.patch
+arch-fix-broken-buildid-for-arm64-and-riscv.patch
diff --git a/queue-6.1/x86-fpu-use-_alignof-to-avoid-undefined-behavior-in-type_align.patch b/queue-6.1/x86-fpu-use-_alignof-to-avoid-undefined-behavior-in-type_align.patch
new file mode 100644 (file)
index 0000000..889b0cb
--- /dev/null
@@ -0,0 +1,63 @@
+From 839cb44916a5f7c2f504ae631831492208d94d41 Mon Sep 17 00:00:00 2001
+From: YingChi Long <me@inclyc.cn>
+Date: Fri, 18 Nov 2022 08:55:35 +0800
+Subject: x86/fpu: Use _Alignof to avoid undefined behavior in TYPE_ALIGN
+
+From: YingChi Long <me@inclyc.cn>
+
+commit 55228db2697c09abddcb9487c3d9fa5854a932cd upstream.
+
+WG14 N2350 specifies that it is an undefined behavior to have type
+definitions within offsetof", see
+
+  https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm
+
+This specification is also part of C23.
+
+Therefore, replace the TYPE_ALIGN macro with the _Alignof builtin to
+avoid undefined behavior. (_Alignof itself is C11 and the kernel is
+built with -gnu11).
+
+ISO C11 _Alignof is subtly different from the GNU C extension
+__alignof__. Latter is the preferred alignment and _Alignof the
+minimal alignment. For long long on x86 these are 8 and 4
+respectively.
+
+The macro TYPE_ALIGN's behavior matches _Alignof rather than
+__alignof__.
+
+  [ bp: Massage commit message. ]
+
+Signed-off-by: YingChi Long <me@inclyc.cn>
+Signed-off-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
+Link: https://lore.kernel.org/r/20220925153151.2467884-1-me@inclyc.cn
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/kernel/fpu/init.c |    7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+--- a/arch/x86/kernel/fpu/init.c
++++ b/arch/x86/kernel/fpu/init.c
+@@ -133,9 +133,6 @@ static void __init fpu__init_system_gene
+       fpu__init_system_mxcsr();
+ }
+-/* Get alignment of the TYPE. */
+-#define TYPE_ALIGN(TYPE) offsetof(struct { char x; TYPE test; }, test)
+-
+ /*
+  * Enforce that 'MEMBER' is the last field of 'TYPE'.
+  *
+@@ -143,8 +140,8 @@ static void __init fpu__init_system_gene
+  * because that's how C aligns structs.
+  */
+ #define CHECK_MEMBER_AT_END_OF(TYPE, MEMBER) \
+-      BUILD_BUG_ON(sizeof(TYPE) != ALIGN(offsetofend(TYPE, MEMBER), \
+-                                         TYPE_ALIGN(TYPE)))
++      BUILD_BUG_ON(sizeof(TYPE) !=         \
++                   ALIGN(offsetofend(TYPE, MEMBER), _Alignof(TYPE)))
+ /*
+  * We append the 'struct fpu' to the task_struct: