Skip to content

Commit 4fa7d88

Browse files
dkaplan2bp3tk0v
authored andcommitted
x86/bugs: Select best SRSO mitigation
The SRSO bug can theoretically be used to conduct user->user or guest->guest attacks and requires a mitigation (namely IBPB instead of SBPB on context switch) for these. So mark SRSO as being applicable to the user->user and guest->guest attack vectors. Additionally, SRSO supports multiple mitigations which mitigate different potential attack vectors. Some CPUs are also immune to SRSO from certain attack vectors (like user->kernel). Use the specific attack vectors requiring mitigation to select the best SRSO mitigation to avoid unnecessary performance hits. Signed-off-by: David Kaplan <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/[email protected]
1 parent 8f5ae30 commit 4fa7d88

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Spectre_v1 X
214214
Spectre_v2 X X
215215
Spectre_v2_user X X * (Note 1)
216216
SRBDS X X X X
217-
SRSO X X
217+
SRSO X X X X
218218
SSB (Note 4)
219219
TAA X X X X * (Note 2)
220220
TSA X X X X

arch/x86/kernel/cpu/bugs.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ static bool __init should_mitigate_vuln(unsigned int bug)
386386

387387
case X86_BUG_SPECTRE_V2:
388388
case X86_BUG_RETBLEED:
389-
case X86_BUG_SRSO:
390389
case X86_BUG_L1TF:
391390
case X86_BUG_ITS:
392391
return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL) ||
@@ -3184,8 +3183,18 @@ static void __init srso_select_mitigation(void)
31843183
}
31853184

31863185
if (srso_mitigation == SRSO_MITIGATION_AUTO) {
3187-
if (should_mitigate_vuln(X86_BUG_SRSO)) {
3186+
/*
3187+
* Use safe-RET if user->kernel or guest->host protection is
3188+
* required. Otherwise the 'microcode' mitigation is sufficient
3189+
* to protect the user->user and guest->guest vectors.
3190+
*/
3191+
if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST) ||
3192+
(cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL) &&
3193+
!boot_cpu_has(X86_FEATURE_SRSO_USER_KERNEL_NO))) {
31883194
srso_mitigation = SRSO_MITIGATION_SAFE_RET;
3195+
} else if (cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER) ||
3196+
cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST)) {
3197+
srso_mitigation = SRSO_MITIGATION_MICROCODE;
31893198
} else {
31903199
srso_mitigation = SRSO_MITIGATION_NONE;
31913200
return;

0 commit comments

Comments
 (0)