Re: [PATCH v7 01/41] Documentation/x86: Add CET shadow stack description

Florian Weimer
2023-03-07T14:01:42Z

* szabolcs:

> changing/disabling the alt stack is not valid while a handler is
> executing on it. if we don't allow jumping out and back to an
> alt stack (swapcontext) then there can be only one alt stack
> live per thread and change/disable can do the shadow stack free.
>
> if jump back is allowed (linux even makes it race-free with
> SS_AUTODISARM) then the life-time of alt stack is extended
> beyond change/disable (jump back to an unregistered alt stack).
>
> to support jump back to an alt stack the requirements are
>
> 1) user has to manage an alt shadow stack together with the alt
> stack (requies user code change, not just libc).
>
> 2) kernel has to push a restore token on the thread shadow stack
> on signal entry (at least in case of alt shadow stack, and
> deal with corner cases around shadow stack overflow).

We need to have a story for stackful coroutine switching as well, not
just for sigaltstack. I hope that we can use OpenJDK (Project Loom) and
QEMU as guinea pigs. If we have something that works for both,
hopefully that covers a broad range of scenarios. Userspace
coordination can eventually be handled by glibc; we can deallocate
alternate stacks on thread exit fairly easily (at least compared to the
current stack 8-).

Thanks,
Florian