Skip to content

Commit dc6306a

Browse files
jpoimboebp3tk0v
authored andcommitted
x86/srso: Fix vulnerability reporting for missing microcode
The SRSO default safe-ret mitigation is reported as "mitigated" even if microcode hasn't been updated. That's wrong because userspace may still be vulnerable to SRSO attacks due to IBPB not flushing branch type predictions. Report the safe-ret + !microcode case as vulnerable. Also report the microcode-only case as vulnerable as it leaves the kernel open to attacks. Fixes: fb3bd91 ("x86/srso: Add a Speculative RAS Overflow mitigation") Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/a8a14f97d1b0e03ec255c81637afdf4cf0ae9c99.1693889988.git.jpoimboe@kernel.org
1 parent de9f5f7 commit dc6306a

File tree

2 files changed

+39
-21
lines changed

2 files changed

+39
-21
lines changed

Documentation/admin-guide/hw-vuln/srso.rst

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,22 @@ The possible values in this file are:
4646

4747
The processor is not vulnerable
4848

49-
* 'Vulnerable: no microcode':
49+
* 'Vulnerable':
50+
51+
The processor is vulnerable and no mitigations have been applied.
52+
53+
* 'Vulnerable: No microcode':
5054

5155
The processor is vulnerable, no microcode extending IBPB
5256
functionality to address the vulnerability has been applied.
5357

54-
* 'Mitigation: microcode':
58+
* 'Vulnerable: Safe RET, no microcode':
59+
60+
The "Safe RET" mitigation (see below) has been applied to protect the
61+
kernel, but the IBPB-extending microcode has not been applied. User
62+
space tasks may still be vulnerable.
63+
64+
* 'Vulnerable: Microcode, no safe RET':
5565

5666
Extended IBPB functionality microcode patch has been applied. It does
5767
not address User->Kernel and Guest->Host transitions protection but it
@@ -72,11 +82,11 @@ The possible values in this file are:
7282

7383
(spec_rstack_overflow=microcode)
7484

75-
* 'Mitigation: safe RET':
85+
* 'Mitigation: Safe RET':
7686

77-
Software-only mitigation. It complements the extended IBPB microcode
78-
patch functionality by addressing User->Kernel and Guest->Host
79-
transitions protection.
87+
Combined microcode/software mitigation. It complements the
88+
extended IBPB microcode patch functionality by addressing
89+
User->Kernel and Guest->Host transitions protection.
8090

8191
Selected by default or by spec_rstack_overflow=safe-ret
8292

@@ -129,7 +139,7 @@ an indrect branch prediction barrier after having applied the required
129139
microcode patch for one's system. This mitigation comes also at
130140
a performance cost.
131141

132-
Mitigation: safe RET
142+
Mitigation: Safe RET
133143
--------------------
134144

135145
The mitigation works by ensuring all RET instructions speculate to

arch/x86/kernel/cpu/bugs.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,6 +2353,8 @@ early_param("l1tf", l1tf_cmdline);
23532353

