linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Dave Martin <Dave.Martin@arm.com>
To: Will Deacon <will.deacon@arm.com>
Cc: pihsun@chromium.org, stable@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/3] arm64: compat: Don't pull syscall number from regs in arm_compat_syscall
Date: Fri, 4 Jan 2019 12:37:19 +0000	[thread overview]
Message-ID: <20190104123706.GA3571@e103592.cambridge.arm.com> (raw)
In-Reply-To: <1546539240-20647-3-git-send-email-will.deacon@arm.com>

On Thu, Jan 03, 2019 at 06:13:59PM +0000, Will Deacon wrote:
> The syscall number may have been changed by a tracer, so we should pass
> the actual number in from the caller instead of pulling it from the
> saved r7 value directly.

Reviewed-by: Dave Martin <Dave.Martin@arm.com>

I was confused by the history here: commit 4141c857fd09 ("arm64: convert
raw syscall invocation to C") breaks syscall changing via
discarding the return from syscall_trace_enter() (which would also break
this case for compat), but the subsequent patch that migrates the
syscall code to C appears to fix it again.

> 
> Cc: <stable@vger.kernel.org>
> Cc: Dave Martin <Dave.Martin@arm.com>
> Cc: Pi-Hsun Shih <pihsun@chromium.org>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm64/kernel/sys_compat.c | 9 ++++-----
>  arch/arm64/kernel/syscall.c    | 9 ++++-----
>  2 files changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm64/kernel/sys_compat.c b/arch/arm64/kernel/sys_compat.c
> index 5972b7533fa0..54c29cd38ff9 100644
> --- a/arch/arm64/kernel/sys_compat.c
> +++ b/arch/arm64/kernel/sys_compat.c
> @@ -66,12 +66,11 @@ do_compat_cache_op(unsigned long start, unsigned long end, int flags)
>  /*
>   * Handle all unrecognised system calls.
>   */
> -long compat_arm_syscall(struct pt_regs *regs)
> +long compat_arm_syscall(struct pt_regs *regs, int scno)
>  {
> -	unsigned int no = regs->regs[7];
>  	void __user *addr;
>  
> -	switch (no) {
> +	switch (scno) {
>  	/*
>  	 * Flush a region from virtual address 'r0' to virtual address 'r1'
>  	 * _exclusive_.  There is no alignment requirement on either address;
> @@ -107,7 +106,7 @@ long compat_arm_syscall(struct pt_regs *regs)
>  		 * way the calling program can gracefully determine whether
>  		 * a feature is supported.
>  		 */
> -		if (no < __ARM_NR_compat_syscall_end)
> +		if (scno < __ARM_NR_compat_syscall_end)
>  			return -ENOSYS;
>  		break;
>  	}
> @@ -116,6 +115,6 @@ long compat_arm_syscall(struct pt_regs *regs)
>  		(compat_thumb_mode(regs) ? 2 : 4);
>  
>  	arm64_notify_die("Oops - bad compat syscall(2)", regs,
> -			 SIGILL, ILL_ILLTRP, addr, no);
> +			 SIGILL, ILL_ILLTRP, addr, scno);
>  	return 0;
>  }
> diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c
> index 032d22312881..5610ac01c1ec 100644
> --- a/arch/arm64/kernel/syscall.c
> +++ b/arch/arm64/kernel/syscall.c
> @@ -13,16 +13,15 @@
>  #include <asm/thread_info.h>
>  #include <asm/unistd.h>
>  
> -long compat_arm_syscall(struct pt_regs *regs);
> -
> +long compat_arm_syscall(struct pt_regs *regs, int scno);
>  long sys_ni_syscall(void);
>  
> -asmlinkage long do_ni_syscall(struct pt_regs *regs)
> +static long do_ni_syscall(struct pt_regs *regs, int scno)
>  {
>  #ifdef CONFIG_COMPAT
>  	long ret;
>  	if (is_compat_task()) {
> -		ret = compat_arm_syscall(regs);
> +		ret = compat_arm_syscall(regs, scno);
>  		if (ret != -ENOSYS)
>  			return ret;
>  	}
> @@ -47,7 +46,7 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno,
>  		syscall_fn = syscall_table[array_index_nospec(scno, sc_nr)];
>  		ret = __invoke_syscall(regs, syscall_fn);
>  	} else {
> -		ret = do_ni_syscall(regs);
> +		ret = do_ni_syscall(regs, scno);
>  	}
>  
>  	regs->regs[0] = ret;
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2019-01-04 12:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-03 18:13 [PATCH 0/3] Fix private compat syscall emulation Will Deacon
2019-01-03 18:13 ` [PATCH 1/3] arm64: compat: Avoid sending SIGILL for unallocated syscall numbers Will Deacon
2019-01-04  4:50   ` Sasha Levin
2019-01-04 12:54   ` Dave Martin
2019-01-04 13:47     ` Will Deacon
2019-01-04 14:15       ` Dave Martin
2019-01-03 18:13 ` [PATCH 2/3] arm64: compat: Don't pull syscall number from regs in arm_compat_syscall Will Deacon
2019-01-04  4:50   ` Sasha Levin
2019-01-04 12:37   ` Dave Martin [this message]
2019-01-03 18:14 ` [PATCH 3/3] arm64: compat: Hook up io_pgetevents() for 32-bit tasks Will Deacon

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=20190104123706.GA3571@e103592.cambridge.arm.com \
    --to=dave.martin@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=pihsun@chromium.org \
    --cc=stable@vger.kernel.org \
    --cc=will.deacon@arm.com \
    /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).