lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251020145118.1306-3-shechenglong@xfusion.com>
Date: Mon, 20 Oct 2025 22:51:17 +0800
From: shechenglong <shechenglong@...sion.com>
To: <linux-arm-kernel@...ts.infradead.org>
CC: <mark.rutland@....com>, <catalin.marinas@....com>, <will@...nel.org>,
	<linux-kernel@...r.kernel.org>, <stone.xulei@...sion.com>,
	<chenjialong@...sion.com>, <yuxiating@...sion.com>, shechenglong
	<shechenglong@...sion.com>
Subject: [PATCH v2 2/2] cpu: fix hard lockup triggered by printk calls within  scheduling context

relocate the printk() calls from spectre_v4_mitigations_off() and
spectre_v2_mitigations_off() into setup_system_capabilities() function,
preventing hard lockups that occur when printk() is invoked from scheduler context.

Link: https://patchwork.kernel.org/project/linux-arm-kernel/patch/20250918064907.1832-1-shechenglong@xfusion.com/
Suggested-by: Mark Rutland <mark.rutland@....com>
Suggested-by: Catalin Marinas <catalin.marinas@....com>
Suggested-by: Will Deacon <will@...nel.org>
Signed-off-by: shechenglong <shechenglong@...sion.com>
---
 arch/arm64/include/asm/spectre.h |  2 ++
 arch/arm64/kernel/cpufeature.c   |  7 ++++++-
 arch/arm64/kernel/proton-pack.c  | 28 ++++++++++++++--------------
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/arch/arm64/include/asm/spectre.h b/arch/arm64/include/asm/spectre.h
index 8fef12626090..f244b52fb123 100644
--- a/arch/arm64/include/asm/spectre.h
+++ b/arch/arm64/include/asm/spectre.h
@@ -118,5 +118,7 @@ void spectre_bhb_patch_wa3(struct alt_instr *alt,
 void spectre_bhb_patch_clearbhb(struct alt_instr *alt,
                                __le32 *origptr, __le32 *updptr, int nr_inst);

+void spectre_print_disabled_mitigations(void);
+
 #endif /* __ASSEMBLY__ */
 #endif /* __ASM_SPECTRE_H */
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 5ed401ff79e3..6836e314fd30 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -94,7 +94,7 @@
 #include <asm/traps.h>
 #include <asm/vectors.h>
 #include <asm/virt.h>
-
+#include <asm/spectre.h>
 /* Kernel representation of AT_HWCAP and AT_HWCAP2 */
 static DECLARE_BITMAP(elf_hwcap, MAX_CPU_FEATURES) __read_mostly;

@@ -3875,6 +3875,11 @@ static void __init setup_system_capabilities(void)
         */
        if (system_uses_ttbr0_pan())
                pr_info("emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching\n");
+
+       /*
+        * Report Spectre mitigations status.
+        */
+       spectre_print_disabled_mitigations();
 }

 void __init setup_system_features(void)
diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c
index d833b7c1bba8..386f986e6b5d 100644
--- a/arch/arm64/kernel/proton-pack.c
+++ b/arch/arm64/kernel/proton-pack.c
@@ -91,12 +91,7 @@ early_param("nospectre_v2", parse_spectre_v2_param);

 static bool spectre_v2_mitigations_off(void)
 {
-       bool ret = __nospectre_v2 || cpu_mitigations_off();
-
-       if (ret)
-               pr_info_once("spectre-v2 mitigation disabled by command line option\n");
-
-       return ret;
+       return __nospectre_v2 || cpu_mitigations_off();
 }

 static const char *get_bhb_affected_string(enum mitigation_state bhb_state)
@@ -421,13 +416,8 @@ early_param("ssbd", parse_spectre_v4_param);
  */
 static bool spectre_v4_mitigations_off(void)
 {
-       bool ret = cpu_mitigations_off() ||
+       return cpu_mitigations_off() ||
                   __spectre_v4_policy == SPECTRE_V4_POLICY_MITIGATION_DISABLED;
-
-       if (ret)
-               pr_info_once("spectre-v4 mitigation disabled by command-line option\n");
-
-       return ret;
 }

 /* Do we need to toggle the mitigation state on entry to/exit from the kernel? */
@@ -1042,8 +1032,6 @@ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry)

        if (arm64_get_spectre_v2_state() == SPECTRE_VULNERABLE) {
                /* No point mitigating Spectre-BHB alone. */
-       } else if (cpu_mitigations_off() || __nospectre_bhb) {
-               pr_info_once("spectre-bhb mitigation disabled by command line option\n");
        } else if (supports_ecbhb(SCOPE_LOCAL_CPU)) {
                state = SPECTRE_MITIGATED;
                set_bit(BHB_HW, &system_bhb_mitigations);
@@ -1197,3 +1185,15 @@ void unpriv_ebpf_notify(int new_state)
                pr_err("WARNING: %s", EBPF_WARN);
 }
 #endif
+
+void spectre_print_disabled_mitigations(void)
+{
+       if (spectre_v2_mitigations_off())
+               pr_info("spectre-v2 mitigation disabled by command-line option\n");
+
+       if (spectre_v4_mitigations_off())
+               pr_info("spectre-v4 mitigation disabled by command-line option\n");
+
+       if (__nospectre_bhb || cpu_mitigations_off())
+               pr_info("spectre-bhb mitigation disabled by command-line option\n");
+}
--
2.33.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