[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ac70e206-5ef8-b6c3-9a37-0e34b7c2f35d@citrix.com>
Date: Tue, 29 Sep 2020 16:01:54 +0100
From: Andrew Cooper <andrew.cooper3@...rix.com>
To: Dave Hansen <dave.hansen@...el.com>,
Andy Lutomirski <luto@...nel.org>
CC: "H.J. Lu" <hjl.tools@...il.com>,
Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
the arch/x86 maintainers <x86@...nel.org>,
<linux-sgx@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>,
"Sean Christopherson" <sean.j.christopherson@...el.com>,
Jethro Beekman <jethro@...tanix.com>,
Cedric Xing <cedric.xing@...el.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
<asapek@...gle.com>, Borislav Petkov <bp@...en8.de>,
<chenalexchen@...gle.com>, Conrad Parker <conradparker@...gle.com>,
<cyhanish@...gle.com>, "Huang, Haitao" <haitao.huang@...el.com>,
Josh Triplett <josh@...htriplett.org>,
"Huang, Kai" <kai.huang@...el.com>,
"Svahn, Kai" <kai.svahn@...el.com>, Keith Moyer <kmoy@...gle.com>,
Christian Ludloff <ludloff@...gle.com>,
Neil Horman <nhorman@...hat.com>,
Nathaniel McCallum <npmccallum@...hat.com>,
"Patrick Uiterwijk" <puiterwijk@...hat.com>,
David Rientjes <rientjes@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>, <yaozhangx@...gle.com>,
Yu-cheng Yu <yu-cheng.yu@...el.com>,
Josh Poimboeuf <jpoimboe@...hat.com>
Subject: Re: [PATCH v38 21/24] x86/vdso: Implement a vDSO for Intel SGX
enclave call
On 29/09/2020 15:10, Dave Hansen wrote:
> On 9/28/20 4:38 PM, Andrew Cooper wrote:
>>>> CET=y, BUG_SPECTRE_V2=y: does not exist
>>>> CET=n, BUG_SPECTRE_V2=y: vulnerable, use retpoline
>>>> CET=y, BUG_SPECTRE_V2=n: no retpoline, not vulnerable
>>>> CET=n, BUG_SPECTRE_V2=n: no retpoline, not vulnerable
>>> Just to confirm: does this mean that the CPU mitigates against user
>>> code mistraining the branch predictors for CPL0?
>> If (and only if) you have eIBRS enabled.
>>
>> eIBRS should be available on all CET-capable hardware, and Linux ought
>> to use it by default.
> You're totally right, of course. I was (wrongly) thinking about this
> VDSO retpoline as kernel code.
>
> There's another wrinkle here. Let's say we're vulnerable to a
> Spectre-v2-style attack and we want to mitigate it on CET hardware that
> has enhanced IBRS. I'm not sure how reliable of a mitigation retpolines
> are on enhanced IBRS hardware. Intel has recommended _against_ using
> them in some cases:
>
>> https://software.intel.com/security-software-guidance/api-app/sites/default/files/Retpoline-A-Branch-Target-Injection-Mitigation.pdf
> "On processors that support enhanced IBRS, it should be used for
> mitigation instead of retpoline."
> I actually authored that bit of the whitepaper, and I recall that this
> was not simply a recommendation based on performance advantages of using
> enhanced IBRS. I can dig through some old email if we decide that we
> want to explore using a retpoline on enhanced IBRS hardware.
If only life were simple.
In light of https://arxiv.org/abs/2008.02307 which managed to
demonstrate that the original KAISER was actually a speculative attack
and nothing to do with the prefetch instruction, a discussion about
same-mode training happened.
The updated recommendation given was to continue using retpoline as well
as eIBRS to prevent same-mode training of the syscall indirect branch.
Josh (CC'd) has been doing a lot of work to find and fix other
speculative leaks in this area.
For Skylake uarch and later, even if an RSB underflow leads to a BTB
lookup, it still requires an interrupt/NMI to hit one of two instruction
boundaries to empty the RSB, and an attacker with that level of control
probably has more interesting things to be trying to do.
Without retpoline (or something even more expensive such as IRET-ing
around), an attacker can still create speculative type confusion between
different system calls, when eIBRS is active.
Once you mix CET-SS in, this breaks, unless you're prepared to update
the retpoline gadget to include a WRSS to modify the shadow stack
alongside the regular stack. Add this to the large pile of fun for
whomever has the privileg^W chore of implementing supervisor CET support.
>
> But, let's take a step back. The changelog for this patch needs to at
> least have:
>
> 1. What is the attack being mitigated by the retpoline?
> 2. Do we actually want to mitigate it?
> 3. What options are there to mitigate it?
> 4. Which option does this patch use and why?
>
> Right now, there's not even a comment about this.
I agree. The reason for using a retpoline here in the first place is
unclear.
~Andrew
Powered by blists - more mailing lists