Thread (154 messages) 154 messages, 12 authors, 2023-03-20

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

From: H.J. Lu <hidden>
Date: 2023-03-03 17:51:08
Also in: linux-arch, linux-doc, linux-mm, lkml

On Fri, Mar 3, 2023 at 9:40 AM szabolcs.nagy@arm.com
[off-list ref] wrote:
The 03/03/2023 08:57, H.J. Lu wrote:
quoted
On Fri, Mar 3, 2023 at 8:31 AM szabolcs.nagy@arm.com
[off-list ref] wrote:
quoted
longjmp to different stack should work: it can do the same as
setcontext/swapcontext: scan for the pivot token. then only
longjmp out of alt shadow stack fails. (this is non-conforming
longjmp use, but e.g. qemu relies on it.)
Restore token may not be used with longjmp.  Unlike setcontext/swapcontext,
longjmp is optional.  If longjmp isn't called, there will be an extra
token on shadow
stack and RET will fail.
what do you mean longjmp is optional?
In some cases, longjmp is called to handle an error condition and
longjmp won't be called if there is no error.
it can scan the target shadow stack and decide if it's the
same as the current one or not and in the latter case there
should be a restore token to switch to. then it can INCSSP
to reach the target SSP state.

qemu does setjmp, then swapcontext, then longjmp back.
swapcontext can change the stack, but leaves a token behind
so longjmp can switch back.
This needs changes to support shadow stack.  Replacing setjmp with
getcontext and longjmp with setcontext may work for shadow stack.

BTW, there is no testcase in glibc for this usage.

-- 
H.J.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help