]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
riscv: cfi: clear CFI lock status in start_thread()
authorZong Li <zong.li@sifive.com>
Sun, 5 Apr 2026 00:40:58 +0000 (18:40 -0600)
committerPaul Walmsley <pjw@kernel.org>
Sun, 5 Apr 2026 00:40:58 +0000 (18:40 -0600)
commita6ede084c4b7cd6ecd0d31d5292336e556901bd7
treed0dc9ac19bfc554b2fc624cd185fca593408bab4
parenta621d9cdc8d08bd2fe8dfe6fa6897d256de8248f
riscv: cfi: clear CFI lock status in start_thread()

When libc locks the CFI status through the following prctl:
 - PR_LOCK_SHADOW_STACK_STATUS
 - PR_LOCK_INDIR_BR_LP_STATUS

A newly execd address space will inherit the lock status
if it does not clear the lock bits. Since the lock bits
remain set, libc will later fail to enable the landing
pad and shadow stack.

Signed-off-by: Zong Li <zong.li@sifive.com>
Link: https://patch.msgid.link/20260323065640.4045713-1-zong.li@sifive.com
[pjw@kernel.org: ensure we unlock before changing state; cleaned up subject line]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/include/asm/usercfi.h
arch/riscv/kernel/process.c
arch/riscv/kernel/usercfi.c