Skip to content

Commit ca01c0d

Browse files
leitaobp3tk0v
authored andcommitted
x86/bugs: Add a separate config for Spectre v1
Currently, the CONFIG_SPECULATION_MITIGATIONS is halfway populated, where some mitigations have entries in Kconfig, and they could be modified, while others mitigations do not have Kconfig entries, and could not be controlled at build time. Create an entry for the Spectre v1 CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time. Signed-off-by: Breno Leitao <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 894e288 commit ca01c0d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

arch/x86/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,6 +2705,16 @@ config MITIGATION_RETBLEED
27052705
unprivileged attacker can use these flaws to bypass conventional
27062706
memory security restrictions to gain read access to privileged memory
27072707
that would otherwise be inaccessible.
2708+
2709+
config MITIGATION_SPECTRE_V1
2710+
bool "Mitigate SPECTRE V1 hardware bug"
2711+
default y
2712+
help
2713+
Enable mitigation for Spectre V1 (Bounds Check Bypass). Spectre V1 is a
2714+
class of side channel attacks that takes advantage of speculative
2715+
execution that bypasses conditional branch instructions used for
2716+
memory access bounds check.
2717+
See also <file:Documentation/admin-guide/hw-vuln/spectre.rst>
27082718
endif
27092719

27102720
config ARCH_HAS_ADD_PAGES

arch/x86/kernel/cpu/bugs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,8 @@ enum spectre_v1_mitigation {
874874
};
875875

876876
static enum spectre_v1_mitigation spectre_v1_mitigation __ro_after_init =
877-
SPECTRE_V1_MITIGATION_AUTO;
877+
IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V1) ?
878+
SPECTRE_V1_MITIGATION_AUTO : SPECTRE_V1_MITIGATION_NONE;
878879

879880
static const char * const spectre_v1_strings[] = {
880881
[SPECTRE_V1_MITIGATION_NONE] = "Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers",

0 commit comments

Comments
 (0)