On Mon, Aug 05, 2024 at 08:54:54PM -0700, Kees Cook wrote:
# Running test 'Shadow stack on system with shadow stack' # [5496] Trying clone3() with flags 0 (size 0) # I am the parent (5496). My child's pid is 5505 # Child exited with signal 11 # [5496] clone3() with flags says: 11 expected 0 # [5496] Result (11) is different than expected (0) not ok 20 Shadow stack on system with shadow stack
The child segfaults immediately, it seems?
Does this help:
diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c index 1755fa21e6fb..27acbdf44c5f 100644 --- a/arch/x86/kernel/shstk.c +++ b/arch/x86/kernel/shstk.c @@ -198,13 +198,14 @@ int arch_shstk_post_fork(struct task_struct *t, struct kernel_clone_args *args) * the token 64-bit. */ struct mm_struct *mm; - unsigned long addr; + unsigned long addr, ssp; u64 expected; u64 val; - int ret = -EINVAL;; + int ret = -EINVAL;
- addr = args->shadow_stack + args->shadow_stack_size - sizeof(u64); - expected = (addr - SS_FRAME_SIZE) | BIT(0); + ssp = args->shadow_stack + args->shadow_stack_size; + addr = ssp - SS_FRAME_SIZE; + expected = ssp | BIT(0);
mm = get_task_mm(t); if (!mm)