Skip to content

Commit b93d6c7

Browse files
rpedgecohansendc
authored andcommitted
x86/shstk: Check that SSP is aligned on sigreturn
The shadow stack signal frame is read by the kernel on sigreturn. It relies on shadow stack memory protections to prevent forgeries of this signal frame (which included the pre-signal SSP). It also relies on the shadow stack signal frame to have bit 63 set. Since this bit would not be set via typical shadow stack operations, so the kernel can assume it was a value it placed there. However, in order to support 32 bit shadow stack, the INCSSPD instruction can increment the shadow stack by 4 bytes. In this case SSP might be pointing to a region spanning two 8 byte shadow stack frames. It could confuse the checks described above. Since the kernel only supports shadow stack in 64 bit, just check that the SSP is 8 byte aligned in the sigreturn path. Signed-off-by: Rick Edgecombe <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Link: https://lore.kernel.org/all/20230613001108.3040476-33-rick.p.edgecombe%40intel.com
1 parent 05e3602 commit b93d6c7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/x86/kernel/shstk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ static int shstk_pop_sigframe(unsigned long *ssp)
252252
unsigned long token_addr;
253253
int err;
254254

255+
if (!IS_ALIGNED(*ssp, 8))
256+
return -EINVAL;
257+
255258
err = get_shstk_data(&token_addr, (unsigned long __user *)*ssp);
256259
if (unlikely(err))
257260
return err;

0 commit comments

Comments
 (0)