x86/bugs: Separate config for mitigations
Subsystems (2)
v4 cover x86/bugs: Separate config for mitigations
The current CONFIG_SPECULATION_MITIGATIONS namespace is only halfway populated, where some mitigations have entries in Kconfig, and they could be modified, while others mitigations do not have Kconfig entries, and can not be controlled at build time.
New mitigations, such as BHI, were properly added, i.e, having an independent Kconfig, which depends on CONFIG_SPECULATION_MITIGATIONS, so, you can enable/disable at compilation time.
This patch set aims to have the old mitigations in the same format, bringing some uniformity to the mitigations.
These are the advantages of having fine-grained control for the mitigations:
1) Users can choose and pick only mitigations that are important for their workloads.
2) Users and developers can choose to disable mitigations that mangle the assembly code generation, making it hard to read.
3) Separate Kconfigs for just source code readability, so that we see *which* butt-ugly piece of crap code is for what reason...
In most cases, if a mitigation is disabled at compilation time, it can still be enabled at runtime using kernel command line arguments.
This is the second part of the initial patchset[1] that got half landed. The first patch did some code re-organization. This second part contains the exact missing patches from the initial patchset, and basically adds build-time configuration for the other mitigations that are currently only disabled at boot time.
Here is a detailed view of each patch:
With this patch applied, setting CONFIG_SPECULATION_MITIGATIONS=n, a simple script[2] shows that all the mitigations are disabled:
spectre_v2_user_stibp SPECTRE_V2_USER_NONE spectre_v2_user_ibpb SPECTRE_V2_USER_NONE spectre_v2_cmd SPECTRE_V2_CMD_NONE ssb_mode SPEC_STORE_BYPASS_NONE l1tf_mitigation L1TF_MITIGATION_OFF srso_mitigation SRSO_MITIGATION_NONE srso_cmd SRSO_CMD_SAFE_RET mds_mitigation MDS_MITIGATION_OFF taa_mitigation TAA_MITIGATION_OFF mmio_mitigation MMIO_MITIGATION_OFF srbds_mitigation SRBDS_MITIGATION_OFF gds_mitigation GDS_MITIGATION_OFF spectre_v1_mitigation SPECTRE_V1_MITIGATION_NONE spectre_v2_enabled SPECTRE_V2_NONE retbleed_mitigation RETBLEED_MITIGATION_NONE
[1] https://lore.kernel.org/all/[email protected]/#t
[2] https://github.com/leitao/debug/blob/main/spec/dump_speculation.py
Changelog:
v4:
* Created a patch that removes the MITIGATION_GDS_FORCE Kconfig entry, then rebasing the last patch ("x86/bugs: Add a separate config for GDS") on top of it (Borislav Petkov)
v3:
* Rebased the patch on top of linux-next, since BHI mitigation added some hunk to original patch series.
* Broke down the patches even further, creating one patch for each mitigation. This make the review code easier (I hope).
* Nothing was changed, code-wise. The code is *exactly* the * same
* Dropped the "spectre_v2_user default mode depends on main default" patch, that will be sent later, since there is no dependency to this patch series. Hopping to make the review/acceptance easier as well.
* https://lore.kernel.org/all/[email protected]/
v2:
* Patch 2: Changed mode type from int to enum spectre_v2_user_cmd as suggested by Pawan Gupta
* Patch 3: Change MITIGATION_RETBLEED dependency to match the code.
* https://lore.kernel.org/all/[email protected]/
v1:
* https://lore.kernel.org/all/[email protected]/
Breno Leitao (11):
x86/bugs: Add a separate config for MDS x86/bugs: Add a separate config for TAA x86/bugs: Add a separate config for MMIO Stable Data x86/bugs: Add a separate config for L1TF x86/bugs: Add a separate config for RETBLEED x86/bugs: Add a separate config for Spectre v1 x86/bugs: Add a separate config for SRBDS x86/bugs: Add a separate config for Spectre V2 x86/bugs: Add a separate config for SSB x86/bugs: Remove GDS Force Kconfig option x86/bugs: Add a separate config for GDS
arch/x86/Kconfig | 124 ++++++++++++++++++++++++++++++++----- arch/x86/kernel/cpu/bugs.c | 46 ++++++++------ 2 files changed, 134 insertions(+), 36 deletions(-)
Signature · 1 line
2.43.0
PATCH v4 1/11 x86/bugs: Add a separate config for MDS
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 MDS CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 9 +++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-)
arch/x86/Kconfig +9 -0
@@ -2650,6 +2650,15 @@ config MITIGATION_SPECTRE_BHI indirect branches. See <file:Documentation/admin-guide/hw-vuln/spectre.rst> +config MITIGATION_MDS + bool "Mitigate Microarchitectural Data Sampling (MDS) hardware bug" + depends on CPU_SUP_INTEL + default y + help + Enable mitigation for Microarchitectural Data Sampling (MDS). MDS is + a hardware vulnerability which allows unprivileged speculative access + to data which is available in various CPU internal buffers. + See also <file:Documentation/admin-guide/hw-vuln/mds.rst> endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -233,7 +233,8 @@ static void x86_amd_ssb_disable(void)#define pr_fmt (fmt) "MDS: " fmt/* Default mitigation for MDS-affected CPUs */ -static enum mds_mitigations mds_mitigation__ro_after_init =MDS_MITIGATION_FULL ; +static enum mds_mitigations mds_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_MDS ) ?MDS_MITIGATION_FULL :MDS_MITIGATION_OFF ;static bool mds_nosmt__ro_after_init = false;static const char *const mds_strings[] = {
Signature · 1 line
2.43.0
[tip: x86/bugs] x86/bugs: Add a separate config for MDS
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 940455681d94a4100f024097737e502e93273f26 Gitweb: https://git.kernel.org/tip/940455681d94a4100f024097737e502e93273f26 Author: Breno Leitao <[email protected]> AuthorDate: Mon, 29 Jul 2024 09:40:49 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 30 Jul 2024 10:17:36 +02:00
x86/bugs: Add a separate config for MDS
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 MDS CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 9 +++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-)
arch/x86/Kconfig +9 -0
@@ -2650,6 +2650,15 @@ config MITIGATION_SPECTRE_BHI indirect branches. See <file:Documentation/admin-guide/hw-vuln/spectre.rst> +config MITIGATION_MDS + bool "Mitigate Microarchitectural Data Sampling (MDS) hardware bug" + depends on CPU_SUP_INTEL + default y + help + Enable mitigation for Microarchitectural Data Sampling (MDS). MDS is + a hardware vulnerability which allows unprivileged speculative access + to data which is available in various CPU internal buffers. + See also <file:Documentation/admin-guide/hw-vuln/mds.rst> endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -233,7 +233,8 @@ static void x86_amd_ssb_disable(void)#define pr_fmt (fmt) "MDS: " fmt/* Default mitigation for MDS-affected CPUs */ -static enum mds_mitigations mds_mitigation__ro_after_init =MDS_MITIGATION_FULL ; +static enum mds_mitigations mds_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_MDS ) ?MDS_MITIGATION_FULL :MDS_MITIGATION_OFF ;static bool mds_nosmt__ro_after_init = false;static const char *const mds_strings[] = {
PATCH v4 2/11 x86/bugs: Add a separate config for TAA
In reply to Breno LeitaoCurrently, 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 TAA CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 11 +++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-)
arch/x86/Kconfig +11 -0
@@ -2659,6 +2659,17 @@ config MITIGATION_MDS a hardware vulnerability which allows unprivileged speculative access to data which is available in various CPU internal buffers. See also <file:Documentation/admin-guide/hw-vuln/mds.rst> + +config MITIGATION_TAA + bool "Mitigate TSX Asynchronous Abort (TAA) hardware bug" + depends on CPU_SUP_INTEL + default y + help + Enable mitigation for TSX Asynchronous Abort (TAA). TAA is a hardware + vulnerability that allows unprivileged speculative access to data + which is available in various CPU internal buffers by using + asynchronous aborts within an Intel TSX transactional region. + See also <file:Documentation/admin-guide/hw-vuln/tsx_async_abort.rst> endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -294,7 +294,8 @@ enum taa_mitigations { };/* Default mitigation for TAA-affected CPUs */ -static enum taa_mitigations taa_mitigation__ro_after_init =TAA_MITIGATION_VERW ; +static enum taa_mitigations taa_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_TAA ) ?TAA_MITIGATION_VERW :TAA_MITIGATION_OFF ;static bool taa_nosmt__ro_after_init ;static const char *const taa_strings[] = {
Signature · 1 line
2.43.0
[tip: x86/bugs] x86/bugs: Add a separate config for TAA
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: b8da0b33d3899e5911aaf0220a317545fe2e3b37 Gitweb: https://git.kernel.org/tip/b8da0b33d3899e5911aaf0220a317545fe2e3b37 Author: Breno Leitao <[email protected]> AuthorDate: Mon, 29 Jul 2024 09:40:50 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 30 Jul 2024 10:36:16 +02:00
x86/bugs: Add a separate config for TAA
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 TAA CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 11 +++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-)
arch/x86/Kconfig +11 -0
@@ -2659,6 +2659,17 @@ config MITIGATION_MDS a hardware vulnerability which allows unprivileged speculative access to data which is available in various CPU internal buffers. See also <file:Documentation/admin-guide/hw-vuln/mds.rst> + +config MITIGATION_TAA + bool "Mitigate TSX Asynchronous Abort (TAA) hardware bug" + depends on CPU_SUP_INTEL + default y + help + Enable mitigation for TSX Asynchronous Abort (TAA). TAA is a hardware + vulnerability that allows unprivileged speculative access to data + which is available in various CPU internal buffers by using + asynchronous aborts within an Intel TSX transactional region. + See also <file:Documentation/admin-guide/hw-vuln/tsx_async_abort.rst> endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -294,7 +294,8 @@ enum taa_mitigations { };/* Default mitigation for TAA-affected CPUs */ -static enum taa_mitigations taa_mitigation__ro_after_init =TAA_MITIGATION_VERW ; +static enum taa_mitigations taa_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_TAA ) ?TAA_MITIGATION_VERW :TAA_MITIGATION_OFF ;static bool taa_nosmt__ro_after_init ;static const char *const taa_strings[] = {
PATCH v4 3/11 x86/bugs: Add a separate config for MMIO Stable Data
In reply to Breno LeitaoCurrently, 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 MMIO Stale data CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 12 ++++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-)
arch/x86/Kconfig +12 -0
@@ -2670,6 +2670,18 @@ config MITIGATION_TAA which is available in various CPU internal buffers by using asynchronous aborts within an Intel TSX transactional region. See also <file:Documentation/admin-guide/hw-vuln/tsx_async_abort.rst> + +config MITIGATION_MMIO_STALE_DATA + bool "Mitigate MMIO Stale Data hardware bug" + depends on CPU_SUP_INTEL + default y + help + Enable mitigation for MMIO Stale Data hardware bugs. Processor MMIO + Stale Data Vulnerabilities are a class of memory-mapped I/O (MMIO) + vulnerabilities that can expose data. The vulnerabilities require the + attacker to have access to MMIO. + See also + <file:Documentation/admin-guide/hw-vuln/processor_mmio_stale_data.rst> endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -393,7 +393,8 @@ enum mmio_mitigations { };/* Default mitigation for Processor MMIO Stale Data vulnerabilities */ -static enum mmio_mitigations mmio_mitigation__ro_after_init =MMIO_MITIGATION_VERW ; +static enum mmio_mitigations mmio_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_MMIO_STALE_DATA ) ?MMIO_MITIGATION_VERW :MMIO_MITIGATION_OFF ;static bool mmio_nosmt__ro_after_init = false;static const char *const mmio_strings[] = {
Signature · 1 line
2.43.0
[tip: x86/bugs] x86/bugs: Add a separate config for MMIO Stable Data
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 163f9fe6b625c5f5c4d5b05265b194388182454b Gitweb: https://git.kernel.org/tip/163f9fe6b625c5f5c4d5b05265b194388182454b Author: Breno Leitao <[email protected]> AuthorDate: Mon, 29 Jul 2024 09:40:51 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 30 Jul 2024 10:56:20 +02:00
x86/bugs: Add a separate config for MMIO Stable Data
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 MMIO Stale data CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 12 ++++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-)
arch/x86/Kconfig +12 -0
@@ -2670,6 +2670,18 @@ config MITIGATION_TAA which is available in various CPU internal buffers by using asynchronous aborts within an Intel TSX transactional region. See also <file:Documentation/admin-guide/hw-vuln/tsx_async_abort.rst> + +config MITIGATION_MMIO_STALE_DATA + bool "Mitigate MMIO Stale Data hardware bug" + depends on CPU_SUP_INTEL + default y + help + Enable mitigation for MMIO Stale Data hardware bugs. Processor MMIO + Stale Data Vulnerabilities are a class of memory-mapped I/O (MMIO) + vulnerabilities that can expose data. The vulnerabilities require the + attacker to have access to MMIO. + See also + <file:Documentation/admin-guide/hw-vuln/processor_mmio_stale_data.rst> endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -393,7 +393,8 @@ enum mmio_mitigations { };/* Default mitigation for Processor MMIO Stale Data vulnerabilities */ -static enum mmio_mitigations mmio_mitigation__ro_after_init =MMIO_MITIGATION_VERW ; +static enum mmio_mitigations mmio_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_MMIO_STALE_DATA ) ?MMIO_MITIGATION_VERW :MMIO_MITIGATION_OFF ;static bool mmio_nosmt__ro_after_init = false;static const char *const mmio_strings[] = {
PATCH v4 4/11 x86/bugs: Add a separate config for L1TF
In reply to Breno LeitaoCurrently, 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 L1TF CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 10 ++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-)
arch/x86/Kconfig +10 -0
@@ -2682,6 +2682,16 @@ config MITIGATION_MMIO_STALE_DATA attacker to have access to MMIO. See also <file:Documentation/admin-guide/hw-vuln/processor_mmio_stale_data.rst> + +config MITIGATION_L1TF + bool "Mitigate L1 Terminal Fault (L1TF) hardware bug" + depends on CPU_SUP_INTEL + default y + help + Mitigate L1 Terminal Fault (L1TF) hardware bug. L1 Terminal Fault is a + hardware vulnerability which allows unprivileged speculative access to data + available in the Level 1 Data Cache. + See <file:Documentation/admin-guide/hw-vuln/l1tf.rst endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -2374,7 +2374,8 @@ EXPORT_SYMBOL_GPL(itlb_multihit_kvm_mitigation);#define pr_fmt (fmt) "L1TF: " fmt/* Default mitigation for L1TF-affected CPUs */ -enum l1tf_mitigations l1tf_mitigation__ro_after_init =L1TF_MITIGATION_FLUSH ; +enum l1tf_mitigations l1tf_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_L1TF ) ?L1TF_MITIGATION_FLUSH :L1TF_MITIGATION_OFF ;#if IS_ENABLED (CONFIG_KVM_INTEL )EXPORT_SYMBOL_GPL (l1tf_mitigation);#endif
Signature · 1 line
2.43.0
[tip: x86/bugs] x86/bugs: Add a separate config for L1TF
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 3a4ee4ff819b2bd09f1eca4a90846f2be449bd51 Gitweb: https://git.kernel.org/tip/3a4ee4ff819b2bd09f1eca4a90846f2be449bd51 Author: Breno Leitao <[email protected]> AuthorDate: Mon, 29 Jul 2024 09:40:52 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 30 Jul 2024 11:23:17 +02:00
x86/bugs: Add a separate config for L1TF
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 L1TF CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 10 ++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-)
arch/x86/Kconfig +10 -0
@@ -2682,6 +2682,16 @@ config MITIGATION_MMIO_STALE_DATA attacker to have access to MMIO. See also <file:Documentation/admin-guide/hw-vuln/processor_mmio_stale_data.rst> + +config MITIGATION_L1TF + bool "Mitigate L1 Terminal Fault (L1TF) hardware bug" + depends on CPU_SUP_INTEL + default y + help + Mitigate L1 Terminal Fault (L1TF) hardware bug. L1 Terminal Fault is a + hardware vulnerability which allows unprivileged speculative access to data + available in the Level 1 Data Cache. + See <file:Documentation/admin-guide/hw-vuln/l1tf.rst endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -2374,7 +2374,8 @@ EXPORT_SYMBOL_GPL(itlb_multihit_kvm_mitigation);#define pr_fmt (fmt) "L1TF: " fmt/* Default mitigation for L1TF-affected CPUs */ -enum l1tf_mitigations l1tf_mitigation__ro_after_init =L1TF_MITIGATION_FLUSH ; +enum l1tf_mitigations l1tf_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_L1TF ) ?L1TF_MITIGATION_FLUSH :L1TF_MITIGATION_OFF ;#if IS_ENABLED (CONFIG_KVM_INTEL )EXPORT_SYMBOL_GPL (l1tf_mitigation);#endif
PATCH v4 5/11 x86/bugs: Add a separate config for RETBLEED
In reply to Breno LeitaoCurrently, 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 RETBLEED CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 13 +++++++++++++ arch/x86/kernel/cpu/bugs.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-)
arch/x86/Kconfig +13 -0
@@ -2692,6 +2692,19 @@ config MITIGATION_L1TF hardware vulnerability which allows unprivileged speculative access to data available in the Level 1 Data Cache. See <file:Documentation/admin-guide/hw-vuln/l1tf.rst + +config MITIGATION_RETBLEED + bool "Mitigate RETBleed hardware bug" + depends on (CPU_SUP_INTEL && MITIGATION_SPECTRE_V2) || MITIGATION_UNRET_ENTRY || MITIGATION_IBPB_ENTRY + default y + help + Enable mitigation for RETBleed (Arbitrary Speculative Code Execution + with Return Instructions) vulnerability. RETBleed is a speculative + execution attack which takes advantage of microarchitectural behavior + in many modern microprocessors, similar to Spectre v2. An + unprivileged attacker can use these flaws to bypass conventional + memory security restrictions to gain read access to privileged memory + that would otherwise be inaccessible. endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -989,7 +989,7 @@ static const char * const retbleed_strings[] = {static enum retbleed_mitigation retbleed_mitigation__ro_after_init =RETBLEED_MITIGATION_NONE ;static enum retbleed_mitigation_cmd retbleed_cmd__ro_after_init = -RETBLEED_CMD_AUTO ; +IS_ENABLED (CONFIG_MITIGATION_RETBLEED ) ?RETBLEED_CMD_AUTO :RETBLEED_CMD_OFF ;static int __ro_after_init retbleed_nosmt = false;
Signature · 1 line
2.43.0
[tip: x86/bugs] x86/bugs: Add a separate config for RETBLEED
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 894e28857c112c5a31517b3837b507f1dcbe9da5 Gitweb: https://git.kernel.org/tip/894e28857c112c5a31517b3837b507f1dcbe9da5 Author: Breno Leitao <[email protected]> AuthorDate: Mon, 29 Jul 2024 09:40:53 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 30 Jul 2024 14:48:54 +02:00
x86/bugs: Add a separate config for RETBLEED
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 RETBLEED CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 13 +++++++++++++ arch/x86/kernel/cpu/bugs.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-)
arch/x86/Kconfig +13 -0
@@ -2692,6 +2692,19 @@ config MITIGATION_L1TF hardware vulnerability which allows unprivileged speculative access to data available in the Level 1 Data Cache. See <file:Documentation/admin-guide/hw-vuln/l1tf.rst + +config MITIGATION_RETBLEED + bool "Mitigate RETBleed hardware bug" + depends on (CPU_SUP_INTEL && MITIGATION_SPECTRE_V2) || MITIGATION_UNRET_ENTRY || MITIGATION_IBPB_ENTRY + default y + help + Enable mitigation for RETBleed (Arbitrary Speculative Code Execution + with Return Instructions) vulnerability. RETBleed is a speculative + execution attack which takes advantage of microarchitectural behavior + in many modern microprocessors, similar to Spectre v2. An + unprivileged attacker can use these flaws to bypass conventional + memory security restrictions to gain read access to privileged memory + that would otherwise be inaccessible. endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -989,7 +989,7 @@ static const char * const retbleed_strings[] = {static enum retbleed_mitigation retbleed_mitigation__ro_after_init =RETBLEED_MITIGATION_NONE ;static enum retbleed_mitigation_cmd retbleed_cmd__ro_after_init = -RETBLEED_CMD_AUTO ; +IS_ENABLED (CONFIG_MITIGATION_RETBLEED ) ?RETBLEED_CMD_AUTO :RETBLEED_CMD_OFF ;static int __ro_after_init retbleed_nosmt = false;
PATCH v4 6/11 x86/bugs: Add a separate config for Spectre v1
In reply to Breno LeitaoCurrently, 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.
--- arch/x86/Kconfig | 10 ++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-)
arch/x86/Kconfig +10 -0
@@ -2705,6 +2705,16 @@ config MITIGATION_RETBLEED unprivileged attacker can use these flaws to bypass conventional memory security restrictions to gain read access to privileged memory that would otherwise be inaccessible. + +config MITIGATION_SPECTRE_V1 + bool "Mitigate SPECTRE V1 hardware bug" + default y + help + Enable mitigation for Spectre V1 (Bounds Check Bypass). Spectre V1 is a + class of side channel attacks that takes advantage of speculative + execution that bypasses conditional branch instructions used for + memory access bounds check. + See also <file:Documentation/admin-guide/hw-vuln/spectre.rst> endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -874,7 +874,8 @@ enum spectre_v1_mitigation { };static enum spectre_v1_mitigation spectre_v1_mitigation__ro_after_init = -SPECTRE_V1_MITIGATION_AUTO ; +IS_ENABLED (CONFIG_MITIGATION_SPECTRE_V1 ) ? +SPECTRE_V1_MITIGATION_AUTO :SPECTRE_V1_MITIGATION_NONE ;static const char *const spectre_v1_strings[] = { [SPECTRE_V1_MITIGATION_NONE ] ="Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers" ,
Signature · 1 line
2.43.0
[tip: x86/bugs] x86/bugs: Add a separate config for Spectre v1
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: ca01c0d8d03089f81c713aec0c63d359bc0f6796 Gitweb: https://git.kernel.org/tip/ca01c0d8d03089f81c713aec0c63d359bc0f6796 Author: Breno Leitao <[email protected]> AuthorDate: Mon, 29 Jul 2024 09:40:54 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 30 Jul 2024 14:49:28 +02:00
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.
--- arch/x86/Kconfig | 10 ++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-)
arch/x86/Kconfig +10 -0
@@ -2705,6 +2705,16 @@ config MITIGATION_RETBLEED unprivileged attacker can use these flaws to bypass conventional memory security restrictions to gain read access to privileged memory that would otherwise be inaccessible. + +config MITIGATION_SPECTRE_V1 + bool "Mitigate SPECTRE V1 hardware bug" + default y + help + Enable mitigation for Spectre V1 (Bounds Check Bypass). Spectre V1 is a + class of side channel attacks that takes advantage of speculative + execution that bypasses conditional branch instructions used for + memory access bounds check. + See also <file:Documentation/admin-guide/hw-vuln/spectre.rst> endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -874,7 +874,8 @@ enum spectre_v1_mitigation { };static enum spectre_v1_mitigation spectre_v1_mitigation__ro_after_init = -SPECTRE_V1_MITIGATION_AUTO ; +IS_ENABLED (CONFIG_MITIGATION_SPECTRE_V1 ) ? +SPECTRE_V1_MITIGATION_AUTO :SPECTRE_V1_MITIGATION_NONE ;static const char *const spectre_v1_strings[] = { [SPECTRE_V1_MITIGATION_NONE ] ="Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers" ,
PATCH v4 7/11 x86/bugs: Add a separate config for SRBDS
In reply to Breno LeitaoCurrently, 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 SRBDS CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 14 ++++++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-)
arch/x86/Kconfig +14 -0
@@ -2715,6 +2715,20 @@ config MITIGATION_SPECTRE_V1 execution that bypasses conditional branch instructions used for memory access bounds check. See also <file:Documentation/admin-guide/hw-vuln/spectre.rst> + +config MITIGATION_SRBDS + bool "Mitigate Special Register Buffer Data Sampling (SRBDS) hardware bug" + depends on CPU_SUP_INTEL + default y + help + Enable mitigation for Special Register Buffer Data Sampling (SRBDS). + SRBDS is a hardware vulnerability that allows Microarchitectural Data + Sampling (MDS) techniques to infer values returned from special + register accesses. An unprivileged user can extract values returned + from RDRAND and RDSEED executed on another core or sibling thread + using MDS techniques. + See also + <file:Documentation/admin-guide/hw-vuln/special-register-buffer-data-sampling.rst> endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -608,7 +608,8 @@ enum srbds_mitigations { SRBDS_MITIGATION_HYPERVISOR, }; -static enum srbds_mitigations srbds_mitigation__ro_after_init =SRBDS_MITIGATION_FULL ; +static enum srbds_mitigations srbds_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_SRBDS ) ?SRBDS_MITIGATION_FULL :SRBDS_MITIGATION_OFF ;static const char *const srbds_strings[] = { [SRBDS_MITIGATION_OFF ] ="Vulnerable" ,
Signature · 1 line
2.43.0
[tip: x86/bugs] x86/bugs: Add a separate config for SRBDS
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: a0b02e3fe3661ea20df4d13adfc94b6affdcc466 Gitweb: https://git.kernel.org/tip/a0b02e3fe3661ea20df4d13adfc94b6affdcc466 Author: Breno Leitao <[email protected]> AuthorDate: Mon, 29 Jul 2024 09:40:55 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 30 Jul 2024 14:49:53 +02:00
x86/bugs: Add a separate config for SRBDS
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 SRBDS CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 14 ++++++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-)
arch/x86/Kconfig +14 -0
@@ -2715,6 +2715,20 @@ config MITIGATION_SPECTRE_V1 execution that bypasses conditional branch instructions used for memory access bounds check. See also <file:Documentation/admin-guide/hw-vuln/spectre.rst> + +config MITIGATION_SRBDS + bool "Mitigate Special Register Buffer Data Sampling (SRBDS) hardware bug" + depends on CPU_SUP_INTEL + default y + help + Enable mitigation for Special Register Buffer Data Sampling (SRBDS). + SRBDS is a hardware vulnerability that allows Microarchitectural Data + Sampling (MDS) techniques to infer values returned from special + register accesses. An unprivileged user can extract values returned + from RDRAND and RDSEED executed on another core or sibling thread + using MDS techniques. + See also + <file:Documentation/admin-guide/hw-vuln/special-register-buffer-data-sampling.rst> endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -608,7 +608,8 @@ enum srbds_mitigations { SRBDS_MITIGATION_HYPERVISOR, }; -static enum srbds_mitigations srbds_mitigation__ro_after_init =SRBDS_MITIGATION_FULL ; +static enum srbds_mitigations srbds_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_SRBDS ) ?SRBDS_MITIGATION_FULL :SRBDS_MITIGATION_OFF ;static const char *const srbds_strings[] = { [SRBDS_MITIGATION_OFF ] ="Vulnerable" ,
PATCH v4 8/11 x86/bugs: Add a separate config for Spectre V2
In reply to Breno LeitaoCurrently, 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 V2 CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 12 ++++++++++++ arch/x86/kernel/cpu/bugs.c | 9 +++++---- 2 files changed, 17 insertions(+), 4 deletions(-)
arch/x86/Kconfig +12 -0
@@ -2716,6 +2716,18 @@ config MITIGATION_SPECTRE_V1 memory access bounds check. See also <file:Documentation/admin-guide/hw-vuln/spectre.rst> +config MITIGATION_SPECTRE_V2 + bool "Mitigate SPECTRE V2 hardware bug" + default y + help + Enable mitigation for Spectre V2 (Branch Target Injection). Spectre + V2 is a class of side channel attacks that takes advantage of + indirect branch predictors inside the processor. In Spectre variant 2 + attacks, the attacker can steer speculative indirect branches in the + victim to gadget code by poisoning the branch target buffer of a CPU + used for predicting indirect branch addresses. + See also <file:Documentation/admin-guide/hw-vuln/spectre.rst> + config MITIGATION_SRBDS bool "Mitigate Special Register Buffer Data Sampling (SRBDS) hardware bug" depends on CPU_SUP_INTEL
arch/x86/kernel/cpu/bugs.c +5 -4
@@ -1452,17 +1452,18 @@ static void __init spec_v2_print_cond(const char *reason, bool secure)static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline (void ) { -enum spectre_v2_mitigation_cmd cmd =SPECTRE_V2_CMD_AUTO ; +enum spectre_v2_mitigation_cmd cmd;char arg[20 ];int ret, i; + cmd =IS_ENABLED (CONFIG_MITIGATION_SPECTRE_V2 ) ?SPECTRE_V2_CMD_AUTO :SPECTRE_V2_CMD_NONE ;if (cmdline_find_option_bool (boot_command_line,"nospectre_v2" ) ||cpu_mitigations_off ())return SPECTRE_V2_CMD_NONE ; ret =cmdline_find_option (boot_command_line,"spectre_v2" , arg,sizeof (arg));if (ret <0 ) -return SPECTRE_V2_CMD_AUTO ; +return cmd;for (i =0 ; i <ARRAY_SIZE (mitigation_options); i++) {if (!match_option (arg, ret, mitigation_options[i].option))
@@ -1472,8 +1473,8 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) }if (i >=ARRAY_SIZE (mitigation_options)) { -pr_err ("unknown option (%s). Switching to AUTO select\n" , arg); -return SPECTRE_V2_CMD_AUTO ; +pr_err ("unknown option (%s). Switching to default mode\n" , arg); +return cmd; } if ((cmd == SPECTRE_V2_CMD_RETPOLINE ||
Signature · 1 line
2.43.0
[tip: x86/bugs] x86/bugs: Add a separate config for Spectre V2
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 72c70f480a70695523f984651d5da766b862c712 Gitweb: https://git.kernel.org/tip/72c70f480a70695523f984651d5da766b862c712 Author: Breno Leitao <[email protected]> AuthorDate: Mon, 29 Jul 2024 09:40:56 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 30 Jul 2024 14:51:11 +02:00
x86/bugs: Add a separate config for Spectre V2
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 V2 CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 12 ++++++++++++ arch/x86/kernel/cpu/bugs.c | 9 +++++---- 2 files changed, 17 insertions(+), 4 deletions(-)
arch/x86/Kconfig +12 -0
@@ -2716,6 +2716,18 @@ config MITIGATION_SPECTRE_V1 memory access bounds check. See also <file:Documentation/admin-guide/hw-vuln/spectre.rst> +config MITIGATION_SPECTRE_V2 + bool "Mitigate SPECTRE V2 hardware bug" + default y + help + Enable mitigation for Spectre V2 (Branch Target Injection). Spectre + V2 is a class of side channel attacks that takes advantage of + indirect branch predictors inside the processor. In Spectre variant 2 + attacks, the attacker can steer speculative indirect branches in the + victim to gadget code by poisoning the branch target buffer of a CPU + used for predicting indirect branch addresses. + See also <file:Documentation/admin-guide/hw-vuln/spectre.rst> + config MITIGATION_SRBDS bool "Mitigate Special Register Buffer Data Sampling (SRBDS) hardware bug" depends on CPU_SUP_INTEL
arch/x86/kernel/cpu/bugs.c +5 -4
@@ -1452,17 +1452,18 @@ static void __init spec_v2_print_cond(const char *reason, bool secure)static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline (void ) { -enum spectre_v2_mitigation_cmd cmd =SPECTRE_V2_CMD_AUTO ; +enum spectre_v2_mitigation_cmd cmd;char arg[20 ];int ret, i; + cmd =IS_ENABLED (CONFIG_MITIGATION_SPECTRE_V2 ) ?SPECTRE_V2_CMD_AUTO :SPECTRE_V2_CMD_NONE ;if (cmdline_find_option_bool (boot_command_line,"nospectre_v2" ) ||cpu_mitigations_off ())return SPECTRE_V2_CMD_NONE ; ret =cmdline_find_option (boot_command_line,"spectre_v2" , arg,sizeof (arg));if (ret <0 ) -return SPECTRE_V2_CMD_AUTO ; +return cmd;for (i =0 ; i <ARRAY_SIZE (mitigation_options); i++) {if (!match_option (arg, ret, mitigation_options[i].option))
@@ -1472,8 +1473,8 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) }if (i >=ARRAY_SIZE (mitigation_options)) { -pr_err ("unknown option (%s). Switching to AUTO select\n" , arg); -return SPECTRE_V2_CMD_AUTO ; +pr_err ("unknown option (%s). Switching to default mode\n" , arg); +return cmd; } if ((cmd == SPECTRE_V2_CMD_RETPOLINE ||
PATCH v4 9/11 x86/bugs: Add a separate config for SSB
In reply to Breno LeitaoCurrently, 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 SSB CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 10 ++++++++++ arch/x86/kernel/cpu/bugs.c | 10 ++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
arch/x86/Kconfig +10 -0
@@ -2741,6 +2741,16 @@ config MITIGATION_SRBDS using MDS techniques. See also <file:Documentation/admin-guide/hw-vuln/special-register-buffer-data-sampling.rst> + +config MITIGATION_SSB + bool "Mitigate Speculative Store Bypass (SSB) hardware bug" + default y + help + Enable mitigation for Speculative Store Bypass (SSB). SSB is a + hardware security vulnerability and its exploitation takes advantage + of speculative execution in a similar way to the Meltdown and Spectre + security vulnerabilities. + endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +6 -4
@@ -2027,10 +2027,12 @@ static const struct {static enum ssb_mitigation_cmd __init ssb_parse_cmdline (void ) { -enum ssb_mitigation_cmd cmd =SPEC_STORE_BYPASS_CMD_AUTO ; +enum ssb_mitigation_cmd cmd;char arg[20 ];int ret, i; + cmd =IS_ENABLED (CONFIG_MITIGATION_SSB ) ? +SPEC_STORE_BYPASS_CMD_AUTO :SPEC_STORE_BYPASS_CMD_NONE ;if (cmdline_find_option_bool (boot_command_line,"nospec_store_bypass_disable" ) ||cpu_mitigations_off ()) {return SPEC_STORE_BYPASS_CMD_NONE ;
@@ -2038,7 +2040,7 @@ static enum ssb_mitigation_cmd __init ssb_parse_cmdline(void) ret =cmdline_find_option (boot_command_line,"spec_store_bypass_disable" , arg,sizeof (arg));if (ret <0 ) -return SPEC_STORE_BYPASS_CMD_AUTO ; +return cmd;for (i =0 ; i <ARRAY_SIZE (ssb_mitigation_options); i++) {if (!match_option (arg, ret, ssb_mitigation_options[i].option))
@@ -2049,8 +2051,8 @@ static enum ssb_mitigation_cmd __init ssb_parse_cmdline(void) }if (i >=ARRAY_SIZE (ssb_mitigation_options)) { -pr_err ("unknown option (%s). Switching to AUTO select\n" , arg); -return SPEC_STORE_BYPASS_CMD_AUTO ; +pr_err ("unknown option (%s). Switching to default mode\n" , arg); +return cmd; } }
Signature · 1 line
2.43.0
[tip: x86/bugs] x86/bugs: Add a separate config for SSB
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: b908cdab061a5ead51d5e1731ca9c1b26699a9bb Gitweb: https://git.kernel.org/tip/b908cdab061a5ead51d5e1731ca9c1b26699a9bb Author: Breno Leitao <[email protected]> AuthorDate: Mon, 29 Jul 2024 09:40:57 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 30 Jul 2024 14:51:45 +02:00
x86/bugs: Add a separate config for SSB
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 SSB CPU mitigation under CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable it at compilation time.
--- arch/x86/Kconfig | 10 ++++++++++ arch/x86/kernel/cpu/bugs.c | 10 ++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
arch/x86/Kconfig +10 -0
@@ -2741,6 +2741,16 @@ config MITIGATION_SRBDS using MDS techniques. See also <file:Documentation/admin-guide/hw-vuln/special-register-buffer-data-sampling.rst> + +config MITIGATION_SSB + bool "Mitigate Speculative Store Bypass (SSB) hardware bug" + default y + help + Enable mitigation for Speculative Store Bypass (SSB). SSB is a + hardware security vulnerability and its exploitation takes advantage + of speculative execution in a similar way to the Meltdown and Spectre + security vulnerabilities. + endif config ARCH_HAS_ADD_PAGES
arch/x86/kernel/cpu/bugs.c +6 -4
@@ -2027,10 +2027,12 @@ static const struct {static enum ssb_mitigation_cmd __init ssb_parse_cmdline (void ) { -enum ssb_mitigation_cmd cmd =SPEC_STORE_BYPASS_CMD_AUTO ; +enum ssb_mitigation_cmd cmd;char arg[20 ];int ret, i; + cmd =IS_ENABLED (CONFIG_MITIGATION_SSB ) ? +SPEC_STORE_BYPASS_CMD_AUTO :SPEC_STORE_BYPASS_CMD_NONE ;if (cmdline_find_option_bool (boot_command_line,"nospec_store_bypass_disable" ) ||cpu_mitigations_off ()) {return SPEC_STORE_BYPASS_CMD_NONE ;
@@ -2038,7 +2040,7 @@ static enum ssb_mitigation_cmd __init ssb_parse_cmdline(void) ret =cmdline_find_option (boot_command_line,"spec_store_bypass_disable" , arg,sizeof (arg));if (ret <0 ) -return SPEC_STORE_BYPASS_CMD_AUTO ; +return cmd;for (i =0 ; i <ARRAY_SIZE (ssb_mitigation_options); i++) {if (!match_option (arg, ret, ssb_mitigation_options[i].option))
@@ -2049,8 +2051,8 @@ static enum ssb_mitigation_cmd __init ssb_parse_cmdline(void) }if (i >=ARRAY_SIZE (ssb_mitigation_options)) { -pr_err ("unknown option (%s). Switching to AUTO select\n" , arg); -return SPEC_STORE_BYPASS_CMD_AUTO ; +pr_err ("unknown option (%s). Switching to default mode\n" , arg); +return cmd; } }
PATCH v4 10/11 x86/bugs: Remove GDS Force Kconfig option
In reply to Breno LeitaoRemove the MITIGATION_GDS_FORCE Kconfig option, which aggressively disables AVX as a mitigation for Gather Data Sampling (GDS) vulnerabilities. This option is not widely used by distros.
While removing the Kconfig option, retain the runtime configuration ability through the gather_data_sampling=force kernel parameter. This allows users to still enable this aggressive mitigation if needed, without baking it into the kernel configuration.
This change simplifies the kernel configuration while maintaining flexibility for runtime mitigation choices.
--- arch/x86/Kconfig | 19 ------------------- arch/x86/kernel/cpu/bugs.c | 4 ---- 2 files changed, 23 deletions(-)
arch/x86/Kconfig +0 -19
@@ -2610,25 +2610,6 @@ config MITIGATION_SLS against straight line speculation. The kernel image might be slightly larger. -config MITIGATION_GDS_FORCE - bool "Force GDS Mitigation" - depends on CPU_SUP_INTEL - default n - help - Gather Data Sampling (GDS) is a hardware vulnerability which allows - unprivileged speculative access to data which was previously stored in - vector registers. - - This option is equivalent to setting gather_data_sampling=force on the - command line. The microcode mitigation is used if present, otherwise - AVX is disabled as a mitigation. On affected systems that are missing - the microcode any userspace code that unconditionally uses AVX will - break with this option set. - - Setting this option on systems not vulnerable to GDS has no effect. - - If in doubt, say N. - config MITIGATION_RFDS bool "RFDS Mitigation" depends on CPU_SUP_INTEL
arch/x86/kernel/cpu/bugs.c +0 -4
@@ -735,11 +735,7 @@ enum gds_mitigations { GDS_MITIGATION_HYPERVISOR, }; -#if IS_ENABLED (CONFIG_MITIGATION_GDS_FORCE ) -static enum gds_mitigations gds_mitigation__ro_after_init =GDS_MITIGATION_FORCE ; -#else static enum gds_mitigations gds_mitigation__ro_after_init =GDS_MITIGATION_FULL ; -#endif static const char *const gds_strings[] = { [GDS_MITIGATION_OFF ] ="Vulnerable" ,
Signature · 1 line
2.43.0
Re: [PATCH v4 10/11] x86/bugs: Remove GDS Force Kconfig option
Quoted 9 lines · Breno Leitao
Remove the
MITIGATION_GDS_FORCEKconfigoption, which aggressively disables AVX as a mitigation for Gather Data Sampling (GDS) vulnerabilities. This option is not widely used by distros.While removing the
Kconfigoption, retain the runtime configuration ability through thegather_data_sampling=forcekernel parameter. This allows users to still enable this aggressive mitigation if needed, without baking it into the kernel configuration.
Quoted 6 lines
This change simplifies the kernel configuration while maintaining flexibility for runtime mitigation choices.
Cc Daniel Sneddon <[email protected]>Suggested-by Borislav Petkov <[email protected]>Signed-off-by Breno Leitao <[email protected]>
LGTM. Feel free to add a Reviewed-by from me.
[tip: x86/bugs] x86/bugs: Remove GDS Force Kconfig option
In reply to Breno LeitaoThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 03267a534bb388acdd2ee685101084d144e8384c Gitweb: https://git.kernel.org/tip/03267a534bb388acdd2ee685101084d144e8384c Author: Breno Leitao <[email protected]> AuthorDate: Mon, 29 Jul 2024 09:40:58 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 30 Jul 2024 14:53:15 +02:00
x86/bugs: Remove GDS Force Kconfig option
Remove the MITIGATION_GDS_FORCE Kconfig option, which aggressively disables AVX as a mitigation for Gather Data Sampling (GDS) vulnerabilities. This option is not widely used by distros.
While removing the Kconfig option, retain the runtime configuration ability through the gather_data_sampling=force kernel parameter. This allows users to still enable this aggressive mitigation if needed, without baking it into the kernel configuration.
Simplify the kernel configuration while maintaining flexibility for runtime mitigation choices.
--- arch/x86/Kconfig | 19 ------------------- arch/x86/kernel/cpu/bugs.c | 4 ---- 2 files changed, 23 deletions(-)
arch/x86/Kconfig +0 -19
@@ -2610,25 +2610,6 @@ config MITIGATION_SLS against straight line speculation. The kernel image might be slightly larger. -config MITIGATION_GDS_FORCE - bool "Force GDS Mitigation" - depends on CPU_SUP_INTEL - default n - help - Gather Data Sampling (GDS) is a hardware vulnerability which allows - unprivileged speculative access to data which was previously stored in - vector registers. - - This option is equivalent to setting gather_data_sampling=force on the - command line. The microcode mitigation is used if present, otherwise - AVX is disabled as a mitigation. On affected systems that are missing - the microcode any userspace code that unconditionally uses AVX will - break with this option set. - - Setting this option on systems not vulnerable to GDS has no effect. - - If in doubt, say N. - config MITIGATION_RFDS bool "RFDS Mitigation" depends on CPU_SUP_INTEL
arch/x86/kernel/cpu/bugs.c +0 -4
@@ -735,11 +735,7 @@ enum gds_mitigations { GDS_MITIGATION_HYPERVISOR, }; -#if IS_ENABLED (CONFIG_MITIGATION_GDS_FORCE ) -static enum gds_mitigations gds_mitigation__ro_after_init =GDS_MITIGATION_FORCE ; -#else static enum gds_mitigations gds_mitigation__ro_after_init =GDS_MITIGATION_FULL ; -#endif static const char *const gds_strings[] = { [GDS_MITIGATION_OFF ] ="Vulnerable" ,
PATCH v4 11/11 x86/bugs: Add a separate config for GDS
In reply to Breno LeitaoCurrently, 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 a new kernel config that allows GDS to be completely disabled, similarly to the "gather_data_sampling=off" or "mitigations=off" kernel command-line.
Now, there are two options for GDS mitigation:
* CONFIG_MITIGATION_GDS=n -> Mitigation disabled (New)
* CONFIG_MITIGATION_GDS=y -> Mitigation enabled (GDS_MITIGATION_FULL)
--- arch/x86/Kconfig | 10 ++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-)
arch/x86/Kconfig +10 -0
@@ -2610,6 +2610,16 @@ config MITIGATION_SLS against straight line speculation. The kernel image might be slightly larger. +config MITIGATION_GDS + bool "Mitigate Gather Data Sampling" + depends on CPU_SUP_INTEL + default y + help + Enable mitigation for Gather Data Sampling (GDS). GDS is a hardware + vulnerability which allows unprivileged speculative access to data + which was previously stored in vector registers. The attacker uses gather + instructions to infer the stale vector register data. + config MITIGATION_RFDS bool "RFDS Mitigation" depends on CPU_SUP_INTEL
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -735,7 +735,8 @@ enum gds_mitigations { GDS_MITIGATION_HYPERVISOR, }; -static enum gds_mitigations gds_mitigation__ro_after_init =GDS_MITIGATION_FULL ; +static enum gds_mitigations gds_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_GDS ) ?GDS_MITIGATION_FULL :GDS_MITIGATION_OFF ;static const char *const gds_strings[] = { [GDS_MITIGATION_OFF ] ="Vulnerable" ,
Signature · 1 line
2.43.0
[tip: x86/bugs] x86/bugs: Add a separate config for GDS
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 225f2bd064c32397acfe3d9dfd9a2b3bc6d64fd7 Gitweb: https://git.kernel.org/tip/225f2bd064c32397acfe3d9dfd9a2b3bc6d64fd7 Author: Breno Leitao <[email protected]> AuthorDate: Mon, 29 Jul 2024 09:40:59 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 30 Jul 2024 14:54:15 +02:00
x86/bugs: Add a separate config for GDS
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 a new kernel config that allows GDS to be completely disabled, similarly to the "gather_data_sampling=off" or "mitigations=off" kernel command-line.
Now, there are two options for GDS mitigation:
* CONFIG_MITIGATION_GDS=n -> Mitigation disabled (New)
* CONFIG_MITIGATION_GDS=y -> Mitigation enabled (GDS_MITIGATION_FULL)
--- arch/x86/Kconfig | 10 ++++++++++ arch/x86/kernel/cpu/bugs.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-)
arch/x86/Kconfig +10 -0
@@ -2610,6 +2610,16 @@ config MITIGATION_SLS against straight line speculation. The kernel image might be slightly larger. +config MITIGATION_GDS + bool "Mitigate Gather Data Sampling" + depends on CPU_SUP_INTEL + default y + help + Enable mitigation for Gather Data Sampling (GDS). GDS is a hardware + vulnerability which allows unprivileged speculative access to data + which was previously stored in vector registers. The attacker uses gather + instructions to infer the stale vector register data. + config MITIGATION_RFDS bool "RFDS Mitigation" depends on CPU_SUP_INTEL
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -735,7 +735,8 @@ enum gds_mitigations { GDS_MITIGATION_HYPERVISOR, }; -static enum gds_mitigations gds_mitigation__ro_after_init =GDS_MITIGATION_FULL ; +static enum gds_mitigations gds_mitigation__ro_after_init = +IS_ENABLED (CONFIG_MITIGATION_GDS ) ?GDS_MITIGATION_FULL :GDS_MITIGATION_OFF ;static const char *const gds_strings[] = { [GDS_MITIGATION_OFF ] ="Vulnerable" ,