linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v9 2/6] arm64: ptrace: allow tracer to skip a system call
Date: Wed, 26 Nov 2014 13:02:52 +0000	[thread overview]
Message-ID: <20141126130252.GI14866@arm.com> (raw)
In-Reply-To: <1416977391-24231-3-git-send-email-takahiro.akashi@linaro.org>

On Wed, Nov 26, 2014 at 04:49:47AM +0000, AKASHI Takahiro wrote:
> If tracer modifies a syscall number to -1, this traced system call should
> be skipped with a return value specified in x0.
> This patch implements this semantics.
> 
> Please note:
> * syscall entry tracing and syscall exit tracing (ftrace tracepoint and
>   audit) are always executed, if enabled, even when skipping a system call
>   (that is, -1).
>   In this way, we can avoid a potential bug where audit_syscall_entry()
>   might be called without audit_syscall_exit() at the previous system call
>   being called, that would cause OOPs in audit_syscall_entry().
> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>  arch/arm64/kernel/entry.S |   10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> index 726b910..946ec52 100644
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -161,6 +161,7 @@
>   */
>  sc_nr	.req	x25		// number of system calls
>  scno	.req	x26		// syscall number
> +scno_w	.req	w26		// syscall number (lower 32 bits)
>  stbl	.req	x27		// syscall table pointer
>  tsk	.req	x28		// current thread_info
>  
> @@ -668,8 +669,14 @@ ENDPROC(el0_svc)
>  	 * switches, and waiting for our parent to respond.
>  	 */
>  __sys_trace:
> -	mov	x0, sp
> +	cmp     scno_w, #-1			// set default errno for

I hate that we have to use scno_w, but the only alternative I can think of
is using w8 directly, which isn't any better and doesn't work for compat.
Ho-hum, I guess we'll stick with what you have.

> +	b.ne	1f				// user-issued syscall(-1)
> +	mov	x0, #-ENOSYS
> +	str	x0, [sp]

Can you use #S_X0 here for clarity, please?

> +1:	mov	x0, sp
>  	bl	syscall_trace_enter
> +	cmp	w0, #-1				// skip the syscall?
> +	b.eq	__sys_trace_return_skipped
>  	adr	lr, __sys_trace_return		// return address
>  	uxtw	scno, w0			// syscall number (possibly new)
>  	mov	x1, sp				// pointer to regs
> @@ -684,6 +691,7 @@ __sys_trace:
>  
>  __sys_trace_return:
>  	str	x0, [sp]			// save returned x0

and update this guy too.

Will

  reply	other threads:[~2014-11-26 13:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-26  4:49 [PATCH v9 0/6] arm64: add seccomp support AKASHI Takahiro
2014-11-26  4:49 ` [PATCH v9 1/6] arm64: ptrace: add NT_ARM_SYSTEM_CALL regset AKASHI Takahiro
2014-11-26 12:41   ` Will Deacon
2014-11-27  5:53     ` AKASHI Takahiro
2014-11-27 14:10       ` Will Deacon
2014-11-28  5:25         ` AKASHI Takahiro
2014-11-26  4:49 ` [PATCH v9 2/6] arm64: ptrace: allow tracer to skip a system call AKASHI Takahiro
2014-11-26 13:02   ` Will Deacon [this message]
2014-11-27  6:46     ` AKASHI Takahiro
2014-11-27 10:07       ` Will Deacon
2014-11-26  4:49 ` [PATCH v9 3/6] asm-generic: add generic seccomp.h for secure computing mode 1 AKASHI Takahiro
2014-11-26  4:49 ` [PATCH v9 4/6] arm64: add seccomp syscall for compat task AKASHI Takahiro
2014-11-26  4:49 ` [PATCH v9 5/6] arm64: add SIGSYS siginfo " AKASHI Takahiro
2014-11-26  4:49 ` [PATCH v9 6/6] arm64: add seccomp support AKASHI Takahiro

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=20141126130252.GI14866@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).