diff options
author | Mike Frysinger <vapier@gentoo.org> | 2016-01-18 06:32:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-01-21 16:06:00 -0800 |
commit | 1a40b95374f680625318ab61d81958e949e0afe3 (patch) | |
tree | 6340453bf231d117cd93aa6cc02556af3403ae2f /arch/sparc/kernel/entry.S | |
parent | c10910c323bb9e7fc53ba25c83d1adeb9fb20878 (diff) | |
download | linux-1a40b95374f680625318ab61d81958e949e0afe3.tar.gz linux-1a40b95374f680625318ab61d81958e949e0afe3.tar.bz2 linux-1a40b95374f680625318ab61d81958e949e0afe3.zip |
sparc: Fix system call tracing register handling.
A system call trace trigger on entry allows the tracing
process to inspect and potentially change the traced
process's registers.
Account for that by reloading the %g1 (syscall number)
and %i0-%i5 (syscall argument) values. We need to be
careful to revalidate the range of %g1, and reload the
system call table entry it corresponds to into %l7.
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Tested-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/sparc/kernel/entry.S')
-rw-r--r-- | arch/sparc/kernel/entry.S | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S index 33c02b15f478..a83707c83be8 100644 --- a/arch/sparc/kernel/entry.S +++ b/arch/sparc/kernel/entry.S @@ -948,7 +948,24 @@ linux_syscall_trace: cmp %o0, 0 bne 3f mov -ENOSYS, %o0 + + /* Syscall tracing can modify the registers. */ + ld [%sp + STACKFRAME_SZ + PT_G1], %g1 + sethi %hi(sys_call_table), %l7 + ld [%sp + STACKFRAME_SZ + PT_I0], %i0 + or %l7, %lo(sys_call_table), %l7 + ld [%sp + STACKFRAME_SZ + PT_I1], %i1 + ld [%sp + STACKFRAME_SZ + PT_I2], %i2 + ld [%sp + STACKFRAME_SZ + PT_I3], %i3 + ld [%sp + STACKFRAME_SZ + PT_I4], %i4 + ld [%sp + STACKFRAME_SZ + PT_I5], %i5 + cmp %g1, NR_syscalls + bgeu 3f + mov -ENOSYS, %o0 + + sll %g1, 2, %l4 mov %i0, %o0 + ld [%l7 + %l4], %l7 mov %i1, %o1 mov %i2, %o2 mov %i3, %o3 |