Re: [PATCH v2] parisc: Fix ptrace syscall number modification

From: Dmitry V. Levin
Date: Sat Feb 16 2019 - 17:43:02 EST


On Sat, Feb 16, 2019 at 05:55:24PM +0100, Helge Deller wrote:
> On 16.02.19 14:10, Dmitry V. Levin wrote:
> > Commit 910cd32e552e ("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 910cd32e552ea09caa89cdbe328e468979b030dd 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: 910cd32e552e ("parisc: Fix and enable seccomp filter support")
> > Cc: stable@xxxxxxxxxxxxxxx # v4.5+
> > Signed-off-by: Dmitry V. Levin <ldv@xxxxxxxxxxxx>
>
> Thanks, the patch works as expected.
> You may add:
> Tested-by: Helge Deller <deller@xxxxxx>
>
> There is an "out" label a few lines below, which should be removed as well.
> Otherwise you get this warning:
> arch/parisc/kernel/ptrace.c: In function âdo_syscall_trace_enterâ:
> arch/parisc/kernel/ptrace.c:357:1: warning: label âoutâ defined but not used [-Wunused-label]
>
> I've fixed it up locally and added the patch to my for-next tree.
> If it's ok for you, I'll push it through the parisc tree.

It's fine with me, thanks!


--
ldv

Attachment: signature.asc
Description: PGP signature