riscv/usercfi: fix shadow stack locking argument
RFC PATCH 1/1 riscv/usercfi: fix shadow stack locking argument
The API for arch_lock_shadow_stack_status, is that the argument contains the feature bits one wants to lock, including support for unknown bits.
The API was documented in:
commit 91e102e79740 ("prctl: arch-agnostic prctl for shadow stack")
The current code expected the argument to be 0. That would mean nothing is locked. Note that glibc has not merged the riscv support yet, so now would be the time to correct this behavior.
See the patch series in question for glibc here:
Signed-off-by Bill Roberts <[email protected]>
---
RFC Notes:
I ONLY compile tested this. This was meant to strike up a conversation on this before it gets baked into the kernel forever. Right now, seems like the time to change that.
arch/riscv/kernel/usercfi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/riscv/kernel/usercfi.c +4 -2
@@ -440,10 +440,12 @@ int arch_lock_shadow_stack_status(struct task_struct *task, {/* If shtstk not supported or not enabled on task, nothing to lock here */ if (!is_user_shstk_enabled () || - !is_shstk_enabled (task) || arg !=0 ) + !is_shstk_enabled (task))return -EINVAL ; -set_shstk_lock (task, true); +/* transparently handle unknown bits, this is part of the API */ +if (arg &PR_SHADOW_STACK_ENABLE ) +set_shstk_lock (task, true);return 0 ; }
Signature · 1 line
2.55.0