]> git.baikalelectronics.ru Git - kernel.git/commit
parisc: Fix ptrace syscall number modification
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 16 Feb 2019 13:10:39 +0000 (16:10 +0300)
committerHelge Deller <deller@gmx.de>
Thu, 21 Feb 2019 19:10:46 +0000 (20:10 +0100)
commitaf55c7e59e5272fd1f2ab1e5b6175402daebfb76
treebd5b70d0de029450d878f044c5df9b2921f3ea08
parent5f51e0299942ffa09bd8221d594b5cf305e87011
parisc: Fix ptrace syscall number modification

Commit c11ff89f79eb ("parisc: Fix and enable seccomp filter support")
introduced a regression in ptrace-based syscall tampering: when tracer
changes syscall number to -1, the kernel fails to initialize %r28 with
-ENOSYS and subsequently fails to return the error code of the failed
syscall to userspace.

This erroneous behaviour could be observed with a simple strace syscall
fault injection command which is expected to print something like this:

$ strace -a0 -ewrite -einject=write:error=enospc echo hello
write(1, "hello\n", 6) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "echo: ", 6) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "write error", 11) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "\n", 1) = -1 ENOSPC (No space left on device) (INJECTED)
+++ exited with 1 +++

After commit c11ff89f79ebc99e698bf261bf58a8bfcc8ae5a5 it loops printing
something like this instead:

write(1, "hello\n", 6../strace: Failed to tamper with process 12345: unexpectedly got no error (return value 0, error 0)
) = 0 (INJECTED)

This bug was found by strace test suite.

Fixes: c11ff89f79eb ("parisc: Fix and enable seccomp filter support")
Cc: stable@vger.kernel.org # v4.5+
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Tested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>
arch/parisc/kernel/ptrace.c