Skip to content

Commit e4bf6eb

Browse files
aurel32shenki
authored andcommitted
arch/riscv: vdso: remove CFI landing pad from rt_sigreturn
When CONFIG_RISCV_USER_CFI is enabled, the CFI version of the vDSO, has a CFI landing pad instruction at the start of __vdso_rt_sigreturn. This breaks libgcc's unwinding code which matches on the first two instructions. Other unwinders that rely on similar instruction matching may also be affected. Since __vdso_rt_sigreturn is reached as part of signal-return handling rather than via an indirect call/jump from userspace, it does not need a CFI landing pad. Remove it and restore the instruction sequence expected by existing unwinding code. This matches what was done on arm64 in commit 9a96428 ("arm64: vdso: Don't prefix sigreturn trampoline with a BTI C instruction") for a similar issue. Cc: stable@vger.kernel.org Fixes: 37f57bd ("arch/riscv: compile vdso with landing pad and shadow stack note") Co-authored-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Joel Stanley <joel@jms.id.au> Link: https://patch.msgid.link/20260623204058.498120-1-aurelien@aurel32.net [pjw@kernel.org: fixed comment style] Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent ad6dcfa commit e4bf6eb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

arch/riscv/kernel/vdso/rt_sigreturn.S

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@
77
#include <asm/unistd.h>
88
#include <asm/assembler.h>
99

10+
/*
11+
* WARNING: Do NOT add a CFI landing pad at the start of this function.
12+
* Unwinders such as libgcc identify the sigreturn trampoline by matching the
13+
* instruction sequence. Adding a landing pad here would break unwinding from
14+
* signal handlers.
15+
*
16+
* This trampoline is used only for signal return and not via an indirect
17+
* call/jump from userspace, so adding CFI landing pad is unnecessary.
18+
*/
1019
.text
1120
SYM_FUNC_START(__vdso_rt_sigreturn)
1221
.cfi_startproc
1322
.cfi_signal_frame
14-
vdso_lpad
1523
li a7, __NR_rt_sigreturn
1624
ecall
1725
.cfi_endproc

0 commit comments

Comments
 (0)