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