parisc: Fix ptrace syscall number and return value modification
authorHelge Deller <deller@gmx.de>
Tue, 19 Jan 2016 15:08:49 +0000 (16:08 +0100)
committerSasha Levin <sasha.levin@oracle.com>
Wed, 9 Mar 2016 18:15:23 +0000 (13:15 -0500)
commitb8ad68546922dd5acb6cd32628bc9ae69a4795f9
tree6a83a1c4957406beecd123a1aa3a21b9978e6595
parentebe15c00057a4efad2bae1a90b04a20766cefc8c
parisc: Fix ptrace syscall number and return value modification

[ Upstream commit 98e8b6c9ac9d1b1e9d1122dfa6783d5d566bb8f7 ]

Mike Frysinger reported that his ptrace testcase showed strange
behaviour on parisc: It was not possible to avoid a syscall and the
return value of a syscall couldn't be changed.

To modify a syscall number, we were missing to save the new syscall
number to gr20 which is then picked up later in assembly again.

The effect that the return value couldn't be changed is a side-effect of
another bug in the assembly code. When a process is ptraced, userspace
expects each syscall to report entrance and exit of a syscall.  If a
syscall number was given which doesn't exist, we jumped to the normal
syscall exit code instead of informing userspace that the (non-existant)
syscall exits. This unexpected behaviour confuses userspace and thus the
bug was misinterpreted as if we can't change the return value.

This patch fixes both problems and was tested on 64bit kernel with
32bit userspace.

Signed-off-by: Helge Deller <deller@gmx.de>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: stable@vger.kernel.org # v4.0+
Tested-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
arch/parisc/kernel/ptrace.c
arch/parisc/kernel/syscall.S