* BHB-clearing on VM-exit @ 2022-08-30 23:42 Jim Mattson 2022-08-31 8:22 ` Chao Gao 0 siblings, 1 reply; 7+ messages in thread From: Jim Mattson @ 2022-08-30 23:42 UTC (permalink / raw) To: kvm list Don't we need a software BHB-clearing sequence on VM-exit for Intel parts that don't report IA32_ARCH_CAPABILITIES.BHI_NO? What am I missing? https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/branch-history-injection.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: BHB-clearing on VM-exit 2022-08-30 23:42 BHB-clearing on VM-exit Jim Mattson @ 2022-08-31 8:22 ` Chao Gao 2022-09-01 17:46 ` Pawan Gupta 0 siblings, 1 reply; 7+ messages in thread From: Chao Gao @ 2022-08-31 8:22 UTC (permalink / raw) To: Jim Mattson, pawan.kumar.gupta, chen.zhang; +Cc: kvm list On Tue, Aug 30, 2022 at 04:42:19PM -0700, Jim Mattson wrote: >Don't we need a software BHB-clearing sequence on VM-exit for Intel >parts that don't report IA32_ARCH_CAPABILITIES.BHI_NO? What am I >missing? I think we need the software mitigation on parts that don't support/enable BHI_DIS_S of IA32_SPEC_CTRL MSR and don't enumerate BHI_NO. Pawan, any idea? > >https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/branch-history-injection.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: BHB-clearing on VM-exit 2022-08-31 8:22 ` Chao Gao @ 2022-09-01 17:46 ` Pawan Gupta 2022-09-01 18:35 ` Jim Mattson 0 siblings, 1 reply; 7+ messages in thread From: Pawan Gupta @ 2022-09-01 17:46 UTC (permalink / raw) To: Chao Gao; +Cc: Jim Mattson, chen.zhang, kvm list On Wed, Aug 31, 2022 at 04:22:03PM +0800, Chao Gao wrote: > On Tue, Aug 30, 2022 at 04:42:19PM -0700, Jim Mattson wrote: > >Don't we need a software BHB-clearing sequence on VM-exit for Intel > >parts that don't report IA32_ARCH_CAPABILITIES.BHI_NO? What am I > >missing? > > I think we need the software mitigation on parts that don't support/enable > BHI_DIS_S of IA32_SPEC_CTRL MSR and don't enumerate BHI_NO. > > Pawan, any idea? Intel doesn't recommend any BHI mitigation on VM exit. The guest can't make risky system calls (e.g. unprivileged eBPF) in the host, so the previously proposed attacks aren't viable, and in general the exposed attack surface to a guest is much smaller (with no syscalls). If defense-in-depth paranoia is desired, the BHB-clearing sequence could be an alternative in the absence of BHI_DIS_S/BHI_NO. Thanks, Pawan ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: BHB-clearing on VM-exit 2022-09-01 17:46 ` Pawan Gupta @ 2022-09-01 18:35 ` Jim Mattson 2022-09-02 19:14 ` Pawan Gupta 0 siblings, 1 reply; 7+ messages in thread From: Jim Mattson @ 2022-09-01 18:35 UTC (permalink / raw) To: Pawan Gupta; +Cc: Chao Gao, chen.zhang, kvm list On Thu, Sep 1, 2022 at 10:46 AM Pawan Gupta <pawan.kumar.gupta@intel.com> wrote: > > On Wed, Aug 31, 2022 at 04:22:03PM +0800, Chao Gao wrote: > > On Tue, Aug 30, 2022 at 04:42:19PM -0700, Jim Mattson wrote: > > >Don't we need a software BHB-clearing sequence on VM-exit for Intel > > >parts that don't report IA32_ARCH_CAPABILITIES.BHI_NO? What am I > > >missing? > > > > I think we need the software mitigation on parts that don't support/enable > > BHI_DIS_S of IA32_SPEC_CTRL MSR and don't enumerate BHI_NO. > > > > Pawan, any idea? > > Intel doesn't recommend any BHI mitigation on VM exit. The guest can't > make risky system calls (e.g. unprivileged eBPF) in the host, so the > previously proposed attacks aren't viable, and in general the exposed > attack surface to a guest is much smaller (with no syscalls). If > defense-in-depth paranoia is desired, the BHB-clearing sequence could be > an alternative in the absence of BHI_DIS_S/BHI_NO. Just for clarity, are you saying that it is not possible for a guest to use the shared BHB to mount a successful attack on the host when eIBRS is enabled or IBRS is applied after VM-exit? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: BHB-clearing on VM-exit 2022-09-01 18:35 ` Jim Mattson @ 2022-09-02 19:14 ` Pawan Gupta 2022-09-02 19:35 ` Jim Mattson 0 siblings, 1 reply; 7+ messages in thread From: Pawan Gupta @ 2022-09-02 19:14 UTC (permalink / raw) To: Jim Mattson; +Cc: Chao Gao, chen.zhang, kvm list On Thu, Sep 01, 2022 at 11:35:10AM -0700, Jim Mattson wrote: > On Thu, Sep 1, 2022 at 10:46 AM Pawan Gupta <pawan.kumar.gupta@intel.com> wrote: > > > > On Wed, Aug 31, 2022 at 04:22:03PM +0800, Chao Gao wrote: > > > On Tue, Aug 30, 2022 at 04:42:19PM -0700, Jim Mattson wrote: > > > >Don't we need a software BHB-clearing sequence on VM-exit for Intel > > > >parts that don't report IA32_ARCH_CAPABILITIES.BHI_NO? What am I > > > >missing? > > > > > > I think we need the software mitigation on parts that don't support/enable > > > BHI_DIS_S of IA32_SPEC_CTRL MSR and don't enumerate BHI_NO. > > > > > > Pawan, any idea? > > > > Intel doesn't recommend any BHI mitigation on VM exit. The guest can't > > make risky system calls (e.g. unprivileged eBPF) in the host, so the > > previously proposed attacks aren't viable, and in general the exposed > > attack surface to a guest is much smaller (with no syscalls). If > > defense-in-depth paranoia is desired, the BHB-clearing sequence could be > > an alternative in the absence of BHI_DIS_S/BHI_NO. > > Just for clarity, are you saying that it is not possible for a guest > to use the shared BHB to mount a successful attack on the host when > eIBRS is enabled or IBRS is applied after VM-exit? It may be possible to use shared BHB to influence the choice of indirect targets, but there are other requirements that needs to be satisfied such as: - Finding a disclosure gadget. - Controlling register inputs to the gadget. - Injecting the disclosure gadget in the predictors before it can be transiently executed. - Finding an appropriate indirect-branch site after VM-exit, and before BHB is overwritten. IFAIK, other than gadgets based on unprivileged eBPF (which is disabled by default), previous research hasn't concluded on the exploitability of any other gadgets. Also factors stated above makes it hard for a guest to exploit BHI. If that changes or if defense-in-depth is desired, BHB-clearing sequence is the appropriate thing to do. Thanks, Pawan ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: BHB-clearing on VM-exit 2022-09-02 19:14 ` Pawan Gupta @ 2022-09-02 19:35 ` Jim Mattson 2022-09-03 2:08 ` Pawan Gupta 0 siblings, 1 reply; 7+ messages in thread From: Jim Mattson @ 2022-09-02 19:35 UTC (permalink / raw) To: Pawan Gupta; +Cc: Chao Gao, chen.zhang, kvm list On Fri, Sep 2, 2022 at 12:14 PM Pawan Gupta <pawan.kumar.gupta@intel.com> wrote: > It may be possible to use shared BHB to influence the choice of indirect > targets, but there are other requirements that needs to be satisfied > such as: > - Finding a disclosure gadget. Gadgets abound, and there are tools to find them, if the attacker has the victim binary. > - Controlling register inputs to the gadget. This is non-trivial, since kvm clears GPRs on VM-exit. However, an attacker can look for calls to kvm_read_register() or similar places where kvm loads elements of guest state. The instruction emulator and local APIC emulation both seem like promising targets. > - Injecting the disclosure gadget in the predictors before it can be > transiently executed. IIUC, the gadget has to already be an indirect branch target that can be exercised by some guest action (e.g. writing to a specific x2APIC MSR). Is that correct? > - Finding an appropriate indirect-branch site after VM-exit, and before > BHB is overwritten. Is it the case that the RIP of the victim indirect branch has to alias to the RIP of the "training branch" above in the predictors? Presumably, guest influence diminishes after every branch, even before the BHB is completely overwritten. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: BHB-clearing on VM-exit 2022-09-02 19:35 ` Jim Mattson @ 2022-09-03 2:08 ` Pawan Gupta 0 siblings, 0 replies; 7+ messages in thread From: Pawan Gupta @ 2022-09-03 2:08 UTC (permalink / raw) To: Jim Mattson; +Cc: Chao Gao, chen.zhang, kvm list On Fri, Sep 02, 2022 at 12:35:13PM -0700, Jim Mattson wrote: > On Fri, Sep 2, 2022 at 12:14 PM Pawan Gupta <pawan.kumar.gupta@intel.com> wrote: > > > It may be possible to use shared BHB to influence the choice of indirect > > targets, but there are other requirements that needs to be satisfied > > such as: > > - Finding a disclosure gadget. > > Gadgets abound, and there are tools to find them, if the attacker has > the victim binary. Agree. > > - Controlling register inputs to the gadget. > > This is non-trivial, since kvm clears GPRs on VM-exit. However, an > attacker can look for calls to kvm_read_register() or similar places > where kvm loads elements of guest state. The instruction emulator and > local APIC emulation both seem like promising targets. Those "elements of guest state" needs to also survive till the desired indirect-branch site, it could be possible. > > - Injecting the disclosure gadget in the predictors before it can be > > transiently executed. > > IIUC, the gadget has to already be an indirect branch target that can > be exercised by some guest action (e.g. writing to a specific x2APIC > MSR). Is that correct? That is correct. > > - Finding an appropriate indirect-branch site after VM-exit, and before > > BHB is overwritten. > > Is it the case that the RIP of the victim indirect branch has to alias > to the RIP of the "training branch" above in the predictors? No, its due to collision in history based predictors that account for branch history + RIP. > Presumably, guest influence diminishes after every branch, even before > the BHB is completely overwritten. That is true, with every taken-branch the guest control diminishes. Thanks, Pawan ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-09-03 2:08 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-08-30 23:42 BHB-clearing on VM-exit Jim Mattson 2022-08-31 8:22 ` Chao Gao 2022-09-01 17:46 ` Pawan Gupta 2022-09-01 18:35 ` Jim Mattson 2022-09-02 19:14 ` Pawan Gupta 2022-09-02 19:35 ` Jim Mattson 2022-09-03 2:08 ` Pawan Gupta
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox