Skip to content

Commit a4f05a6

Browse files
author
CKI KWF Bot
committed
Merge: x86/bugs: Attack vector controls and proactive bug fixes
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1547 JIRA: https://issues.redhat.com/browse/RHEL-119227 MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1547 Omitted-fix: 84dfce6 ("x86/bugs: Remove dead code which might prevent from building") Attack vector options [1] are designed to make it easier to select appropriate mitigations based on the usage of the system. While many users may not be intimately familiar with the details of these CPU vulnerabilities, they are likely better able to understand the intended usage of their system. As a result, unneeded mitigations may be disabled, allowing users to recoup more performance. New documentation is included with recommendations on what to consider when choosing which attack vectors to enable/disable. Attack vector options are chosen using the mitigations= command line. Attack vectors may be individually disabled such as 'mitigations=auto;no_user_kernel,no_user_user'. The 'mitigations=off' option is equivalent to disabling all attack vectors. 'mitigations=off' therefore disables all mitigations, unless bug-specific command line options are used to re-enable some. Note that this MR also contains some other proactive backports of fixes in mitigation or related code. [1] https://docs.kernel.org/next/admin-guide/hw-vuln/attack_vector_controls.html Signed-off-by: Waiman Long <longman@redhat.com> Approved-by: Phil Auld <pauld@redhat.com> Approved-by: Mark Langsdorf <mlangsdo@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents ec88929 + 5de09f0 commit a4f05a6

File tree

29 files changed

+1309
-457
lines changed

29 files changed

+1309
-457
lines changed

