From patchwork Mon Sep 7 15:36:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11761295 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 383BD59D for ; Mon, 7 Sep 2020 15:39:53 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 097C92078E for ; Mon, 7 Sep 2020 15:39:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IzCD/Cap" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 097C92078E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dy7tj3yR35lpAuxpKiEtEQC5977INQZtryNO1zN8Lnk=; b=IzCD/CaptMID1CPSYhGEjSvJ+ YwIuf554ejNmS9d4yZ0hV1/R7uKF6hmD+fhY7gATnYJjO5g9XSriq368Eo8cxFaGxhKh3TzyMvc2M nN+By2hAhr2xBhr8pWJhVIygbcVeP5JfloLzDYJpwDlmhHpnh9j3yKH3vqLWROnOBvUwWPwYICgV3 dtuF3fGsSzfpOBnSWu8/4N8SUnWExDSJSYlnQ/T4oX8tuGjozI5XaZNoYI+EvIqwMDck81WGCOjwe AZxumdg6QT4S/6O+YIpK+/gp9jlpZ4xsrMH9+oi65sKTXoNmeTc75XTr4o9nrDADZyDLu08EWYxTN WoNkzqcBA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFJE6-0003ZA-C5; Mon, 07 Sep 2020 15:38:38 +0000 Received: from mout.kundenserver.de ([212.227.17.24]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFJE3-0003Xw-9Z for linux-arm-kernel@lists.infradead.org; Mon, 07 Sep 2020 15:38:36 +0000 Received: from threadripper.lan ([149.172.98.151]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1MDQqe-1kMUkb2t1S-00AYvP; Mon, 07 Sep 2020 17:38:31 +0200 From: Arnd Bergmann To: Christoph Hellwig , Russell King Subject: [PATCH 4/9] ARM: syscall: always store thread_info->syscall Date: Mon, 7 Sep 2020 17:36:45 +0200 Message-Id: <20200907153701.2981205-5-arnd@arndb.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200907153701.2981205-1-arnd@arndb.de> References: <20200907153701.2981205-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:uU+TecuTqu0R9F35nqN09r3ArM9MaO4zXOfC9fDMIDMEVEKC175 eHZUfwQdTB/7fFkfB+W0xXhaL/XvLVtfh3ZII8xq2BsysD5q1nM3wenG7EjjevHA85Ih0AQ mlXzjl7IH/NziTpdbHjgoDEHpe7jzEJLgqK6PF4xOwmTCdV9zJyccr74NZVuFw3sxfvZd7S 1XP2KfBS6lM4e4HWdXgDg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:Z/SwDeuaCd0=:/46zD3F6r+k7KbKrKJm1ST V4MN6RGZ+H8tKnSPMQ+oAHnTre6MUpHwHidwDxZ7ty7CnjAPZxSZYfVivHg3KZFy7A/x5nMSE sXprY3IsstN25hPLLiGjkm2HlrJt0i67Dq/9Xa9T6FVkZRs0oMgjT8NW6Uh4Ddq4PO3Hmnr0p V1yS0OD8FAkDDJ2FmZIUTCDoQ6bq8vDbzTUV0x5MkULGCQRP8G2JowviiZIBEl14AtOX7moWs Yg0TrDqtfQzAcBZ9kKD1HOuailFV/WXNLQpfYBxCMHR7D3t/qWjlOy002kCPtCN2BP+KeQL07 Jpr/dKZAKy+TRbTicE4OM/jNBu5qMlxQo6Il4OkBp/UqOH6qEBfggVcyXeyw0PgtGIXBFndA2 xXNFHYa87PqLRbeE3tafQLd76jeYC9eB+s0+Zxk8dwPaYYDi2YO+vVzsZ2ZxZWIx8uMZu3LHJ jZqbY4rkdNYyuAe09LIQeDPHvXLn2refM0ZgHYHjSmvyQIpYPiaKNLeeCgEtVS03UZdtLfHtC hTAYWDucfXShXAR+cHKaE0M96whTL+Q14f22PHX0E8VVOIxoqrhwebvpc3MfZ2ovrYW0YGK+q TIjxM1ZdJMnbbWaXKJ8aEp+I8iumE+pV7jlMjAi3pkS62KvSO0TkAT27iW3rKBRFSFjmdD22B aRFUozwW4aXk+RsX6dxUObqOIQXGsNwpSnkSOoIDmqR0wiEOQBMzznBi5Rs+wpWVDeVPY82qN D/sPt8sRdQRhxegfrLVm3g2NzxwJh09lh3qXuFCI/SUKoJ4UkbI9bOBygLAbDzomJR1gZL4va Wc1hhmPUEokG2APXShmXD//MqjIAM9d5dcAYfSF77VJ/zvGS5FIC6NCQ75rzLAynBQaNqHs X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200907_113835_552106_4FA8F469 X-CRM114-Status: GOOD ( 18.86 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.17.24 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.17.24 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org, linus.walleij@linaro.org, kernel@vger.kernel.org, Russell King , Oleg Nesterov , Alexander Viro , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The system call number is used in a a couple of places, in particular ptrace, seccomp and /proc//syscall. The last one apparently never worked reliably on ARM for tasks that are not currently getting traced. Storing the syscall number in the normal entry path makes it work, as well as allowing us to see if the current system call is for OABI compat mode, which is the next thing I want to hook into. Signed-off-by: Arnd Bergmann --- arch/arm/include/asm/syscall.h | 3 +++ arch/arm/kernel/asm-offsets.c | 1 + arch/arm/kernel/entry-common.S | 7 +++++-- arch/arm/kernel/ptrace.c | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h index fd02761ba06c..ff6cc365eaf7 100644 --- a/arch/arm/include/asm/syscall.h +++ b/arch/arm/include/asm/syscall.h @@ -22,6 +22,9 @@ extern const unsigned long sys_call_table[]; static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs) { + if (IS_ENABLED(CONFIG_OABI_COMPAT)) + return task_thread_info(task)->syscall & ~__NR_OABI_SYSCALL_BASE; + return task_thread_info(task)->syscall; } diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c index a1570c8bab25..97af6735172b 100644 --- a/arch/arm/kernel/asm-offsets.c +++ b/arch/arm/kernel/asm-offsets.c @@ -46,6 +46,7 @@ int main(void) DEFINE(TI_CPU, offsetof(struct thread_info, cpu)); DEFINE(TI_CPU_DOMAIN, offsetof(struct thread_info, cpu_domain)); DEFINE(TI_CPU_SAVE, offsetof(struct thread_info, cpu_context)); + DEFINE(TI_SYSCALL, offsetof(struct thread_info, syscall)); DEFINE(TI_USED_CP, offsetof(struct thread_info, used_cp)); DEFINE(TI_TP_VALUE, offsetof(struct thread_info, tp_value)); DEFINE(TI_FPSTATE, offsetof(struct thread_info, fpstate)); diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index 271cb8a1eba1..2ea3a1989fed 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -223,6 +223,7 @@ ENTRY(vector_swi) /* saved_psr and saved_pc are now dead */ uaccess_disable tbl + get_thread_info tsk adr tbl, sys_call_table @ load syscall table pointer @@ -234,13 +235,16 @@ ENTRY(vector_swi) * get the old ABI syscall table address. */ bics r10, r10, #0xff000000 + str r10, [tsk, #TI_SYSCALL] eorne scno, r10, #__NR_OABI_SYSCALL_BASE ldrne tbl, =sys_oabi_call_table #elif !defined(CONFIG_AEABI) bic scno, scno, #0xff000000 @ mask off SWI op-code + str scno, [tsk, #TI_SYSCALL] eor scno, scno, #__NR_SYSCALL_BASE @ check OS number +#else + str scno, [tsk, #TI_SYSCALL] #endif - get_thread_info tsk /* * Reload the registers that may have been corrupted on entry to * the syscall assembly (by tracing or context tracking.) @@ -285,7 +289,6 @@ ENDPROC(vector_swi) * context switches, and waiting for our parent to respond. */ __sys_trace: - mov r1, scno add r0, sp, #S_OFF bl syscall_trace_enter mov scno, r0 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index 2771e682220b..252060663b00 100644 --- a/arch/arm/kernel/ptrace.c +++ b/arch/arm/kernel/ptrace.c @@ -885,9 +885,9 @@ static void tracehook_report_syscall(struct pt_regs *regs, regs->ARM_ip = ip; } -asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno) +asmlinkage int syscall_trace_enter(struct pt_regs *regs) { - current_thread_info()->syscall = scno; + int scno; if (test_thread_flag(TIF_SYSCALL_TRACE)) tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);