Skip to content

Commit 2b951b0

Browse files
ardbiesheuvelRussell King (Oracle)
authored andcommitted
ARM: 9297/1: vfp: avoid unbalanced stack on 'success' return path
Commit c76c6c4 ("ARM: 9294/2: vfp: Fix broken softirq handling with instrumentation enabled") updated the VFP exception entry logic to go via a C function, so that we get the compiler's version of local_bh_disable(), which may be instrumented, and isn't generally callable from assembler. However, this assumes that passing an alternative 'success' return address works in C as it does in asm, and this is only the case if the C calls in question are tail calls, as otherwise, the stack will need some unwinding as well. I have already sent patches to the list that replace most of the asm logic with C code, and so it is preferable to have a minimal fix that addresses the issue and can be backported along with the commit that it fixes to v6.3 from v6.4. Hopefully, we can land the C conversion for v6.5. So instead of passing the 'success' return address as a function argument, pass the stack address from where to pop it so that both LR and SP have the expected value. Fixes: c76c6c4 ("ARM: 9294/2: vfp: Fix broken softirq handling with ...") Reported-by: syzbot+d4b00edc2d0c910d4bf4@syzkaller.appspotmail.com Tested-by: syzbot+d4b00edc2d0c910d4bf4@syzkaller.appspotmail.com Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Tested-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
1 parent 46dd607 commit 2b951b0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

arch/arm/vfp/entry.S

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
@
2424
ENTRY(do_vfp)
2525
mov r1, r10
26-
mov r3, r9
27-
b vfp_entry
26+
str lr, [sp, #-8]!
27+
add r3, sp, #4
28+
str r9, [r3]
29+
bl vfp_entry
30+
ldr pc, [sp], #8
2831
ENDPROC(do_vfp)

arch/arm/vfp/vfphw.S

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,14 @@ vfp_hw_state_valid:
172172
@ out before setting an FPEXC that
173173
@ stops us reading stuff
174174
VFPFMXR FPEXC, r1 @ Restore FPEXC last
175+
mov sp, r3 @ we think we have handled things
176+
pop {lr}
175177
sub r2, r2, #4 @ Retry current instruction - if Thumb
176178
str r2, [sp, #S_PC] @ mode it's two 16-bit instructions,
177179
@ else it's one 32-bit instruction, so
178180
@ always subtract 4 from the following
179181
@ instruction address.
180182

181-
mov lr, r3 @ we think we have handled things
182183
local_bh_enable_and_ret:
183184
adr r0, .
184185
mov r1, #SOFTIRQ_DISABLE_OFFSET
@@ -209,8 +210,9 @@ skip:
209210

210211
process_exception:
211212
DBGSTR "bounce"
213+
mov sp, r3 @ setup for a return to the user code.
214+
pop {lr}
212215
mov r2, sp @ nothing stacked - regdump is at TOS
213-
mov lr, r3 @ setup for a return to the user code.
214216

215217
@ Now call the C code to package up the bounce to the support code
216218
@ r0 holds the trigger instruction

0 commit comments

Comments
 (0)