Skip to content

Commit 0de05d0

Browse files
jpoimboesuryasaimadhu
authored andcommitted
x86/speculation: Warn about eIBRS + LFENCE + Unprivileged eBPF + SMT
The commit 44a3918 ("x86/speculation: Include unprivileged eBPF status in Spectre v2 mitigation reporting") added a warning for the "eIBRS + unprivileged eBPF" combination, which has been shown to be vulnerable against Spectre v2 BHB-based attacks. However, there's no warning about the "eIBRS + LFENCE retpoline + unprivileged eBPF" combo. The LFENCE adds more protection by shortening the speculation window after a mispredicted branch. That makes an attack significantly more difficult, even with unprivileged eBPF. So at least for now the logic doesn't warn about that combination. But if you then add SMT into the mix, the SMT attack angle weakens the effectiveness of the LFENCE considerably. So extend the "eIBRS + unprivileged eBPF" warning to also include the "eIBRS + LFENCE + unprivileged eBPF + SMT" case. [ bp: Massage commit message. ] Suggested-by: Alyssa Milburn <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Borislav Petkov <[email protected]>
1 parent eafd987 commit 0de05d0

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,27 @@ static inline const char *spectre_v2_module_string(void) { return ""; }
653653

654654
#define SPECTRE_V2_LFENCE_MSG "WARNING: LFENCE mitigation is not recommended for this CPU, data leaks possible!\n"
655655
#define SPECTRE_V2_EIBRS_EBPF_MSG "WARNING: Unprivileged eBPF is enabled with eIBRS on, data leaks possible via Spectre v2 BHB attacks!\n"
656+
#define SPECTRE_V2_EIBRS_LFENCE_EBPF_SMT_MSG "WARNING: Unprivileged eBPF is enabled with eIBRS+LFENCE mitigation and SMT, data leaks possible via Spectre v2 BHB attacks!\n"
656657

657658
#ifdef CONFIG_BPF_SYSCALL
658659
void unpriv_ebpf_notify(int new_state)
659660
{
660-
if (spectre_v2_enabled == SPECTRE_V2_EIBRS && !new_state)
661+
if (new_state)
662+
return;
663+
664+
/* Unprivileged eBPF is enabled */
665+
666+
switch (spectre_v2_enabled) {
667+
case SPECTRE_V2_EIBRS:
661668
pr_err(SPECTRE_V2_EIBRS_EBPF_MSG);
669+
break;
670+
case SPECTRE_V2_EIBRS_LFENCE:
671+
if (sched_smt_active())
672+
pr_err(SPECTRE_V2_EIBRS_LFENCE_EBPF_SMT_MSG);
673+
break;
674+
default:
675+
break;
676+
}
662677
}
663678
#endif
664679

@@ -1118,6 +1133,10 @@ void cpu_bugs_smt_update(void)
11181133
{
11191134
mutex_lock(&spec_ctrl_mutex);
11201135

1136+
if (sched_smt_active() && unprivileged_ebpf_enabled() &&
1137+
spectre_v2_enabled == SPECTRE_V2_EIBRS_LFENCE)
1138+
pr_warn_once(SPECTRE_V2_EIBRS_LFENCE_EBPF_SMT_MSG);
1139+
11211140
switch (spectre_v2_user_stibp) {
11221141
case SPECTRE_V2_USER_NONE:
11231142
break;
@@ -1793,7 +1812,11 @@ static ssize_t spectre_v2_show_state(char *buf)
17931812
return sprintf(buf, "Vulnerable: LFENCE\n");
17941813

17951814
if (spectre_v2_enabled == SPECTRE_V2_EIBRS && unprivileged_ebpf_enabled())
1796-
return sprintf(buf, "Vulnerable: Unprivileged eBPF enabled\n");
1815+
return sprintf(buf, "Vulnerable: eIBRS with unprivileged eBPF\n");
1816+
1817+
if (sched_smt_active() && unprivileged_ebpf_enabled() &&
1818+
spectre_v2_enabled == SPECTRE_V2_EIBRS_LFENCE)
1819+
return sprintf(buf, "Vulnerable: eIBRS+LFENCE with unprivileged eBPF and SMT\n");
17971820

17981821
return sprintf(buf, "%s%s%s%s%s%s\n",
17991822
spectre_v2_strings[spectre_v2_enabled],

0 commit comments

Comments
 (0)