Skip to content

Commit 4d8df8c

Browse files
asteinhaKAGA-KOKO
authored andcommitted
x86/speculation: PR_SPEC_FORCE_DISABLE enforcement for indirect branches.
Currently, it is possible to enable indirect branch speculation even after it was force-disabled using the PR_SPEC_FORCE_DISABLE option. Moreover, the PR_GET_SPECULATION_CTRL command gives afterwards an incorrect result (force-disabled when it is in fact enabled). This also is inconsistent vs. STIBP and the documention which cleary states that PR_SPEC_FORCE_DISABLE cannot be undone. Fix this by actually enforcing force-disabled indirect branch speculation. PR_SPEC_ENABLE called after PR_SPEC_FORCE_DISABLE now fails with -EPERM as described in the documentation. Fixes: 9137bb2 ("x86/speculation: Add prctl() control for indirect branch speculation") Signed-off-by: Anthony Steinhauser <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected]
1 parent dbbe2ad commit 4d8df8c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,11 +1175,14 @@ static int ib_prctl_set(struct task_struct *task, unsigned long ctrl)
11751175
return 0;
11761176
/*
11771177
* Indirect branch speculation is always disabled in strict
1178-
* mode.
1178+
* mode. It can neither be enabled if it was force-disabled
1179+
* by a previous prctl call.
1180+
11791181
*/
11801182
if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||
11811183
spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||
1182-
spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED)
1184+
spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED ||
1185+
task_spec_ib_force_disable(task))
11831186
return -EPERM;
11841187
task_clear_spec_ib_disable(task);
11851188
task_update_spec_tif(task);

0 commit comments

Comments
 (0)