Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86A6AC43387 for ; Fri, 4 Jan 2019 12:37:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 602D320656 for ; Fri, 4 Jan 2019 12:37:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726198AbfADMh0 (ORCPT ); Fri, 4 Jan 2019 07:37:26 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:41414 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726145AbfADMh0 (ORCPT ); Fri, 4 Jan 2019 07:37:26 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BB64EEBD; Fri, 4 Jan 2019 04:37:25 -0800 (PST) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CBA4B3F5D4; Fri, 4 Jan 2019 04:37:24 -0800 (PST) Date: Fri, 4 Jan 2019 12:37:19 +0000 From: Dave Martin To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org, pihsun@chromium.org Subject: Re: [PATCH 2/3] arm64: compat: Don't pull syscall number from regs in arm_compat_syscall Message-ID: <20190104123706.GA3571@e103592.cambridge.arm.com> References: <1546539240-20647-1-git-send-email-will.deacon@arm.com> <1546539240-20647-3-git-send-email-will.deacon@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1546539240-20647-3-git-send-email-will.deacon@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 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: > Cc: Dave Martin > Cc: Pi-Hsun Shih > Signed-off-by: Will Deacon > --- > 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 > #include > > -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