Documentation/ABI/testing/sysfs-devices-system-cpu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ What: /sys/devices/system/cpu/vulnerabilities
518518
/sys/devices/system/cpu/vulnerabilities/mds
519519
/sys/devices/system/cpu/vulnerabilities/meltdown
520520
/sys/devices/system/cpu/vulnerabilities/mmio_stale_data
521+
/sys/devices/system/cpu/vulnerabilities/old_microcode
521522
/sys/devices/system/cpu/vulnerabilities/reg_file_data_sampling
522523
/sys/devices/system/cpu/vulnerabilities/retbleed
523524
/sys/devices/system/cpu/vulnerabilities/spec_store_bypass
Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
Attack Vector Controls
4+
======================
5+
6+
Attack vector controls provide a simple method to configure only the mitigations
7+
for CPU vulnerabilities which are relevant given the intended use of a system.
8+
Administrators are encouraged to consider which attack vectors are relevant and
9+
disable all others in order to recoup system performance.
10+
11+
When new relevant CPU vulnerabilities are found, they will be added to these
12+
attack vector controls so administrators will likely not need to reconfigure
13+
their command line parameters as mitigations will continue to be correctly
14+
applied based on the chosen attack vector controls.
15+
16+
Attack Vectors
17+
--------------
18+
19+
There are 5 sets of attack-vector mitigations currently supported by the kernel:
20+
21+
#. :ref:`user_kernel`
22+
#. :ref:`user_user`
23+
#. :ref:`guest_host`
24+
#. :ref:`guest_guest`
25+
#. :ref:`smt`
26+
27+
To control the enabled attack vectors, see :ref:`cmdline`.
28+
29+
.. _user_kernel:
30+
31+
User-to-Kernel
32+
^^^^^^^^^^^^^^
33+
34+
The user-to-kernel attack vector involves a malicious userspace program
35+
attempting to leak kernel data into userspace by exploiting a CPU vulnerability.
36+
The kernel data involved might be limited to certain kernel memory, or include
37+
all memory in the system, depending on the vulnerability exploited.
38+
39+
If no untrusted userspace applications are being run, such as with single-user
40+
systems, consider disabling user-to-kernel mitigations.
41+
42+
Note that the CPU vulnerabilities mitigated by Linux have generally not been
43+
shown to be exploitable from browser-based sandboxes. User-to-kernel
44+
mitigations are therefore mostly relevant if unknown userspace applications may
45+
be run by untrusted users.
46+
47+
*user-to-kernel mitigations are enabled by default*
48+
49+
.. _user_user:
50+
51+
User-to-User
52+
^^^^^^^^^^^^
53+
54+
The user-to-user attack vector involves a malicious userspace program attempting
55+
to influence the behavior of another unsuspecting userspace program in order to
56+
exfiltrate data. The vulnerability of a userspace program is based on the
57+
program itself and the interfaces it provides.
58+
59+
If no untrusted userspace applications are being run, consider disabling
60+
user-to-user mitigations.
61+
62+
Note that because the Linux kernel contains a mapping of all physical memory,
63+
preventing a malicious userspace program from leaking data from another
64+
userspace program requires mitigating user-to-kernel attacks as well for
65+
complete protection.
66+
67+
*user-to-user mitigations are enabled by default*
68+
69+
.. _guest_host:
70+
71+
Guest-to-Host
72+
^^^^^^^^^^^^^
73+
74+
The guest-to-host attack vector involves a malicious VM attempting to leak
75+
hypervisor data into the VM. The data involved may be limited, or may
76+
potentially include all memory in the system, depending on the vulnerability
77+
exploited.
78+
79+
If no untrusted VMs are being run, consider disabling guest-to-host mitigations.
80+
81+
*guest-to-host mitigations are enabled by default if KVM support is present*
82+
83+
.. _guest_guest:
84+
85+
Guest-to-Guest
86+
^^^^^^^^^^^^^^
87+
88+
The guest-to-guest attack vector involves a malicious VM attempting to influence
89+
the behavior of another unsuspecting VM in order to exfiltrate data. The
90+
vulnerability of a VM is based on the code inside the VM itself and the
91+
interfaces it provides.
92+
93+
If no untrusted VMs, or only a single VM is being run, consider disabling
94+
guest-to-guest mitigations.
95+
96+
Similar to the user-to-user attack vector, preventing a malicious VM from
97+
leaking data from another VM requires mitigating guest-to-host attacks as well
98+
due to the Linux kernel phys map.
99+
100+
*guest-to-guest mitigations are enabled by default if KVM support is present*
101+
102+
.. _smt:
103+
104+
Cross-Thread
105+
^^^^^^^^^^^^
106+
107+
The cross-thread attack vector involves a malicious userspace program or
108+
malicious VM either observing or attempting to influence the behavior of code
109+
running on the SMT sibling thread in order to exfiltrate data.
110+
111+
Many cross-thread attacks can only be mitigated if SMT is disabled, which will
112+
result in reduced CPU core count and reduced performance.
113+
114+
If cross-thread mitigations are fully enabled ('auto,nosmt'), all mitigations
115+
for cross-thread attacks will be enabled. SMT may be disabled depending on
116+
which vulnerabilities are present in the CPU.
117+
118+
If cross-thread mitigations are partially enabled ('auto'), mitigations for
119+
cross-thread attacks will be enabled but SMT will not be disabled.
120+
121+
If cross-thread mitigations are disabled, no mitigations for cross-thread
122+
attacks will be enabled.
123+
124+
Cross-thread mitigation may not be required if core-scheduling or similar
125+
techniques are used to prevent untrusted workloads from running on SMT siblings.
126+
127+
*cross-thread mitigations default to partially enabled*
128+
129+
.. _cmdline:
130+
131+
Command Line Controls
132+
---------------------
133+
134+
Attack vectors are controlled through the mitigations= command line option. The
135+
value provided begins with a global option and then may optionally include one
136+
or more options to disable various attack vectors.
137+
138+
Format:
139+
| ``mitigations=[global]``
140+
| ``mitigations=[global],[attack vectors]``
141+
142+
Global options:
143+
144+
============ =============================================================
145+
Option Description
146+
============ =============================================================
147+
'off' All attack vectors disabled.
148+
'auto' All attack vectors enabled, partial cross-thread mitigations.
149+
'auto,nosmt' All attack vectors enabled, full cross-thread mitigations.
150+
============ =============================================================
151+
152+
Attack vector options:
153+
154+
================= =======================================
155+
Option Description
156+
================= =======================================
157+
'no_user_kernel' Disables user-to-kernel mitigations.
158+
'no_user_user' Disables user-to-user mitigations.
159+
'no_guest_host' Disables guest-to-host mitigations.
160+
'no_guest_guest' Disables guest-to-guest mitigations
161+
'no_cross_thread' Disables all cross-thread mitigations.
162+
================= =======================================
163+
164+
Multiple attack vector options may be specified in a comma-separated list. If
165+
the global option is not specified, it defaults to 'auto'. The global option
166+
'off' is equivalent to disabling all attack vectors.
167+
168+
Examples:
169+
| ``mitigations=auto,no_user_kernel``
170+
171+
Enable all attack vectors except user-to-kernel. Partial cross-thread
172+
mitigations.
173+
174+
| ``mitigations=auto,nosmt,no_guest_host,no_guest_guest``
175+
176+
Enable all attack vectors and cross-thread mitigations except for
177+
guest-to-host and guest-to-guest mitigations.
178+
179+
| ``mitigations=,no_cross_thread``
180+
181+
Enable all attack vectors but not cross-thread mitigations.
182+
183+
Interactions with command-line options
184+
--------------------------------------
185+
186+
Vulnerability-specific controls (e.g. "retbleed=off") take precedence over all
187+
attack vector controls. Mitigations for individual vulnerabilities may be
188+
turned on or off via their command-line options regardless of the attack vector
189+
controls.
190+
191+
Summary of attack-vector mitigations
192+
------------------------------------
193+
194+
When a vulnerability is mitigated due to an attack-vector control, the default
195+
mitigation option for that particular vulnerability is used. To use a different
196+
mitigation, please use the vulnerability-specific command line option.
197+
198+
The table below summarizes which vulnerabilities are mitigated when different
199+
attack vectors are enabled and assuming the CPU is vulnerable.
200+
201+
=============== ============== ============ ============= ============== ============ ========
202+
Vulnerability User-to-Kernel User-to-User Guest-to-Host Guest-to-Guest Cross-Thread Notes
203+
=============== ============== ============ ============= ============== ============ ========
204+
BHI X X
205+
ITS X X
206+
GDS X X X X * (Note 1)
207+
L1TF X X * (Note 2)
208+
MDS X X X X * (Note 2)
209+
MMIO X X X X * (Note 2)
210+
Meltdown X
211+
Retbleed X X * (Note 3)
212+
RFDS X X X X
213+
Spectre_v1 X
214+
Spectre_v2 X X
215+
Spectre_v2_user X X * (Note 1)
216+
SRBDS X X X X
217+
SRSO X X X X
218+
SSB X
219+
TAA X X X X * (Note 2)
220+
TSA X X X X
221+
VMSCAPE X
222+
=============== ============== ============ ============= ============== ============ ========
223+
224+
Notes:
225+
1 -- Can be mitigated without disabling SMT.
226+
227+
2 -- Disables SMT if cross-thread mitigations are fully enabled and the CPU
228+
is vulnerable
229+
230+
3 -- Disables SMT if cross-thread mitigations are fully enabled, the CPU is
231+
vulnerable, and STIBP is not supported
232+
233+
When an attack-vector is disabled, all mitigations for the vulnerabilities
234+
listed in the above table are disabled, unless mitigation is required for a
235+
different enabled attack-vector or a mitigation is explicitly selected via a
236+
vulnerability-specific command line option.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ are configurable at compile, boot or run time.
99
.. toctree::
1010
:maxdepth: 1
1111

12+
attack_vector_controls
1213
spectre
1314
l1tf
1415
mds
@@ -23,5 +24,6 @@ are configurable at compile, boot or run time.
2324
gather_data_sampling
2425
reg-file-data-sampling
2526
rsb
27+
old_microcode
2628
indirect-target-selection
2729
vmscape
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
=============
4+
Old Microcode
5+
=============
6+
7+
The kernel keeps a table of released microcode. Systems that had
8+
microcode older than this at boot will say "Vulnerable". This means
9+
that the system was vulnerable to some known CPU issue. It could be
10+
security or functional, the kernel does not know or care.
11+
12+
You should update the CPU microcode to mitigate any exposure. This is
13+
usually accomplished by updating the files in
14+
/lib/firmware/intel-ucode/ via normal distribution updates. Intel also
15+
distributes these files in a github repo:
16+
17+
https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files.git
18+
19+
Just like all the other hardware vulnerabilities, exposure is
20+
determined at boot. Runtime microcode updates do not change the status
21+
of this vulnerability.

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3588,6 +3588,10 @@
35883588
mmio_stale_data=full,nosmt [X86]
35893589
retbleed=auto,nosmt [X86]
35903590

3591+
[X86] After one of the above options, additionally
3592+
supports attack-vector based controls as documented in
3593+
Documentation/admin-guide/hw-vuln/attack_vector_controls.rst
3594+
35913595
mminit_loglevel=
35923596
[KNL,EARLY] When CONFIG_DEBUG_MEMORY_INIT is set, this
35933597
parameter allows control of the logging verbosity for

Documentation/arch/x86/cpuinfo.rst

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,18 @@ x86_cap/bug_flags[] arrays in kernel/cpu/capflags.c. The names in the
130130
resulting x86_cap/bug_flags[] are used to populate /proc/cpuinfo. The naming
131131
of flags in the x86_cap/bug_flags[] are as follows:
132132

