All of lore.kernel.org
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] arm64: Mirror arm for unimplemented compat syscalls
Date: Mon, 29 Jan 2018 15:37:30 +0000	[thread overview]
Message-ID: <20180129153730.GA24444@arm.com> (raw)
In-Reply-To: <20180122212026.26262-3-michael.weiser@gmx.de>

Hi Michael,

On Mon, Jan 22, 2018 at 10:20:26PM +0100, Michael Weiser wrote:
> Mirror arm behaviour for unimplemented syscalls: Below 2048 return
> -ENOSYS. Above 2048 raise SIGILL and print a ratelimited message with
> details. dump_instr() is made non-static and added to system_misc.h so
> it can be used in compat_arm_syscall(). Also it is synced with the arm
> implementation to support thumb instructions.
> 
> Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
> ---
>  arch/arm64/include/asm/system_misc.h |  1 +
>  arch/arm64/kernel/sys_compat.c       | 27 ++++++++++++++++++++++++++-
>  arch/arm64/kernel/traps.c            | 14 ++++++++++----
>  3 files changed, 37 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/system_misc.h b/arch/arm64/include/asm/system_misc.h
> index 07aa8e3c5630..0f73b6c1ca63 100644
> --- a/arch/arm64/include/asm/system_misc.h
> +++ b/arch/arm64/include/asm/system_misc.h
> @@ -42,6 +42,7 @@ void hook_debug_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
>  struct mm_struct;
>  extern void show_pte(unsigned long addr);
>  extern void __show_regs(struct pt_regs *);
> +extern void dump_instr(const char *lvl, struct pt_regs *regs);
>  
>  extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
>  
> diff --git a/arch/arm64/kernel/sys_compat.c b/arch/arm64/kernel/sys_compat.c
> index 8b8bbd3eaa52..3a5b3809b671 100644
> --- a/arch/arm64/kernel/sys_compat.c
> +++ b/arch/arm64/kernel/sys_compat.c
> @@ -27,6 +27,7 @@
>  #include <linux/uaccess.h>
>  
>  #include <asm/cacheflush.h>
> +#include <asm/system_misc.h>
>  #include <asm/unistd.h>
>  
>  static long
> @@ -67,6 +68,7 @@ do_compat_cache_op(unsigned long start, unsigned long end, int flags)
>   */
>  long compat_arm_syscall(struct pt_regs *regs)
>  {
> +	siginfo_t info;
>  	unsigned int no = regs->regs[7];
>  
>  	switch (no) {
> @@ -99,6 +101,31 @@ long compat_arm_syscall(struct pt_regs *regs)
>  		return 0;
>  
>  	default:
> -		return -ENOSYS;
> +		/*
> +		 * Calls 9f00xx..9f07ff are defined to return -ENOSYS
> +		 * if not implemented, rather than raising SIGILL. This
> +		 * way the calling program can gracefully determine whether
> +		 * a feature is supported.
> +		 */
> +		if ((no & 0xffff) <= 0x7ff)
> +			return -ENOSYS;
> +		break;
>  	}
> +
> +	if (show_unhandled_signals_ratelimited()) {
> +		pr_err("[%d] %s: arm syscall %d\n",
> +		       task_pid_nr(current), current->comm, no);
> +		dump_instr("", regs);
> +		if (user_mode(regs))
> +			__show_regs(regs);
> +	}
> +
> +	info.si_signo = SIGILL;
> +	info.si_errno = 0;
> +	info.si_code  = ILL_ILLTRP;
> +	info.si_addr  = (void __user *)instruction_pointer(regs) -
> +			 (compat_thumb_mode(regs) ? 2 : 4);
> +
> +	arm64_notify_die("Oops - bad syscall(2)", regs, &info, no);
> +	return 0;

Whilst I think it's worth mirroring the SIGILL behaviour here, I don't think
we need to both with the show_unhandled_signals_ratelimited() hunk. It's
predicated on CONFI_DEBUG_USER for arch/arm/ anyway, so it's something that
can be relied upon but really more of a debug aid that we can live without
for now.

So I'd suggest simply dropping that hunk and the changes to __dump_instr.

Cheers,

Will

  reply	other threads:[~2018-01-29 15:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-21 17:44 arm64: Unimplemented syscall kernel message Michael Weiser
2018-01-22 13:18 ` Will Deacon
2018-01-22 21:20   ` [PATCH 0/2] " Michael Weiser
2018-01-22 21:20     ` [PATCH 1/2] arm64: Remove unimplemented syscall log message Michael Weiser
2018-01-29 15:38       ` Will Deacon
2018-01-22 21:20     ` [PATCH 2/2] arm64: Mirror arm for unimplemented compat syscalls Michael Weiser
2018-01-29 15:37       ` Will Deacon [this message]
2018-02-01 22:13   ` [PATCH v2 0/2] arm64: Unimplemented syscall kernel message Michael Weiser
2018-02-01 22:13     ` [PATCH v2 1/3] arm64: Remove unimplemented syscall log message Michael Weiser
2018-02-01 22:13     ` [PATCH v2 2/3] arm64: Mirror arm for unimplemented compat syscalls Michael Weiser
2018-02-01 22:13     ` [PATCH v2 3/3] arm64: Disable unhandled signal log messages by default Michael Weiser
2018-02-19 15:39     ` [PATCH v2 0/2] arm64: Unimplemented syscall kernel message 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=20180129153730.GA24444@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 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.