Skip to content

Commit 5af2ed3

Browse files
jcowgillralfbaechle
authored andcommitted
MIPS: Remove pt_regs adjustments in indirect syscall handler
If a restartable syscall is called using the indirect o32 syscall handler - eg: syscall(__NR_waitid, ...), then it is possible for the incorrect arguments to be passed to the syscall after it has been restarted. This is because the syscall handler tries to shift all the registers down one place in pt_regs so that when the syscall is restarted, the "real" syscall is called instead. Unfortunately it only shifts the arguments passed in registers, not the arguments on the user stack. This causes the 4th argument to be duplicated when the syscall is restarted. Fix by removing all the pt_regs shifting so that the indirect syscall handler is called again when the syscall is restarted. The comment "some syscalls like execve get their arguments from struct pt_regs" is long out of date so this should now be safe. Signed-off-by: James Cowgill <James.Cowgill@imgtec.com> Reviewed-by: James Hogan <james.hogan@imgtec.com> Tested-by: James Hogan <james.hogan@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/15856/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 3d729de commit 5af2ed3

2 files changed

Lines changed: 0 additions & 17 deletions

File tree

arch/mips/kernel/scall32-o32.S

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,6 @@ illegal_syscall:
190190
sll t1, t0, 2
191191
beqz v0, einval
192192
lw t2, sys_call_table(t1) # syscall routine
193-
sw a0, PT_R2(sp) # call routine directly on restart
194-
195-
/* Some syscalls like execve get their arguments from struct pt_regs
196-
and claim zero arguments in the syscall table. Thus we have to
197-
assume the worst case and shuffle around all potential arguments.
198-
If you want performance, don't use indirect syscalls. */
199193

200194
move a0, a1 # shift argument registers
201195
move a1, a2
@@ -207,11 +201,6 @@ illegal_syscall:
207201
sw t4, 16(sp)
208202
sw t5, 20(sp)
209203
sw t6, 24(sp)
210-
sw a0, PT_R4(sp) # .. and push back a0 - a3, some
211-
sw a1, PT_R5(sp) # syscalls expect them there
212-
sw a2, PT_R6(sp)
213-
sw a3, PT_R7(sp)
214-
sw a3, PT_R26(sp) # update a3 for syscall restarting
215204
jr t2
216205
/* Unreached */
217206

arch/mips/kernel/scall64-o32.S

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ LEAF(sys32_syscall)
198198
dsll t1, t0, 3
199199
beqz v0, einval
200200
ld t2, sys32_call_table(t1) # syscall routine
201-
sd a0, PT_R2(sp) # call routine directly on restart
202201

203202
move a0, a1 # shift argument registers
204203
move a1, a2
@@ -207,11 +206,6 @@ LEAF(sys32_syscall)
207206
move a4, a5
208207
move a5, a6
209208
move a6, a7
210-
sd a0, PT_R4(sp) # ... and push back a0 - a3, some
211-
sd a1, PT_R5(sp) # syscalls expect them there
212-
sd a2, PT_R6(sp)
213-
sd a3, PT_R7(sp)
214-
sd a3, PT_R26(sp) # update a3 for syscall restarting
215209
jr t2
216210
/* Unreached */
217211

0 commit comments

Comments
 (0)