Skip to content

Commit 9a96428

Browse files
committed
arm64: vdso: Don't prefix sigreturn trampoline with a BTI C instruction
For better or worse, GDB relies on the exact instruction sequence in the VDSO sigreturn trampoline in order to unwind from signals correctly. Commit c91db23 ("arm64: vdso: Convert to modern assembler annotations") unfortunately added a BTI C instruction to the start of __kernel_rt_sigreturn, which breaks this check. Thankfully, it's also not required, since the trampoline is called from a RET instruction when returning from the signal handler Remove the unnecessary BTI C instruction from __kernel_rt_sigreturn, and do the same for the 32-bit VDSO as well for good measure. Cc: Daniel Kiss <[email protected]> Cc: Tamas Zsoldos <[email protected]> Reviewed-by: Dave Martin <[email protected]> Reviewed-by: Mark Brown <[email protected]> Fixes: c91db23 ("arm64: vdso: Convert to modern assembler annotations") Signed-off-by: Will Deacon <[email protected]>
1 parent e4e9f6d commit 9a96428

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

arch/arm64/include/asm/linkage.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#define BTI_J hint 36 ;
1616

1717
/*
18-
* When using in-kernel BTI we need to ensure that assembly functions
19-
* have suitable annotations. Override SYM_FUNC_START to insert a BTI
20-
* landing pad at the start of everything.
18+
* When using in-kernel BTI we need to ensure that PCS-conformant assembly
19+
* functions have suitable annotations. Override SYM_FUNC_START to insert
20+
* a BTI landing pad at the start of everything.
2121
*/
2222
#define SYM_FUNC_START(name) \
2323
SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN) \

arch/arm64/kernel/vdso/sigreturn.S

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
.text
1616

1717
nop
18-
SYM_FUNC_START(__kernel_rt_sigreturn)
18+
/*
19+
* GDB relies on being able to identify the sigreturn instruction sequence to
20+
* unwind from signal handlers. We cannot, therefore, use SYM_FUNC_START()
21+
* here, as it will emit a BTI C instruction and break the unwinder. Thankfully,
22+
* this function is only ever called from a RET and so omitting the landing pad
23+
* is perfectly fine.
24+
*/
25+
SYM_CODE_START(__kernel_rt_sigreturn)
1926
.cfi_startproc
2027
.cfi_signal_frame
2128
.cfi_def_cfa x29, 0
@@ -24,6 +31,6 @@ SYM_FUNC_START(__kernel_rt_sigreturn)
2431
mov x8, #__NR_rt_sigreturn
2532
svc #0
2633
.cfi_endproc
27-
SYM_FUNC_END(__kernel_rt_sigreturn)
34+
SYM_CODE_END(__kernel_rt_sigreturn)
2835

2936
emit_aarch64_feature_1_and

arch/arm64/kernel/vdso32/sigreturn.S

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,39 @@
1717
.save {r0-r15}
1818
.pad #COMPAT_SIGFRAME_REGS_OFFSET
1919
nop
20-
SYM_FUNC_START(__kernel_sigreturn_arm)
20+
SYM_CODE_START(__kernel_sigreturn_arm)
2121
mov r7, #__NR_compat_sigreturn
2222
svc #0
2323
.fnend
24-
SYM_FUNC_END(__kernel_sigreturn_arm)
24+
SYM_CODE_END(__kernel_sigreturn_arm)
2525

2626
.fnstart
2727
.save {r0-r15}
2828
.pad #COMPAT_RT_SIGFRAME_REGS_OFFSET
2929
nop
30-
SYM_FUNC_START(__kernel_rt_sigreturn_arm)
30+
SYM_CODE_START(__kernel_rt_sigreturn_arm)
3131
mov r7, #__NR_compat_rt_sigreturn
3232
svc #0
3333
.fnend
34-
SYM_FUNC_END(__kernel_rt_sigreturn_arm)
34+
SYM_CODE_END(__kernel_rt_sigreturn_arm)
3535

3636
.thumb
3737
.fnstart
3838
.save {r0-r15}
3939
.pad #COMPAT_SIGFRAME_REGS_OFFSET
4040
nop
41-
SYM_FUNC_START(__kernel_sigreturn_thumb)
41+
SYM_CODE_START(__kernel_sigreturn_thumb)
4242
mov r7, #__NR_compat_sigreturn
4343
svc #0
4444
.fnend
45-
SYM_FUNC_END(__kernel_sigreturn_thumb)
45+
SYM_CODE_END(__kernel_sigreturn_thumb)
4646

4747
.fnstart
4848
.save {r0-r15}
4949
.pad #COMPAT_RT_SIGFRAME_REGS_OFFSET
5050
nop
51-
SYM_FUNC_START(__kernel_rt_sigreturn_thumb)
51+
SYM_CODE_START(__kernel_rt_sigreturn_thumb)
5252
mov r7, #__NR_compat_rt_sigreturn
5353
svc #0
5454
.fnend
55-
SYM_FUNC_END(__kernel_rt_sigreturn_thumb)
55+
SYM_CODE_END(__kernel_rt_sigreturn_thumb)

0 commit comments

Comments
 (0)