arch/riscv: vdso: remove CFI landing pad from rt_sigreturn
PATCH 1/1 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 9a964285572b ("arm64:
vdso: Don't prefix sigreturn trampoline with a BTI C instruction") for a similar issue.
--- arch/riscv/kernel/vdso/rt_sigreturn.S | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/riscv/kernel/vdso/rt_sigreturn.S +8 -1
@@ -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
Signature · 1 line
2.53.0
Paul Walmsley
maintainerHi Joel,
Quoted 11 lines · Aurelien Jarno
When
CONFIG_RISCV_USER_CFIis 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_sigreturnis 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.
Quoted 7 lines
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 <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>
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
Quoted 20 lines · Paul Walmsley
Hi Joel,
Quoted 15 lines · Aurelien Jarno
When
CONFIG_RISCV_USER_CFIis 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_sigreturnis 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.
Quoted 6 lines
Quoted 3 lines
Fixes 37f57bd3faea ("arch/riscv: compile vdso with landing pad and shadow stack note")Co-authored-by Joel Stanley <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>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 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
Hi Paul,
Quoted 28 lines · Joel Stanley
Quoted 20 lines · Paul Walmsley
Hi Joel,
Quoted 15 lines · Aurelien Jarno
When
CONFIG_RISCV_USER_CFIis 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_sigreturnis 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.Quoted 6 lines
Quoted 3 lines
Fixes 37f57bd3faea ("arch/riscv: compile vdso with landing pad and shadow stack note")Co-authored-by Joel Stanley <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>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?
Quoted 7 lines
Signed-off-by Joel Stanley <[email protected]>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
Signature · 7 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://aurel32.net _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Paul Walmsley
maintainerHi Aurelien, Joel,
Quoted 28 lines · Aurelien Jarno
Quoted 27 lines · Joel Stanley
Quoted 17 lines · Paul Walmsley
Quoted 15 lines · Aurelien Jarno
When
CONFIG_RISCV_USER_CFIis 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_sigreturnis 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.Quoted 6 lines
Quoted 3 lines
Fixes 37f57bd3faea ("arch/riscv: compile vdso with landing pad and shadow stack note")Co-authored-by Joel Stanley <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>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 <[email protected]>
Quoted 8 lines
Quoted 5 lines
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?
Of course; thank you for the reminder. Thanks for the patch and the S-o-b, queued for v7.2-rc with a cc: to stable@vger.
- Paul