xref: /linux/Documentation/admin-guide/hw-vuln/indirect-target-selection.rst (revision 6f5bf947bab06f37ff931c359fd5770c4d9cbf87)
1*1ac116ceSPawan Gupta.. SPDX-License-Identifier: GPL-2.0
2*1ac116ceSPawan Gupta
3*1ac116ceSPawan GuptaIndirect Target Selection (ITS)
4*1ac116ceSPawan Gupta===============================
5*1ac116ceSPawan Gupta
6*1ac116ceSPawan GuptaITS is a vulnerability in some Intel CPUs that support Enhanced IBRS and were
7*1ac116ceSPawan Guptareleased before Alder Lake. ITS may allow an attacker to control the prediction
8*1ac116ceSPawan Guptaof indirect branches and RETs located in the lower half of a cacheline.
9*1ac116ceSPawan Gupta
10*1ac116ceSPawan GuptaITS is assigned CVE-2024-28956 with a CVSS score of 4.7 (Medium).
11*1ac116ceSPawan Gupta
12*1ac116ceSPawan GuptaScope of Impact
13*1ac116ceSPawan Gupta---------------
14*1ac116ceSPawan Gupta- **eIBRS Guest/Host Isolation**: Indirect branches in KVM/kernel may still be
15*1ac116ceSPawan Gupta  predicted with unintended target corresponding to a branch in the guest.
16*1ac116ceSPawan Gupta
17*1ac116ceSPawan Gupta- **Intra-Mode BTI**: In-kernel training such as through cBPF or other native
18*1ac116ceSPawan Gupta  gadgets.
19*1ac116ceSPawan Gupta
20*1ac116ceSPawan Gupta- **Indirect Branch Prediction Barrier (IBPB)**: After an IBPB, indirect
21*1ac116ceSPawan Gupta  branches may still be predicted with targets corresponding to direct branches
22*1ac116ceSPawan Gupta  executed prior to the IBPB. This is fixed by the IPU 2025.1 microcode, which
23*1ac116ceSPawan Gupta  should be available via distro updates. Alternatively microcode can be
24*1ac116ceSPawan Gupta  obtained from Intel's github repository [#f1]_.
25*1ac116ceSPawan Gupta
26*1ac116ceSPawan GuptaAffected CPUs
27*1ac116ceSPawan Gupta-------------
28*1ac116ceSPawan GuptaBelow is the list of ITS affected CPUs [#f2]_ [#f3]_:
29*1ac116ceSPawan Gupta
30*1ac116ceSPawan Gupta   ========================  ============  ====================  ===============
31*1ac116ceSPawan Gupta   Common name               Family_Model  eIBRS                 Intra-mode BTI
32*1ac116ceSPawan Gupta                                           Guest/Host Isolation
33*1ac116ceSPawan Gupta   ========================  ============  ====================  ===============
34*1ac116ceSPawan Gupta   SKYLAKE_X (step >= 6)     06_55H        Affected              Affected
35*1ac116ceSPawan Gupta   ICELAKE_X                 06_6AH        Not affected          Affected
36*1ac116ceSPawan Gupta   ICELAKE_D                 06_6CH        Not affected          Affected
37*1ac116ceSPawan Gupta   ICELAKE_L                 06_7EH        Not affected          Affected
38*1ac116ceSPawan Gupta   TIGERLAKE_L               06_8CH        Not affected          Affected
39*1ac116ceSPawan Gupta   TIGERLAKE                 06_8DH        Not affected          Affected
40*1ac116ceSPawan Gupta   KABYLAKE_L (step >= 12)   06_8EH        Affected              Affected
41*1ac116ceSPawan Gupta   KABYLAKE (step >= 13)     06_9EH        Affected              Affected
42*1ac116ceSPawan Gupta   COMETLAKE                 06_A5H        Affected              Affected
43*1ac116ceSPawan Gupta   COMETLAKE_L               06_A6H        Affected              Affected
44*1ac116ceSPawan Gupta   ROCKETLAKE                06_A7H        Not affected          Affected
45*1ac116ceSPawan Gupta   ========================  ============  ====================  ===============
46*1ac116ceSPawan Gupta
47*1ac116ceSPawan Gupta- All affected CPUs enumerate Enhanced IBRS feature.
48*1ac116ceSPawan Gupta- IBPB isolation is affected on all ITS affected CPUs, and need a microcode
49*1ac116ceSPawan Gupta  update for mitigation.
50*1ac116ceSPawan Gupta- None of the affected CPUs enumerate BHI_CTRL which was introduced in Golden
51*1ac116ceSPawan Gupta  Cove (Alder Lake and Sapphire Rapids). This can help guests to determine the
52*1ac116ceSPawan Gupta  host's affected status.
53*1ac116ceSPawan Gupta- Intel Atom CPUs are not affected by ITS.
54*1ac116ceSPawan Gupta
55*1ac116ceSPawan GuptaMitigation
56*1ac116ceSPawan Gupta----------
57*1ac116ceSPawan GuptaAs only the indirect branches and RETs that have their last byte of instruction
58*1ac116ceSPawan Guptain the lower half of the cacheline are vulnerable to ITS, the basic idea behind
59*1ac116ceSPawan Guptathe mitigation is to not allow indirect branches in the lower half.
60*1ac116ceSPawan Gupta
61*1ac116ceSPawan GuptaThis is achieved by relying on existing retpoline support in the kernel, and in
62*1ac116ceSPawan Guptacompilers. ITS-vulnerable retpoline sites are runtime patched to point to newly
63*1ac116ceSPawan Guptaadded ITS-safe thunks. These safe thunks consists of indirect branch in the
64*1ac116ceSPawan Guptasecond half of the cacheline. Not all retpoline sites are patched to thunks, if
65*1ac116ceSPawan Guptaa retpoline site is evaluated to be ITS-safe, it is replaced with an inline
66*1ac116ceSPawan Guptaindirect branch.
67*1ac116ceSPawan Gupta
68*1ac116ceSPawan GuptaDynamic thunks
69*1ac116ceSPawan Gupta~~~~~~~~~~~~~~
70*1ac116ceSPawan GuptaFrom a dynamically allocated pool of safe-thunks, each vulnerable site is
71*1ac116ceSPawan Guptareplaced with a new thunk, such that they get a unique address. This could
72*1ac116ceSPawan Guptaimprove the branch prediction accuracy. Also, it is a defense-in-depth measure
73*1ac116ceSPawan Guptaagainst aliasing.
74*1ac116ceSPawan Gupta
75*1ac116ceSPawan GuptaNote, for simplicity, indirect branches in eBPF programs are always replaced
76*1ac116ceSPawan Guptawith a jump to a static thunk in __x86_indirect_its_thunk_array. If required,
77*1ac116ceSPawan Guptain future this can be changed to use dynamic thunks.
78*1ac116ceSPawan Gupta
79*1ac116ceSPawan GuptaAll vulnerable RETs are replaced with a static thunk, they do not use dynamic
80*1ac116ceSPawan Guptathunks. This is because RETs get their prediction from RSB mostly that does not
81*1ac116ceSPawan Guptadepend on source address. RETs that underflow RSB may benefit from dynamic
82*1ac116ceSPawan Guptathunks. But, RETs significantly outnumber indirect branches, and any benefit
83*1ac116ceSPawan Guptafrom a unique source address could be outweighed by the increased icache
84*1ac116ceSPawan Guptafootprint and iTLB pressure.
85*1ac116ceSPawan Gupta
86*1ac116ceSPawan GuptaRetpoline
87*1ac116ceSPawan Gupta~~~~~~~~~
88*1ac116ceSPawan GuptaRetpoline sequence also mitigates ITS-unsafe indirect branches. For this
89*1ac116ceSPawan Guptareason, when retpoline is enabled, ITS mitigation only relocates the RETs to
90*1ac116ceSPawan Guptasafe thunks. Unless user requested the RSB-stuffing mitigation.
91*1ac116ceSPawan Gupta
92*1ac116ceSPawan GuptaRSB Stuffing
93*1ac116ceSPawan Gupta~~~~~~~~~~~~
94*1ac116ceSPawan GuptaRSB-stuffing via Call Depth Tracking is a mitigation for Retbleed RSB-underflow
95*1ac116ceSPawan Guptaattacks. And it also mitigates RETs that are vulnerable to ITS.
96*1ac116ceSPawan Gupta
97*1ac116ceSPawan GuptaMitigation in guests
98*1ac116ceSPawan Gupta^^^^^^^^^^^^^^^^^^^^
99*1ac116ceSPawan GuptaAll guests deploy ITS mitigation by default, irrespective of eIBRS enumeration
100*1ac116ceSPawan Guptaand Family/Model of the guest. This is because eIBRS feature could be hidden
101*1ac116ceSPawan Guptafrom a guest. One exception to this is when a guest enumerates BHI_DIS_S, which
102*1ac116ceSPawan Guptaindicates that the guest is running on an unaffected host.
103*1ac116ceSPawan Gupta
104*1ac116ceSPawan GuptaTo prevent guests from unnecessarily deploying the mitigation on unaffected
105*1ac116ceSPawan Guptaplatforms, Intel has defined ITS_NO bit(62) in MSR IA32_ARCH_CAPABILITIES. When
106*1ac116ceSPawan Guptaa guest sees this bit set, it should not enumerate the ITS bug. Note, this bit
107*1ac116ceSPawan Guptais not set by any hardware, but is **intended for VMMs to synthesize** it for
108*1ac116ceSPawan Guptaguests as per the host's affected status.
109*1ac116ceSPawan Gupta
110*1ac116ceSPawan GuptaMitigation options
111*1ac116ceSPawan Gupta^^^^^^^^^^^^^^^^^^
112*1ac116ceSPawan GuptaThe ITS mitigation can be controlled using the "indirect_target_selection"
113*1ac116ceSPawan Guptakernel parameter. The available options are:
114*1ac116ceSPawan Gupta
115*1ac116ceSPawan Gupta   ======== ===================================================================
116*1ac116ceSPawan Gupta   on       (default)  Deploy the "Aligned branch/return thunks" mitigation.
117*1ac116ceSPawan Gupta	    If spectre_v2 mitigation enables retpoline, aligned-thunks are only
118*1ac116ceSPawan Gupta	    deployed for the affected RET instructions. Retpoline mitigates
119*1ac116ceSPawan Gupta	    indirect branches.
120*1ac116ceSPawan Gupta
121*1ac116ceSPawan Gupta   off      Disable ITS mitigation.
122*1ac116ceSPawan Gupta
123*1ac116ceSPawan Gupta   vmexit   Equivalent to "=on" if the CPU is affected by guest/host isolation
124*1ac116ceSPawan Gupta	    part of ITS. Otherwise, mitigation is not deployed. This option is
125*1ac116ceSPawan Gupta	    useful when host userspace is not in the threat model, and only
126*1ac116ceSPawan Gupta	    attacks from guest to host are considered.
127*1ac116ceSPawan Gupta
128*1ac116ceSPawan Gupta   stuff    Deploy RSB-fill mitigation when retpoline is also deployed.
129*1ac116ceSPawan Gupta	    Otherwise, deploy the default mitigation. When retpoline mitigation
130*1ac116ceSPawan Gupta	    is enabled, RSB-stuffing via Call-Depth-Tracking also mitigates
131*1ac116ceSPawan Gupta	    ITS.
132*1ac116ceSPawan Gupta
133*1ac116ceSPawan Gupta   force    Force the ITS bug and deploy the default mitigation.
134*1ac116ceSPawan Gupta   ======== ===================================================================
135*1ac116ceSPawan Gupta
136*1ac116ceSPawan GuptaSysfs reporting
137*1ac116ceSPawan Gupta---------------
138*1ac116ceSPawan Gupta
139*1ac116ceSPawan GuptaThe sysfs file showing ITS mitigation status is:
140*1ac116ceSPawan Gupta
141*1ac116ceSPawan Gupta  /sys/devices/system/cpu/vulnerabilities/indirect_target_selection
142*1ac116ceSPawan Gupta
143*1ac116ceSPawan GuptaNote, microcode mitigation status is not reported in this file.
144*1ac116ceSPawan Gupta
145*1ac116ceSPawan GuptaThe possible values in this file are:
146*1ac116ceSPawan Gupta
147*1ac116ceSPawan Gupta.. list-table::
148*1ac116ceSPawan Gupta
149*1ac116ceSPawan Gupta   * - Not affected
150*1ac116ceSPawan Gupta     - The processor is not vulnerable.
151*1ac116ceSPawan Gupta   * - Vulnerable
152*1ac116ceSPawan Gupta     - System is vulnerable and no mitigation has been applied.
153*1ac116ceSPawan Gupta   * - Vulnerable, KVM: Not affected
154*1ac116ceSPawan Gupta     - System is vulnerable to intra-mode BTI, but not affected by eIBRS
155*1ac116ceSPawan Gupta       guest/host isolation.
156*1ac116ceSPawan Gupta   * - Mitigation: Aligned branch/return thunks
157*1ac116ceSPawan Gupta     - The mitigation is enabled, affected indirect branches and RETs are
158*1ac116ceSPawan Gupta       relocated to safe thunks.
159*1ac116ceSPawan Gupta   * - Mitigation: Retpolines, Stuffing RSB
160*1ac116ceSPawan Gupta     - The mitigation is enabled using retpoline and RSB stuffing.
161*1ac116ceSPawan Gupta
162*1ac116ceSPawan GuptaReferences
163*1ac116ceSPawan Gupta----------
164*1ac116ceSPawan Gupta.. [#f1] Microcode repository - https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files
165*1ac116ceSPawan Gupta
166*1ac116ceSPawan Gupta.. [#f2] Affected Processors list - https://www.intel.com/content/www/us/en/developer/topic-technology/software-security-guidance/processors-affected-consolidated-product-cpu-model.html
167*1ac116ceSPawan Gupta
168*1ac116ceSPawan Gupta.. [#f3] Affected Processors list (machine readable) - https://github.com/intel/Intel-affected-processor-list
169