From 79bfa04ef8f935bfd24b98ea86e724087a3cade2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 31 Aug 2023 12:58:59 +0200 Subject: [PATCH] 6.4-stable patches added patches: lockdep-fix-static-memory-detection-even-more.patch parisc-sys_parisc-parisc_personality-is-called-from-asm-code.patch --- ...ix-static-memory-detection-even-more.patch | 132 ++++++++++++++++++ ..._personality-is-called-from-asm-code.patch | 34 +++++ queue-6.4/series | 2 + 3 files changed, 168 insertions(+) create mode 100644 queue-6.4/lockdep-fix-static-memory-detection-even-more.patch create mode 100644 queue-6.4/parisc-sys_parisc-parisc_personality-is-called-from-asm-code.patch diff --git a/queue-6.4/lockdep-fix-static-memory-detection-even-more.patch b/queue-6.4/lockdep-fix-static-memory-detection-even-more.patch new file mode 100644 index 00000000000..76c3c9657ec --- /dev/null +++ b/queue-6.4/lockdep-fix-static-memory-detection-even-more.patch @@ -0,0 +1,132 @@ +From 0a6b58c5cd0dfd7961e725212f0fc8dfc5d96195 Mon Sep 17 00:00:00 2001 +From: Helge Deller +Date: Tue, 15 Aug 2023 00:31:09 +0200 +Subject: lockdep: fix static memory detection even more + +From: Helge Deller + +commit 0a6b58c5cd0dfd7961e725212f0fc8dfc5d96195 upstream. + +On the parisc architecture, lockdep reports for all static objects which +are in the __initdata section (e.g. "setup_done" in devtmpfs, +"kthreadd_done" in init/main.c) this warning: + + INFO: trying to register non-static key. + +The warning itself is wrong, because those objects are in the __initdata +section, but the section itself is on parisc outside of range from +_stext to _end, which is why the static_obj() functions returns a wrong +answer. + +While fixing this issue, I noticed that the whole existing check can +be simplified a lot. +Instead of checking against the _stext and _end symbols (which include +code areas too) just check for the .data and .bss segments (since we check a +data object). This can be done with the existing is_kernel_core_data() +macro. + +In addition objects in the __initdata section can be checked with +init_section_contains(), and is_kernel_rodata() allows keys to be in the +_ro_after_init section. + +This partly reverts and simplifies commit bac59d18c701 ("x86/setup: Fix static +memory detection"). + +Link: https://lkml.kernel.org/r/ZNqrLRaOi/3wPAdp@p100 +Fixes: bac59d18c701 ("x86/setup: Fix static memory detection") +Signed-off-by: Helge Deller +Cc: Borislav Petkov +Cc: Greg Kroah-Hartman +Cc: Guenter Roeck +Cc: Peter Zijlstra +Cc: "Rafael J. Wysocki" +Signed-off-by: Andrew Morton +Signed-off-by: Greg Kroah-Hartman +--- + arch/x86/include/asm/sections.h | 18 ------------------ + kernel/locking/lockdep.c | 36 ++++++++++++++---------------------- + 2 files changed, 14 insertions(+), 40 deletions(-) + +--- a/arch/x86/include/asm/sections.h ++++ b/arch/x86/include/asm/sections.h +@@ -2,8 +2,6 @@ + #ifndef _ASM_X86_SECTIONS_H + #define _ASM_X86_SECTIONS_H + +-#define arch_is_kernel_initmem_freed arch_is_kernel_initmem_freed +- + #include + #include + +@@ -18,20 +16,4 @@ extern char __end_of_kernel_reserve[]; + + extern unsigned long _brk_start, _brk_end; + +-static inline bool arch_is_kernel_initmem_freed(unsigned long addr) +-{ +- /* +- * If _brk_start has not been cleared, brk allocation is incomplete, +- * and we can not make assumptions about its use. +- */ +- if (_brk_start) +- return 0; +- +- /* +- * After brk allocation is complete, space between _brk_end and _end +- * is available for allocation. +- */ +- return addr >= _brk_end && addr < (unsigned long)&_end; +-} +- + #endif /* _ASM_X86_SECTIONS_H */ +--- a/kernel/locking/lockdep.c ++++ b/kernel/locking/lockdep.c +@@ -817,34 +817,26 @@ static int very_verbose(struct lock_clas + * Is this the address of a static object: + */ + #ifdef __KERNEL__ +-/* +- * Check if an address is part of freed initmem. After initmem is freed, +- * memory can be allocated from it, and such allocations would then have +- * addresses within the range [_stext, _end]. +- */ +-#ifndef arch_is_kernel_initmem_freed +-static int arch_is_kernel_initmem_freed(unsigned long addr) +-{ +- if (system_state < SYSTEM_FREEING_INITMEM) +- return 0; +- +- return init_section_contains((void *)addr, 1); +-} +-#endif +- + static int static_obj(const void *obj) + { +- unsigned long start = (unsigned long) &_stext, +- end = (unsigned long) &_end, +- addr = (unsigned long) obj; ++ unsigned long addr = (unsigned long) obj; + +- if (arch_is_kernel_initmem_freed(addr)) +- return 0; ++ if (is_kernel_core_data(addr)) ++ return 1; ++ ++ /* ++ * keys are allowed in the __ro_after_init section. ++ */ ++ if (is_kernel_rodata(addr)) ++ return 1; + + /* +- * static variable? ++ * in initdata section and used during bootup only? ++ * NOTE: On some platforms the initdata section is ++ * outside of the _stext ... _end range. + */ +- if ((addr >= start) && (addr < end)) ++ if (system_state < SYSTEM_FREEING_INITMEM && ++ init_section_contains((void *)addr, 1)) + return 1; + + /* diff --git a/queue-6.4/parisc-sys_parisc-parisc_personality-is-called-from-asm-code.patch b/queue-6.4/parisc-sys_parisc-parisc_personality-is-called-from-asm-code.patch new file mode 100644 index 00000000000..c2ef9976c50 --- /dev/null +++ b/queue-6.4/parisc-sys_parisc-parisc_personality-is-called-from-asm-code.patch @@ -0,0 +1,34 @@ +From b5d89408b9fb21258f7c371d6d48a674f60f7181 Mon Sep 17 00:00:00 2001 +From: Helge Deller +Date: Fri, 30 Jun 2023 12:36:09 +0200 +Subject: parisc: sys_parisc: parisc_personality() is called from asm code + +From: Helge Deller + +commit b5d89408b9fb21258f7c371d6d48a674f60f7181 upstream. + +Signed-off-by: Helge Deller +Signed-off-by: Greg Kroah-Hartman +--- + arch/parisc/kernel/sys_parisc.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/arch/parisc/kernel/sys_parisc.c ++++ b/arch/parisc/kernel/sys_parisc.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + /* + * Construct an artificial page offset for the mapping based on the physical +@@ -339,7 +340,7 @@ asmlinkage long parisc_fallocate(int fd, + ((u64)lenhi << 32) | lenlo); + } + +-long parisc_personality(unsigned long personality) ++asmlinkage long parisc_personality(unsigned long personality) + { + long err; + diff --git a/queue-6.4/series b/queue-6.4/series index 99c901adf64..deca3684780 100644 --- a/queue-6.4/series +++ b/queue-6.4/series @@ -4,3 +4,5 @@ module-expose-module_init_layout_section.patch arm64-module-plts-inline-linux-moduleloader.h.patch arm64-module-use-module_init_layout_section-to-spot-init-sections.patch arm-module-use-module_init_layout_section-to-spot-init-sections.patch +lockdep-fix-static-memory-detection-even-more.patch +parisc-sys_parisc-parisc_personality-is-called-from-asm-code.patch -- 2.47.3