diff mbox series

[04/11] x86/bugs: Change commas to semicolons in 'spectre_v2' sysfs file

Message ID 20240417235401.243631-5-yuxuan.luo@canonical.com
State New
Headers show
Series CVE-2024-2201 | expand

Commit Message

Yuxuan Luo April 17, 2024, 11:53 p.m. UTC
From: Josh Poimboeuf <jpoimboe@kernel.org>

Change the format of the 'spectre_v2' vulnerabilities sysfs file
slightly by converting the commas to semicolons, so that mitigations for
future variants can be grouped together and separated by commas.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Daniel Sneddon <daniel.sneddon@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

(backported from commit 0cd01ac5dcb1e18eb18df0f0d05b5de76522a437)
[yuxuan.luo: manually substituted the spectre_v2_show_state() hunk]
CVE-2024-2201
Signed-off-by: Yuxuan Luo <yuxuan.luo@canonical.com>
---
 arch/x86/kernel/cpu/bugs.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Juerg Haefliger April 30, 2024, 9:10 a.m. UTC | #1
On Wed, 17 Apr 2024 19:53:54 -0400
Yuxuan Luo <yuxuan.luo@canonical.com> wrote:

> From: Josh Poimboeuf <jpoimboe@kernel.org>
> 
> Change the format of the 'spectre_v2' vulnerabilities sysfs file
> slightly by converting the commas to semicolons, so that mitigations for
> future variants can be grouped together and separated by commas.
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> Signed-off-by: Daniel Sneddon <daniel.sneddon@linux.intel.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> 
> (backported from commit 0cd01ac5dcb1e18eb18df0f0d05b5de76522a437)
> [yuxuan.luo: manually substituted the spectre_v2_show_state() hunk]
> CVE-2024-2201
> Signed-off-by: Yuxuan Luo <yuxuan.luo@canonical.com>

This is a user visible change that might break userspace tools that parse
this file. Is this change relevant for the patch series?

...Juerg


> ---
>  arch/x86/kernel/cpu/bugs.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> index a0d2ace1877a5..be2c0cf95f3f3 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -2233,15 +2233,15 @@ static char *stibp_state(void)
>  
>  	switch (spectre_v2_user_stibp) {
>  	case SPECTRE_V2_USER_NONE:
> -		return ", STIBP: disabled";
> +		return "; STIBP: disabled";
>  	case SPECTRE_V2_USER_STRICT:
> -		return ", STIBP: forced";
> +		return "; STIBP: forced";
>  	case SPECTRE_V2_USER_STRICT_PREFERRED:
> -		return ", STIBP: always-on";
> +		return "; STIBP: always-on";
>  	case SPECTRE_V2_USER_PRCTL:
>  	case SPECTRE_V2_USER_SECCOMP:
>  		if (static_key_enabled(&switch_to_cond_stibp))
> -			return ", STIBP: conditional";
> +			return "; STIBP: conditional";
>  	}
>  	return "";
>  }
> @@ -2250,10 +2250,10 @@ static char *ibpb_state(void)
>  {
>  	if (boot_cpu_has(X86_FEATURE_IBPB)) {
>  		if (static_key_enabled(&switch_mm_always_ibpb))
> -			return ", IBPB: always-on";
> +			return "; IBPB: always-on";
>  		if (static_key_enabled(&switch_mm_cond_ibpb))
> -			return ", IBPB: conditional";
> -		return ", IBPB: disabled";
> +			return "; IBPB: conditional";
> +		return "; IBPB: disabled";
>  	}
>  	return "";
>  }
> @@ -2263,11 +2263,11 @@ static char *pbrsb_eibrs_state(void)
>  	if (boot_cpu_has_bug(X86_BUG_EIBRS_PBRSB)) {
>  		if (boot_cpu_has(X86_FEATURE_RSB_VMEXIT_LITE) ||
>  		    boot_cpu_has(X86_FEATURE_RSB_VMEXIT))
> -			return ", PBRSB-eIBRS: SW sequence";
> +			return "; PBRSB-eIBRS: SW sequence";
>  		else
> -			return ", PBRSB-eIBRS: Vulnerable";
> +			return "; PBRSB-eIBRS: Vulnerable";
>  	} else {
> -		return ", PBRSB-eIBRS: Not affected";
> +		return "; PBRSB-eIBRS: Not affected";
>  	}
>  }
>  
> @@ -2286,9 +2286,9 @@ static ssize_t spectre_v2_show_state(char *buf)
>  	return sprintf(buf, "%s%s%s%s%s%s%s\n",
>  		       spectre_v2_strings[spectre_v2_enabled],
>  		       ibpb_state(),
> -		       boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? ", IBRS_FW" : "",
> +		       boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? "; IBRS_FW" : "",
>  		       stibp_state(),
> -		       boot_cpu_has(X86_FEATURE_RSB_CTXSW) ? ", RSB filling" : "",
> +		       boot_cpu_has(X86_FEATURE_RSB_CTXSW) ? "; RSB filling" : "",
>  		       pbrsb_eibrs_state(),
>  		       spectre_v2_module_string());
>  }
diff mbox series

