Skip to content

Commit eafd987

Browse files
jpoimboesuryasaimadhu
authored andcommitted
x86/speculation: Warn about Spectre v2 LFENCE mitigation
With: f8a66d6 ("x86,bugs: Unconditionally allow spectre_v2=retpoline,amd") it became possible to enable the LFENCE "retpoline" on Intel. However, Intel doesn't recommend it, as it has some weaknesses compared to retpoline. Now AMD doesn't recommend it either. It can still be left available as a cmdline option. It's faster than retpoline but is weaker in certain scenarios -- particularly SMT, but even non-SMT may be vulnerable in some cases. So just unconditionally warn if the user requests it on the cmdline. [ bp: Massage commit message. ] Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Borislav Petkov <[email protected]>
1 parent e9b6013 commit eafd987

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ static inline const char *spectre_v2_module_string(void)
651651
static inline const char *spectre_v2_module_string(void) { return ""; }
652652
#endif
653653

654+
#define SPECTRE_V2_LFENCE_MSG "WARNING: LFENCE mitigation is not recommended for this CPU, data leaks possible!\n"
654655
#define SPECTRE_V2_EIBRS_EBPF_MSG "WARNING: Unprivileged eBPF is enabled with eIBRS on, data leaks possible via Spectre v2 BHB attacks!\n"
655656

656657
#ifdef CONFIG_BPF_SYSCALL
@@ -972,6 +973,7 @@ static void __init spectre_v2_select_mitigation(void)
972973
break;
973974

974975
case SPECTRE_V2_CMD_RETPOLINE_LFENCE:
976+
pr_err(SPECTRE_V2_LFENCE_MSG);
975977
mode = SPECTRE_V2_LFENCE;
976978
break;
977979

@@ -1787,6 +1789,9 @@ static char *ibpb_state(void)
17871789

17881790
static ssize_t spectre_v2_show_state(char *buf)
17891791
{
1792+
if (spectre_v2_enabled == SPECTRE_V2_LFENCE)
1793+
return sprintf(buf, "Vulnerable: LFENCE\n");
1794+
17901795
if (spectre_v2_enabled == SPECTRE_V2_EIBRS && unprivileged_ebpf_enabled())
17911796
return sprintf(buf, "Vulnerable: Unprivileged eBPF enabled\n");
17921797

0 commit comments

Comments
 (0)