Re: RFC: userspace exception fixups

From: Andy Lutomirski
Date: Tue Nov 06 2018 - 13:20:34 EST





> On Nov 6, 2018, at 9:19 AM, Sean Christopherson <sean.j.christopherson@xxxxxxxxx> wrote:
>
>> On Tue, 2018-11-06 at 08:57 -0800, Andy Lutomirski wrote:
>>
>> So I guess the non-enclave code basically canât trust its stack pointer
>> because of these shenanigans. And the AEP code has to live with the fact
>> that its RSP is basically arbitrary and probably canât even be unwound
>> by a debugger?
>
> The SDK provides a Python GDB plugin to hook into the out-call flow and
> do more stack shenanigans. From what I can tell it's fudging the stack
> to make it look like a normal stack frame so the debugger can do it's
> thing.
>
>> And the EENTER code has to deal with the fact that its red zone can be
>> blatantly violated by the enclave?
>
> That's my understanding of things. So yeah, if it wasn't obvious before,
> the trusted and untrusted parts of the SDK are very tightly coupled.

Yuck. Just how far does this right coupling go? If there are enclaves that play with, say, FSBASE or GSBASE, weâre going to start having problems. And the SGX handling of PKRU is complicated at best.

I almost feel like the right solution is to call into SGX on its own private stack or maybe even its own private address space.