@@ -29,6 +29,7 @@ config ARM64
select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYSCALL_WRAPPER
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
+ select ARCH_HAS_USP_CHECK_SYSCALL
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select ARCH_INLINE_READ_LOCK if !PREEMPT
select ARCH_INLINE_READ_LOCK_BH if !PREEMPT
@@ -11,6 +11,7 @@
#include <asm/fpsimd.h>
#include <asm/syscall.h>
#include <asm/thread_info.h>
+#include <asm/traps.h>
#include <asm/unistd.h>
long compat_arm_syscall(struct pt_regs *regs, int scno);
@@ -71,6 +72,9 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr,
local_daif_restore(DAIF_PROCCTX);
user_exit();
+ if (!usp_check_syscall())
+ force_signal_inject(SIGSEGV, SEGV_MAPERR, GET_USP(regs));
+
if (has_syscall_work(flags)) {
/* set default errno for user-issued syscall(-1) */
if (scno == NO_SYSCALL)
Allow the user stack pointer value to be checked on system call entry and deliver a SIGSEGV if the check does not pass. Cc: Kees Cook <keescook@chromium.org> Cc: Jann Horn <jannh@google.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Matthew Wilcox <willy@infradead.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Will Deacon <will.deacon@arm.com> --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/syscall.c | 4 ++++ 2 files changed, 5 insertions(+) -- 2.11.0