Re: [PATCH v5 29/39] x86/shstk: Introduce routines modifying shstk
From: Kees Cook <hidden>
Date: 2023-01-20 01:06:07
Also in:
linux-arch, linux-doc, linux-mm, lkml
On Thu, Jan 19, 2023 at 01:23:07PM -0800, Rick Edgecombe wrote:
From: Yu-cheng Yu <redacted> Shadow stacks are normally written to via CALL/RET or specific CET instructions like RSTORSSP/SAVEPREVSSP. However during some Linux operations the kernel will need to write to directly using the ring-0 only WRUSS instruction. A shadow stack restore token marks a restore point of the shadow stack, and the address in a token must point directly above the token, which is within the same shadow stack. This is distinctively different from other pointers on the shadow stack, since those pointers point to executable code area. Introduce token setup and verify routines. Also introduce WRUSS, which is a kernel-mode instruction but writes directly to user shadow stack. In future patches that enable shadow stack to work with signals, the kernel will need something to denote the point in the stack where sigreturn may be called. This will prevent attackers calling sigreturn at arbitrary places in the stack, in order to help prevent SROP attacks. To do this, something that can only be written by the kernel needs to be placed on the shadow stack. This can be accomplished by setting bit 63 in the frame written to the shadow stack. Userspace return addresses can't have this bit set as it is in the kernel range. It is also can't be a valid restore token. Tested-by: Pengfei Xu <redacted> Tested-by: John Allen <john.allen@amd.com> Signed-off-by: Yu-cheng Yu <redacted>
Reviewed-by: Kees Cook <redacted> -- Kees Cook