Patch

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index a0d2ace1877a5..be2c0cf95f3f3 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -2233,15 +2233,15 @@  static char *stibp_state(void)
 
 	switch (spectre_v2_user_stibp) {
 	case SPECTRE_V2_USER_NONE:
-		return ", STIBP: disabled";
+		return "; STIBP: disabled";
 	case SPECTRE_V2_USER_STRICT:
-		return ", STIBP: forced";
+		return "; STIBP: forced";
 	case SPECTRE_V2_USER_STRICT_PREFERRED:
-		return ", STIBP: always-on";
+		return "; STIBP: always-on";
 	case SPECTRE_V2_USER_PRCTL:
 	case SPECTRE_V2_USER_SECCOMP:
 		if (static_key_enabled(&switch_to_cond_stibp))
-			return ", STIBP: conditional";
+			return "; STIBP: conditional";
 	}
 	return "";
 }
@@ -2250,10 +2250,10 @@  static char *ibpb_state(void)
 {
 	if (boot_cpu_has(X86_FEATURE_IBPB)) {
 		if (static_key_enabled(&switch_mm_always_ibpb))
-			return ", IBPB: always-on";
+			return "; IBPB: always-on";
 		if (static_key_enabled(&switch_mm_cond_ibpb))
-			return ", IBPB: conditional";
-		return ", IBPB: disabled";
+			return "; IBPB: conditional";
+		return "; IBPB: disabled";
 	}
 	return "";
 }
@@ -2263,11 +2263,11 @@  static char *pbrsb_eibrs_state(void)
 	if (boot_cpu_has_bug(X86_BUG_EIBRS_PBRSB)) {
 		if (boot_cpu_has(X86_FEATURE_RSB_VMEXIT_LITE) ||
 		    boot_cpu_has(X86_FEATURE_RSB_VMEXIT))
-			return ", PBRSB-eIBRS: SW sequence";
+			return "; PBRSB-eIBRS: SW sequence";
 		else
-			return ", PBRSB-eIBRS: Vulnerable";
+			return "; PBRSB-eIBRS: Vulnerable";
 	} else {
-		return ", PBRSB-eIBRS: Not affected";
+		return "; PBRSB-eIBRS: Not affected";
 	}
 }
 
@@ -2286,9 +2286,9 @@  static ssize_t spectre_v2_show_state(char *buf)
 	return sprintf(buf, "%s%s%s%s%s%s%s\n",
 		       spectre_v2_strings[spectre_v2_enabled],
 		       ibpb_state(),
-		       boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? ", IBRS_FW" : "",
+		       boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? "; IBRS_FW" : "",
 		       stibp_state(),
-		       boot_cpu_has(X86_FEATURE_RSB_CTXSW) ? ", RSB filling" : "",
+		       boot_cpu_has(X86_FEATURE_RSB_CTXSW) ? "; RSB filling" : "",
 		       pbrsb_eibrs_state(),
 		       spectre_v2_module_string());
 }