23542354
enum srso_mitigation {
23552355
SRSO_MITIGATION_NONE,
2356+
SRSO_MITIGATION_UCODE_NEEDED,
2357+
SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED,
23562358
SRSO_MITIGATION_MICROCODE,
23572359
SRSO_MITIGATION_SAFE_RET,
23582360
SRSO_MITIGATION_IBPB,
@@ -2368,11 +2370,13 @@ enum srso_mitigation_cmd {
23682370
};
23692371

23702372
static const char * const srso_strings[] = {
2371-
[SRSO_MITIGATION_NONE] = "Vulnerable",
2372-
[SRSO_MITIGATION_MICROCODE] = "Mitigation: microcode",
2373-
[SRSO_MITIGATION_SAFE_RET] = "Mitigation: safe RET",
2374-
[SRSO_MITIGATION_IBPB] = "Mitigation: IBPB",
2375-
[SRSO_MITIGATION_IBPB_ON_VMEXIT] = "Mitigation: IBPB on VMEXIT only"
2373+
[SRSO_MITIGATION_NONE] = "Vulnerable",
2374+
[SRSO_MITIGATION_UCODE_NEEDED] = "Vulnerable: No microcode",
2375+
[SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED] = "Vulnerable: Safe RET, no microcode",
2376+
[SRSO_MITIGATION_MICROCODE] = "Vulnerable: Microcode, no safe RET",
2377+
[SRSO_MITIGATION_SAFE_RET] = "Mitigation: Safe RET",
2378+
[SRSO_MITIGATION_IBPB] = "Mitigation: IBPB",
2379+
[SRSO_MITIGATION_IBPB_ON_VMEXIT] = "Mitigation: IBPB on VMEXIT only"
23762380
};
23772381

23782382
static enum srso_mitigation srso_mitigation __ro_after_init = SRSO_MITIGATION_NONE;
@@ -2409,10 +2413,7 @@ static void __init srso_select_mitigation(void)
24092413
if (!boot_cpu_has_bug(X86_BUG_SRSO) || cpu_mitigations_off())
24102414
goto pred_cmd;
24112415

2412-
if (!has_microcode) {
2413-
pr_warn("IBPB-extending microcode not applied!\n");
2414-
pr_warn(SRSO_NOTICE);
2415-
} else {
2416+
if (has_microcode) {
24162417
/*
24172418
* Zen1/2 with SMT off aren't vulnerable after the right
24182419
* IBPB microcode has been applied.
@@ -2428,6 +2429,12 @@ static void __init srso_select_mitigation(void)
24282429
srso_mitigation = SRSO_MITIGATION_IBPB;
24292430
goto out;
24302431
}
2432+
} else {
2433+
pr_warn("IBPB-extending microcode not applied!\n");
2434+
pr_warn(SRSO_NOTICE);
2435+
2436+
/* may be overwritten by SRSO_CMD_SAFE_RET below */
2437+
srso_mitigation = SRSO_MITIGATION_UCODE_NEEDED;
24312438
}
24322439

24332440
switch (srso_cmd) {
@@ -2457,7 +2464,10 @@ static void __init srso_select_mitigation(void)
24572464
setup_force_cpu_cap(X86_FEATURE_SRSO);
24582465
x86_return_thunk = srso_return_thunk;
24592466
}
2460-
srso_mitigation = SRSO_MITIGATION_SAFE_RET;
2467+
if (has_microcode)
2468+
srso_mitigation = SRSO_MITIGATION_SAFE_RET;
2469+
else
2470+
srso_mitigation = SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED;
24612471
} else {
24622472
pr_err("WARNING: kernel not compiled with CPU_SRSO.\n");
24632473
}
@@ -2490,7 +2500,7 @@ static void __init srso_select_mitigation(void)
24902500
}
24912501

24922502
out:
2493-
pr_info("%s%s\n", srso_strings[srso_mitigation], has_microcode ? "" : ", no microcode");
2503+
pr_info("%s\n", srso_strings[srso_mitigation]);
24942504

24952505
pred_cmd:
24962506
if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
@@ -2701,9 +2711,7 @@ static ssize_t srso_show_state(char *buf)
27012711
if (boot_cpu_has(X86_FEATURE_SRSO_NO))
27022712
return sysfs_emit(buf, "Mitigation: SMT disabled\n");
27032713

2704-
return sysfs_emit(buf, "%s%s\n",
2705-
srso_strings[srso_mitigation],
2706-
boot_cpu_has(X86_FEATURE_IBPB_BRTYPE) ? "" : ", no microcode");
2714+
return sysfs_emit(buf, "%s\n", srso_strings[srso_mitigation]);
27072715
}
27082716

27092717
static ssize_t gds_show_state(char *buf)

0 commit comments

Comments
 (0)