* [PATCH] arch/riscv: vdso: remove CFI landing pad from rt_sigreturn
@ 2026-06-23 20:40 Aurelien Jarno
2026-06-25 18:03 ` Paul Walmsley
0 siblings, 1 reply; 4+ messages in thread
From: Aurelien Jarno @ 2026-06-23 20:40 UTC (permalink / raw)
To: linux-kernel, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Jim Shu, Zong Li, Deepak Gupta
Cc: Aurelien Jarno, Joel Stanley, open list:RISC-V ARCHITECTURE
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 9a964285572b ("arm64:
vdso: Don't prefix sigreturn trampoline with a BTI C instruction") for a
similar issue.
Fixes: 37f57bd3faea ("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>
---
arch/riscv/kernel/vdso/rt_sigreturn.S | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/vdso/rt_sigreturn.S b/arch/riscv/kernel/vdso/rt_sigreturn.S
index e82987dc37394..f6b053d3bb798 100644
--- a/arch/riscv/kernel/vdso/rt_sigreturn.S
+++ b/arch/riscv/kernel/vdso/rt_sigreturn.S
@@ -7,11 +7,18 @@
#include <asm/unistd.h>
#include <asm/assembler.h>
+/* WARNING: Do NOT add a CFI landing pad at the start of this function.
+ * Unwinders such as libgcc identify the sigreturn trampoline by matching the
+ * instruction sequence. Adding a landing pad here would break unwinding from
+ * signal handlers.
+ *
+ * This trampoline is used only for signal return and not via an indirect
+ * call/jump from userspace, so adding CFI landing pad is unnecessary.
+ */
.text
SYM_FUNC_START(__vdso_rt_sigreturn)
.cfi_startproc
.cfi_signal_frame
- vdso_lpad
li a7, __NR_rt_sigreturn
ecall
.cfi_endproc
--
2.53.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arch/riscv: vdso: remove CFI landing pad from rt_sigreturn
2026-06-23 20:40 [PATCH] arch/riscv: vdso: remove CFI landing pad from rt_sigreturn Aurelien Jarno
@ 2026-06-25 18:03 ` Paul Walmsley
2026-06-29 7:38 ` Joel Stanley
0 siblings, 1 reply; 4+ messages in thread
From: Paul Walmsley @ 2026-06-25 18:03 UTC (permalink / raw)
To: Joel Stanley
Cc: Aurelien Jarno, linux-kernel, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, Jim Shu, Zong Li, Deepak Gupta,
open list:RISC-V ARCHITECTURE
Hi Joel,
On Tue, 23 Jun 2026, Aurelien Jarno wrote:
> 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 9a964285572b ("arm64:
> vdso: Don't prefix sigreturn trampoline with a BTI C instruction") for a
> similar issue.
>
> Fixes: 37f57bd3faea ("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>
I'd like to take this one. But since you're listed as the co-author, I
probably need your Signed-off-by: as well. Care to reply with it?
thanks
- Paul
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arch/riscv: vdso: remove CFI landing pad from rt_sigreturn
2026-06-25 18:03 ` Paul Walmsley
@ 2026-06-29 7:38 ` Joel Stanley
2026-07-14 13:35 ` Aurelien Jarno
0 siblings, 1 reply; 4+ messages in thread
From: Joel Stanley @ 2026-06-29 7:38 UTC (permalink / raw)
To: Paul Walmsley
Cc: Aurelien Jarno, linux-kernel, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Jim Shu, Zong Li, Deepak Gupta,
open list:RISC-V ARCHITECTURE
On Fri, 26 Jun 2026 at 03:33, Paul Walmsley <pjw@kernel.org> wrote:
>
> Hi Joel,
>
> On Tue, 23 Jun 2026, Aurelien Jarno wrote:
>
> > 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 9a964285572b ("arm64:
> > vdso: Don't prefix sigreturn trampoline with a BTI C instruction") for a
> > similar issue.
> >
> > Fixes: 37f57bd3faea ("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>
>
> I'd like to take this one. But since you're listed as the co-author, I
> probably need your Signed-off-by: as well. Care to reply with it?
Signed-off-by: Joel Stanley <joel@jms.id.au>
Thanks Aurelien for working with me on this one. I saw CFI was
disabled in the debian kernel config and wondered why (failing glibc
backtrace tests with CFI enabled), and we got to the bottom of it.
This one should go to stable IMO.
Cheers,
Joel
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arch/riscv: vdso: remove CFI landing pad from rt_sigreturn
2026-06-29 7:38 ` Joel Stanley
@ 2026-07-14 13:35 ` Aurelien Jarno
0 siblings, 0 replies; 4+ messages in thread
From: Aurelien Jarno @ 2026-07-14 13:35 UTC (permalink / raw)
To: Paul Walmsley
Cc: Joel Stanley, linux-kernel, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Jim Shu, Zong Li, Deepak Gupta,
open list:RISC-V ARCHITECTURE
Hi Paul,
On 2026-06-29 17:08, Joel Stanley wrote:
> On Fri, 26 Jun 2026 at 03:33, Paul Walmsley <pjw@kernel.org> wrote:
> >
> > Hi Joel,
> >
> > On Tue, 23 Jun 2026, Aurelien Jarno wrote:
> >
> > > 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 9a964285572b ("arm64:
> > > vdso: Don't prefix sigreturn trampoline with a BTI C instruction") for a
> > > similar issue.
> > >
> > > Fixes: 37f57bd3faea ("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>
> >
> > I'd like to take this one. But since you're listed as the co-author, I
> > probably need your Signed-off-by: as well. Care to reply with it?
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
>
> Thanks Aurelien for working with me on this one. I saw CFI was
> disabled in the debian kernel config and wondered why (failing glibc
> backtrace tests with CFI enabled), and we got to the bottom of it.
>
> This one should go to stable IMO.
Now that Joel answered with a Signed-off-by, would it be possible to get
this merged for 7.2?
Thanks
Aurelien
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://aurel32.net
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-14 13:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 20:40 [PATCH] arch/riscv: vdso: remove CFI landing pad from rt_sigreturn Aurelien Jarno
2026-06-25 18:03 ` Paul Walmsley
2026-06-29 7:38 ` Joel Stanley
2026-07-14 13:35 ` Aurelien Jarno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox