All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: sparclinux@vger.kernel.org
Subject: Re: using ptrace to cancel a syscall on sparc
Date: Tue, 19 Jan 2016 19:39:53 +0000	[thread overview]
Message-ID: <20160119.143953.133998620717754795.davem@davemloft.net> (raw)
In-Reply-To: <20151220054754.GZ11489@vapier.lan>

From: Mike Frysinger <vapier@gentoo.org>
Date: Mon, 18 Jan 2016 06:32:30 -0500

> looks like the bug is in arch/sparc/kernel/syscalls.S:linux_syscall_trace32
> (and linux_syscall_trace).  they don't reload the args from the pt_regs
> struct after calling syscall_trace_enter.  i put in a small hack:
> linux_syscall_trace32:
> 	call	syscall_trace_enter
> 	 add	%sp, PTREGS_OFF, %o0
> 	brnz,pn	%o0, 3f
> 	 mov	-ENOSYS, %o0
> +
> +	ldx	[%sp + PTREGS_OFF + PT_V9_G1], %g1
> +	cmp	%g1, NR_syscalls
> =	bgeu,pn	%xcc, 3f
> +	 mov	-ENOSYS, %o0
> +
> 	srl	%i0, 0, %o0
> 	srl	%i4, 0, %o4
> ...
> 
> it's enough for my use case (cancel the call), but it's not entirely correct.
> i think it needs to re-initialize %l7 with the final syscall pointer via the
> syscall table, and it needs to reload PT_V9_I{0..5}.  i have no idea which
> regs need stuffing though, especially in light of the %l7 optimization.  and
> i'm not familiar at all with the apparent parallelism via IEU0/IEU1 groups.
> so i won't bother with trying to write a full patch.  hopefully sparc guys
> will notice & post a fix ;).

Thanks Mike, indeed this code is problematic.

We definitely need to reload all of the syscall registers (%o0-%o5,
%g1), revalidate the range of the syscall number in %g1, and if that
passes recompute the syscall table entry.

I'll work on a complete fix, thanks a lot for reporting this!

  parent reply	other threads:[~2016-01-19 19:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-20  5:47 using ptrace to cancel a syscall on sparc Mike Frysinger
2015-12-20 23:31 ` Dmitry V. Levin
2016-01-18 11:32 ` Mike Frysinger
2016-01-19 19:39 ` David Miller [this message]
2016-01-19 20:10 ` David Miller
2016-01-19 20:56 ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160119.143953.133998620717754795.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=sparclinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.