Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>, Kees Cook <keescook@chromium.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64: fix function types in COND_SYSCALL
Date: Wed, 11 Sep 2019 16:15:46 +0100
Message-ID: <20190911151545.GD3360@blommer> (raw)
In-Reply-To: <20190910224044.100388-1-samitolvanen@google.com>

On Tue, Sep 10, 2019 at 03:40:44PM -0700, Sami Tolvanen wrote:
> Define a weak function in COND_SYSCALL instead of a weak alias to
> sys_ni_syscall, which has an incompatible type. This fixes indirect
> call mismatches with Control-Flow Integrity (CFI) checking.
> 
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

This looks correct to me, builds fine, and I asume has been tested, so FWIW:

Acked-by: Mark Rutland <mark.rutland@arm.com>

In looking at this, I came to the conclusion that we can drop the ifdeffery
around our SYSCALL_DEFINE0(), COND_SYSCALL(), and SYS_NI(), which I evidently
cargo-culted from x86 (where the ifdeffery is actually necessary).

I can send a follow up for that.

Thanks,
Mark.

> ---
>  arch/arm64/include/asm/syscall_wrapper.h | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/syscall_wrapper.h b/arch/arm64/include/asm/syscall_wrapper.h
> index 507d0ee6bc69..06d880b3526c 100644
> --- a/arch/arm64/include/asm/syscall_wrapper.h
> +++ b/arch/arm64/include/asm/syscall_wrapper.h
> @@ -8,6 +8,8 @@
>  #ifndef __ASM_SYSCALL_WRAPPER_H
>  #define __ASM_SYSCALL_WRAPPER_H
>  
> +struct pt_regs;
> +
>  #define SC_ARM64_REGS_TO_ARGS(x, ...)				\
>  	__MAP(x,__SC_ARGS					\
>  	      ,,regs->regs[0],,regs->regs[1],,regs->regs[2]	\
> @@ -35,8 +37,11 @@
>  	ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO);			\
>  	asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused)
>  
> -#define COND_SYSCALL_COMPAT(name) \
> -	cond_syscall(__arm64_compat_sys_##name);
> +#define COND_SYSCALL_COMPAT(name) 							\
> +	asmlinkage long __weak __arm64_compat_sys_##name(const struct pt_regs *regs)	\
> +	{										\
> +		return sys_ni_syscall();						\
> +	}
>  
>  #define COMPAT_SYS_NI(name) \
>  	SYSCALL_ALIAS(__arm64_compat_sys_##name, sys_ni_posix_timers);
> @@ -70,7 +75,11 @@
>  #endif
>  
>  #ifndef COND_SYSCALL
> -#define COND_SYSCALL(name) cond_syscall(__arm64_sys_##name)
> +#define COND_SYSCALL(name)							\
> +	asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs)	\
> +	{									\
> +		return sys_ni_syscall();					\
> +	}
>  #endif
>  
>  #ifndef SYS_NI
> -- 
> 2.23.0.162.g0b9fbb3734-goog
> 

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

  reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10 22:40 Sami Tolvanen
2019-09-11 15:15 ` Mark Rutland [this message]
2019-09-12 13:11   ` Will Deacon
2019-09-13 11:33     ` Mark Rutland

Reply instructions:

You may reply publically 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=20190911151545.GD3360@blommer \
    --to=mark.rutland@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=keescook@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samitolvanen@google.com \
    --cc=will@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

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git