Re: TDX #VE in SYSCALL gap (was: [RFD] x86: Curing the exception and syscall trainwreck in hardware)
From: Andrew Cooper
Date: Tue Aug 25 2020 - 14:18:32 EST
On 25/08/2020 18:35, Luck, Tony wrote:
>>> Or malicious hypervisor action, and that's a problem.
>>>
>>> Suppose the hypervisor remaps a GPA used in the SYSCALL gap (e.g. the
>>> actual SYSCALL text or the first memory it accesses -- I don't have a
>>> TDX spec so I don't know the details).
> Is it feasible to defend against a malicious (or buggy) hypervisor?
>
> Obviously, we can't leave holes that guests can exploit. But the hypervisor
> can crash the system no matter how clever TDX is.
You have to be more specific about what you mean by "malicious" hypervisor.
Nothing can protect against a hypervisor which refuses to schedule the
Trusted Domain. The guest cannot protect against availability
maliciousness. However, you can use market forces to fix that problem.
(I'll take my credit card elsewhere if you don't schedule my VM, etc)
Things are more complicated when it comes to integrity or
confidentiality of the TD, but the prevailing feeling seems to be
"crashing obviously and reliably if something goes wrong is ok".
If I've read the TDX spec/whitepaper properly, the main hypervisor can
write to all the encrypted pages. This will destroy data, break the
MAC, and yields #PF inside the SEAM hypervisor, or the TD when the cache
line is next referenced.
Cunning timing on behalf of a malicious hypervisor (hitting the SYSCALL
gap) will cause the guest's #PF handler to run on a user stack, opening
a privilege escalation hole.
Whatever you might want to say about the exact integrity/confidentiality
expectations, I think "the hypervisor can open a user=>kernel privilege
escalation hole inside the TD" is not what people would consider acceptable.
On AMD parts, this is why the #VC handler is IST, in an attempt to at
least notice this damage and crash. There is no way TDX can get away
with requiring #PF to be IST as well.
~Andrew