133-
a: The name of the flag is from the string in X86_FEATURE_<name> by default.
134-
----------------------------------------------------------------------------
135-
By default, the flag <name> in /proc/cpuinfo is extracted from the respective
136-
X86_FEATURE_<name> in cpufeatures.h. For example, the flag "avx2" is from
137-
X86_FEATURE_AVX2.
138-
139-
b: The naming can be overridden.
140-
--------------------------------
133+
a: Flags do not appear by default in /proc/cpuinfo
134+
--------------------------------------------------
135+
136+
Feature flags are omitted by default from /proc/cpuinfo as it does not make
137+
sense for the feature to be exposed to userspace in most cases. For example,
138+
X86_FEATURE_ALWAYS is defined in cpufeatures.h but that flag is an internal
139+
kernel feature used in the alternative runtime patching functionality. So the
140+
flag does not appear in /proc/cpuinfo.
141+
142+
b: Specify a flag name if absolutely needed
143+
-------------------------------------------
144+
141145
If the comment on the line for the #define X86_FEATURE_* starts with a
142146
double-quote character (""), the string inside the double-quote characters
143147
will be the name of the flags. For example, the flag "sse4_1" comes from
@@ -148,14 +152,6 @@ needed. For instance, /proc/cpuinfo is a userspace interface and must remain
148152
constant. If, for some reason, the naming of X86_FEATURE_<name> changes, one
149153
shall override the new naming with the name already used in /proc/cpuinfo.
150154

151-
c: The naming override can be "", which means it will not appear in /proc/cpuinfo.
152-
----------------------------------------------------------------------------------
153-
The feature shall be omitted from /proc/cpuinfo if it does not make sense for
154-
the feature to be exposed to userspace. For example, X86_FEATURE_ALWAYS is
155-
defined in cpufeatures.h but that flag is an internal kernel feature used
156-
in the alternative runtime patching functionality. So, its name is overridden
157-
with "". Its flag will not appear in /proc/cpuinfo.
158-
159155
Flags are missing when one or more of these happen
160156
==================================================
161157

arch/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,4 +1743,7 @@ config ARCH_WANTS_PRE_LINK_VMLINUX
17431743
An architecture can select this if it provides arch/<arch>/tools/Makefile
17441744
with .arch.vmlinux.o target to be linked into vmlinux.
17451745

1746+
config ARCH_HAS_CPU_ATTACK_VECTORS
1747+
bool
1748+
17461749
endmenu

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ config X86
7373
select ARCH_ENABLE_SPLIT_PMD_PTLOCK if (PGTABLE_LEVELS > 2) && (X86_64 || X86_PAE)
7474
select ARCH_ENABLE_THP_MIGRATION if X86_64 && TRANSPARENT_HUGEPAGE
7575
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
76+
select ARCH_HAS_CPU_ATTACK_VECTORS if CPU_MITIGATIONS
7677
select ARCH_HAS_CACHE_LINE_SIZE
7778
select ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
7879
select ARCH_HAS_CPU_FINALIZE_INIT

arch/x86/include/asm/cpufeatures.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,9 @@
543543
#define X86_BUG_DIV0 X86_BUG( 1*32+ 1) /* "div0" AMD DIV0 speculation bug */
544544
#define X86_BUG_RFDS X86_BUG( 1*32+ 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */
545545
#define X86_BUG_BHI X86_BUG( 1*32+ 3) /* "bhi" CPU is affected by Branch History Injection */
546-
#define X86_BUG_IBPB_NO_RET X86_BUG( 1*32+ 4) /* "ibpb_no_ret" IBPB omits return target predictions */
546+
#define X86_BUG_IBPB_NO_RET X86_BUG( 1*32+ 4) /* "ibpb_no_ret" IBPB omits return target predictions */
547547
#define X86_BUG_SPECTRE_V2_USER X86_BUG( 1*32+ 5) /* "spectre_v2_user" CPU is affected by Spectre variant 2 attack between user processes */
548+
#define X86_BUG_OLD_MICROCODE X86_BUG( 1*32+ 6) /* "old_microcode" CPU has old microcode, it is surely vulnerable to something */
548549
#define X86_BUG_ITS X86_BUG( 1*32+ 7) /* "its" CPU is affected by Indirect Target Selection */
549550
#define X86_BUG_ITS_NATIVE_ONLY X86_BUG( 1*32+ 8) /* "its_native_only" CPU is affected by ITS, VMX is not affected */
550551
#define X86_BUG_TSA X86_BUG( 1*32+ 9) /* "tsa" CPU is affected by Transient Scheduler Attacks */

arch/x86/include/asm/nospec-branch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ enum spectre_v2_user_mitigation {
511511
/* The Speculative Store Bypass disable variants */
512512
enum ssb_mitigation {
513513
SPEC_STORE_BYPASS_NONE,
514+
SPEC_STORE_BYPASS_AUTO,
514515
SPEC_STORE_BYPASS_DISABLE,
515516
SPEC_STORE_BYPASS_PRCTL,
516517
SPEC_STORE_BYPASS_SECCOMP,

0 commit comments

Comments
 (0)