From patchwork Thu May 23 09:06:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 164948 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1913662ili; Thu, 23 May 2019 02:06:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4VO2uh+tFfK3t/+3JMNadfPszXxPd6VINk5Yz4JIJpXUW0DLhiPG1ZGcKRATjPeuDKvgx X-Received: by 2002:a17:902:bd94:: with SMTP id q20mr74074807pls.146.1558602397327; Thu, 23 May 2019 02:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558602397; cv=none; d=google.com; s=arc-20160816; b=1E+WU9X6A+5Xnf4ZsRzJAzFJnL874Ftu4z2RKgLbtk7JvGfM/f0WWz0scMV+i2tGpi ZXQ4chEGQ82PFBfR2KYRGZgP74BNJLKXAAxgS7ElzC3PH9LCNUUoVWHJ5oYuetyI0XKO IFMln/q+jf3CJEpqgNzPp1YEgYv04dGWdImKFWPrOo/usrvDVjpDLFoWs/nuoBeo7Xyq sG9hjzEr3MIP7M43W4wlqmGORyma9tk2MxGYCdjjbReejI8MVfwHkAlEVFwegO10FVHp viCNXzf5CtrDGx8oCyHXhugTgnX0FJhNSPunPUeOC7K9k3n9knv665u7YVytBrGHuRWk LKMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=aimtCuPzQEVgfDlhJyeEqqK//gIgFGXq12SDBI9UmpE=; b=uG5sugjLj80O1HzHxxOZ2JPggGLptYDyiMuR8rYTqiIpbssm6kXpeqihApGTK801Q0 8Ixj+JbJobwx4r40r9VxWeXuNQ043zB97k6d5f7btBmNkdPHY+xK0EjSj1Gwyuj3AgTr eXe/JZZ3CnfFpi6EqQJyJyns21PhhVQhX28IpS0RHBXlQlF9nS0XyJ6Ex411TBtHQ/UG P1hcMedOjeRtc3CpwQsyAQ/UutWIFIpUY4kndo271hsSqsPmR43HVUCXj/7kvvFVW4es ak2OVChcwe6latNQInvwRxPPUvvMp6nxvbwNjO7noVS+wrCwlmttHnTse1T7dk+m+kTb 471g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x16si118099pjt.85.2019.05.23.02.06.37; Thu, 23 May 2019 02:06:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730225AbfEWJGg (ORCPT + 30 others); Thu, 23 May 2019 05:06:36 -0400 Received: from foss.arm.com ([217.140.101.70]:40732 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730170AbfEWJGe (ORCPT ); Thu, 23 May 2019 05:06:34 -0400 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 7A6F1A78; Thu, 23 May 2019 02:06:34 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CD7EC3F575; Thu, 23 May 2019 02:06:31 -0700 (PDT) From: Sudeep Holla To: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Catalin Marinas , Will Deacon , Oleg Nesterov , Richard Weinberger , jdike@addtoit.com, Steve Capper , Haibo Xu , Bin Lu , Paul Mackerras , Michael Ellerman , Thomas Gleixner , Ingo Molnar Subject: [PATCH v4 1/4] ptrace: move clearing of TIF_SYSCALL_EMU flag to core Date: Thu, 23 May 2019 10:06:15 +0100 Message-Id: <20190523090618.13410-2-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190523090618.13410-1-sudeep.holla@arm.com> References: <20190523090618.13410-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While the TIF_SYSCALL_EMU is set in ptrace_resume independent of any architecture, currently only powerpc and x86 unset the TIF_SYSCALL_EMU flag in ptrace_disable which gets called from ptrace_detach. Let's move the clearing of TIF_SYSCALL_EMU flag to __ptrace_unlink which gets executed from ptrace_detach and also keep it along with or close to clearing of TIF_SYSCALL_TRACE. Cc: Paul Mackerras Cc: Michael Ellerman Cc: Thomas Gleixner Cc: Ingo Molnar Acked-by: Oleg Nesterov Signed-off-by: Sudeep Holla --- arch/powerpc/kernel/ptrace.c | 1 - arch/x86/kernel/ptrace.c | 3 --- kernel/ptrace.c | 3 +++ 3 files changed, 3 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 684b0b315c32..8c92febf5f44 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -2521,7 +2521,6 @@ void ptrace_disable(struct task_struct *child) { /* make sure the single step bit is not set. */ user_disable_single_step(child); - clear_tsk_thread_flag(child, TIF_SYSCALL_EMU); } #ifdef CONFIG_PPC_ADV_DEBUG_REGS diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 4b8ee05dd6ad..45792dbd2443 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -746,9 +746,6 @@ static int ioperm_get(struct task_struct *target, void ptrace_disable(struct task_struct *child) { user_disable_single_step(child); -#ifdef TIF_SYSCALL_EMU - clear_tsk_thread_flag(child, TIF_SYSCALL_EMU); -#endif } #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 6f357f4fc859..16c7fc1eabcf 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -117,6 +117,9 @@ void __ptrace_unlink(struct task_struct *child) BUG_ON(!child->ptrace); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); +#ifdef TIF_SYSCALL_EMU + clear_tsk_thread_flag(child, TIF_SYSCALL_EMU); +#endif child->parent = child->real_parent; list_del_init(&child->ptrace_entry); From patchwork Thu May 23 09:06:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 164949 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1913724ili; Thu, 23 May 2019 02:06:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1slxEA2QITBiZsiTyI1jUpL5hRR9Ub3RWF5D7gkftTulOpoWUkGVtbAT6Sq9dOwFCVSSk X-Received: by 2002:a63:a449:: with SMTP id c9mr7016727pgp.149.1558602400004; Thu, 23 May 2019 02:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558602399; cv=none; d=google.com; s=arc-20160816; b=mU+MVILQml/n8eebevKJ+AU1oXiDVHjgzSct6fvNEoUfmVBrheJTMOJ6GwcEqtTyhX T+htMy5t84b8yEWGk69cYlkWu/fHKYkaP9shMmD6NVjOmzYRqHlp5B/ut6LIAZ7U+lhP s7mZwiR1wa2wWO3JM8ziJO4E/DhEbEEKLFDeIP5ufeq6c6/6vRMFgMjllCP3atd1bC2G vHEnE4tOUXFb7DmYfQwfZJUPYX8msRxrpOGImw0BKPg7OJWjAIlOPTGJOaZbUq3A+hPn HIPWTtYKk07BO3De7Uf3x2wcsPRlgKkoN2GH2CpNO+YstSy1IKoJ2rwJR0IbdN8mvvvC B+RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=cCASbWwVisKk0+IYaD3kjn19j4r3k7GnMq8Oaal2++I=; b=A7zFaxBHaDP7e76/M8D4EPwVUWKOLF6dledqgW1vtut9iRhhXMNa3pQ1FlNvA3cgt4 FA8SKplqgwCpX+Eg5BCW47naKCLRIpYo3QotVmvgE6u89MbNpG8+zADbtvOyVEmiUJK1 Ci0Isgi4d0kXetEiRrgeNc+/Wyq7PUCmu7zEKTW7dL0220RzaWDIRl+FcVi1GWrywLDR qnxgDacUKU+q3146FDm2FrUzjny09XG1dz26hZjV4AXhcXF5cyGEUUf01ZlaHbt6aT3W b66BcIHtgkB1jqyjz4zSiIXtoWMp8RFU9u0Bqhe38hhk3dPOYrAtgcJpKm9FeoojO07J vUlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x16si118099pjt.85.2019.05.23.02.06.39; Thu, 23 May 2019 02:06:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730245AbfEWJGi (ORCPT + 30 others); Thu, 23 May 2019 05:06:38 -0400 Received: from foss.arm.com ([217.140.101.70]:40756 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729898AbfEWJGh (ORCPT ); Thu, 23 May 2019 05:06:37 -0400 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 66D1515AB; Thu, 23 May 2019 02:06:37 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B9A643F575; Thu, 23 May 2019 02:06:34 -0700 (PDT) From: Sudeep Holla To: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Catalin Marinas , Will Deacon , Oleg Nesterov , Richard Weinberger , jdike@addtoit.com, Steve Capper , Haibo Xu , Bin Lu , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov Subject: [PATCH v4 2/4] x86: simplify _TIF_SYSCALL_EMU handling Date: Thu, 23 May 2019 10:06:16 +0100 Message-Id: <20190523090618.13410-3-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190523090618.13410-1-sudeep.holla@arm.com> References: <20190523090618.13410-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The usage of emulated/_TIF_SYSCALL_EMU flags in syscall_trace_enter seems to be bit overcomplicated than required. Let's simplify it. Cc: Andy Lutomirski Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Acked-by: Oleg Nesterov Signed-off-by: Sudeep Holla --- arch/x86/entry/common.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index a986b3c8294c..0a61705d62ec 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -72,23 +72,18 @@ static long syscall_trace_enter(struct pt_regs *regs) struct thread_info *ti = current_thread_info(); unsigned long ret = 0; - bool emulated = false; u32 work; if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) BUG_ON(regs != task_pt_regs(current)); - work = READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY; + work = READ_ONCE(ti->flags); - if (unlikely(work & _TIF_SYSCALL_EMU)) - emulated = true; - - if ((emulated || (work & _TIF_SYSCALL_TRACE)) && - tracehook_report_syscall_entry(regs)) - return -1L; - - if (emulated) - return -1L; + if (work & (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU)) { + ret = tracehook_report_syscall_entry(regs); + if (ret || (work & _TIF_SYSCALL_EMU)) + return -1L; + } #ifdef CONFIG_SECCOMP /* From patchwork Thu May 23 09:06:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 164950 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1913779ili; Thu, 23 May 2019 02:06:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGD/FYSRTkw1RVfuwprHWMa2XkiBQWuyKi9RnANLp1zGK5Ukl9B0a8Oiru1w1EMA9OTzlD X-Received: by 2002:a63:c106:: with SMTP id w6mr11926639pgf.422.1558602402946; Thu, 23 May 2019 02:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558602402; cv=none; d=google.com; s=arc-20160816; b=oD1Vvg+CCwjRr7DYnYo+AiyU8XCcrcJhMjaOhlXw/VqAZTsoTvxA6mnkxzIelBPhII VIGYlmeZvQzB0+iLR5K3QcMYAYMyERq+xGT7LECKdqjubFTUqazVYGZ4wyyNHI5BimaN sM9W6sdsAxz92QnJoUH6X8p1Mry9K9J3zkynkIOeLSp7xLEv5BhzGwqH4eYMuSTsipPX jhQdb3g5h9FfG/9LryAUa6JlLO5CiR6WeoyfOvhSPbriYBDVlDxAhQBAa5T7tP+IsIOC 3ieJj/F24MGm3uytCYoZbp3RWGGBNWoJ92b8YBwWoD0/De9unfsaiwr89QxrIrNfNIa8 9GgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=g5QQEGQLW//t5dOUXT0AbO58BS980jp6eytiOL7yUPE=; b=bfF/uaB0f8g9TgkeeZBQZIRkf76BGYQF/2YTIfP0cb6G/ZSRIjI2LUnDv9vz+PIayI ppm+XBQl9IhUD7nPLQjowl9cWMO6n8Z0k/zdgJuWNbp2kj0Gz7e8BByViunjzJMH38eA gkKp9kYdaMWgzKkJHVaXEm0YpYxYXOIrS6jJiSyLjUdmP1KD7efXHcDgEHPsRrksnGOj iWOivNa+A0tqfQRZow3cQ/EI0WwN/uRmr/MbQFfshX/oxN4SEmwjOBa64iqbKB9oxOV9 8fiw5hU1cXgqVp8NbgcP+te3Cx7Z/iaxBtAXtoV18DC0w4l2vUaH4Mpkx/7vF6uie6YJ x+eg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4si1821854pgp.592.2019.05.23.02.06.42; Thu, 23 May 2019 02:06:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730276AbfEWJGl (ORCPT + 30 others); Thu, 23 May 2019 05:06:41 -0400 Received: from foss.arm.com ([217.140.101.70]:40776 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729898AbfEWJGj (ORCPT ); Thu, 23 May 2019 05:06:39 -0400 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 C296015BF; Thu, 23 May 2019 02:06:39 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A698E3F575; Thu, 23 May 2019 02:06:37 -0700 (PDT) From: Sudeep Holla To: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Catalin Marinas , Will Deacon , Oleg Nesterov , Richard Weinberger , jdike@addtoit.com, Steve Capper , Haibo Xu , Bin Lu Subject: [PATCH v4 3/4] arm64: add PTRACE_SYSEMU{, SINGLESTEP} definations to uapi headers Date: Thu, 23 May 2019 10:06:17 +0100 Message-Id: <20190523090618.13410-4-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190523090618.13410-1-sudeep.holla@arm.com> References: <20190523090618.13410-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org x86 and um use 31 and 32 for PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP while powerpc uses different value maybe for legacy reasons. Though handling of PTRACE_SYSEMU can be made architecture independent, it's hard to make these definations generic. To add to this existing mess few architectures like arm, c6x and sh use 31 for PTRACE_GETFDPIC (get the ELF fdpic loadmap address). It's not possible to move the definations to generic headers. So we unfortunately have to duplicate the same defination to ARM64 if we need to support PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP. Cc: Catalin Marinas Cc: Will Deacon Signed-off-by: Sudeep Holla --- arch/arm64/include/uapi/asm/ptrace.h | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h index d78623acb649..627ac57c1581 100644 --- a/arch/arm64/include/uapi/asm/ptrace.h +++ b/arch/arm64/include/uapi/asm/ptrace.h @@ -62,6 +62,9 @@ #define PSR_x 0x0000ff00 /* Extension */ #define PSR_c 0x000000ff /* Control */ +/* syscall emulation path in ptrace */ +#define PTRACE_SYSEMU 31 +#define PTRACE_SYSEMU_SINGLESTEP 32 #ifndef __ASSEMBLY__ From patchwork Thu May 23 09:06:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 164951 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1913820ili; Thu, 23 May 2019 02:06:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4c+Ji8Gjg9JRN7o2rUvLT/wT62O0IS4JQB3YAAVRsyZm4RxJZgf/qFypKkp+6MI0UKT+i X-Received: by 2002:a65:554d:: with SMTP id t13mr95025670pgr.171.1558602405479; Thu, 23 May 2019 02:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558602405; cv=none; d=google.com; s=arc-20160816; b=ut+G+dNjOaTiEA/uT3IEc5CtieFaydrx/ceA5gHQxCPwOlzAz4Kt9n5qAf6qdTlUYv Hu7kFI+h/HA06lZXSFK7+9iGOWtOJ11YTpOi38ThDpGdQJgsAcdAO9tQjNnw+VArZCwJ mqOAupoxMDlDwCawi1W3TxmDAQr0wOwpH0vZonml6e4AGu94gXhgp5c4rMZLu3tiX6Xl IcjrLBZiZPRjwx2aUpSd1p49NnOctjFmUDrb4DS6PKKEK3ptT2j3cA+ZBoX8OVZyYv04 knuSC3s5ObkcXWjlIqHVDUJhms2Npp4RHZaF1Hs1embz6rSXVzBvHtqIm6w8N6dp7Pfu DvYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=3ZvwLZCDodsw6fzWUuXOmDQ6/ZwliopnGtXfOoCPfqA=; b=jBxQ4yBC/h2gkXLygxOUFC2yxyVWbTgwzBuhBJA0j+EahYA6uQ9f6FB922AQGvO39l b+/tw55bRstgqtJiqdbLHMzTtY2TVASC6Ilc4dWKs+V5mOOAyP1l6LpfucNRogU7QGXk WlSpzQtJxbfuBep/dSENoOgHE0FCfQmaiAPV4NbKWqilhp4KoZ3XoxscRrNbDQ4qc2T7 zBg0i4ZIrq5S7qNkySP0NjosV7ULTDc3Gl37D8VO22TLSxy6Pq25F5cpqss1SO7dISFl zlNDRlvxcActDg1Jk/puAZu2NllZL+2NzLCFfjsab6OwxiAtGizTbw9l8qPqOHT0WxNK nCTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4si1821854pgp.592.2019.05.23.02.06.45; Thu, 23 May 2019 02:06:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730305AbfEWJGo (ORCPT + 30 others); Thu, 23 May 2019 05:06:44 -0400 Received: from foss.arm.com ([217.140.101.70]:40794 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729898AbfEWJGm (ORCPT ); Thu, 23 May 2019 05:06:42 -0400 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 2102B165C; Thu, 23 May 2019 02:06:42 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0D7903F575; Thu, 23 May 2019 02:06:39 -0700 (PDT) From: Sudeep Holla To: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Catalin Marinas , Will Deacon , Oleg Nesterov , Richard Weinberger , jdike@addtoit.com, Steve Capper , Haibo Xu , Bin Lu Subject: [PATCH v4 4/4] arm64: ptrace: add support for syscall emulation Date: Thu, 23 May 2019 10:06:18 +0100 Message-Id: <20190523090618.13410-5-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190523090618.13410-1-sudeep.holla@arm.com> References: <20190523090618.13410-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP support on arm64. We don't need any special handling for PTRACE_SYSEMU_SINGLESTEP. It's quite difficult to generalize handling PTRACE_SYSEMU cross architectures and avoid calls to tracehook_report_syscall_entry twice. Different architecture have different mechanism to indicate NO_SYSCALL and trying to generalise adds more code for no gain. Cc: Catalin Marinas Cc: Will Deacon Signed-off-by: Sudeep Holla --- arch/arm64/include/asm/thread_info.h | 5 ++++- arch/arm64/kernel/ptrace.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index eb3ef73e07cf..c285d1ce7186 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -75,6 +75,7 @@ void arch_release_task_struct(struct task_struct *tsk); * TIF_SYSCALL_TRACE - syscall trace active * TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace * TIF_SYSCALL_AUDIT - syscall auditing + * TIF_SYSCALL_EMU - syscall emulation active * TIF_SECOMP - syscall secure computing * TIF_SIGPENDING - signal pending * TIF_NEED_RESCHED - rescheduling necessary @@ -91,6 +92,7 @@ void arch_release_task_struct(struct task_struct *tsk); #define TIF_SYSCALL_AUDIT 9 #define TIF_SYSCALL_TRACEPOINT 10 #define TIF_SECCOMP 11 +#define TIF_SYSCALL_EMU 12 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_FREEZE 19 #define TIF_RESTORE_SIGMASK 20 @@ -109,6 +111,7 @@ void arch_release_task_struct(struct task_struct *tsk); #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) #define _TIF_SECCOMP (1 << TIF_SECCOMP) +#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU) #define _TIF_UPROBE (1 << TIF_UPROBE) #define _TIF_FSCHECK (1 << TIF_FSCHECK) #define _TIF_32BIT (1 << TIF_32BIT) @@ -120,7 +123,7 @@ void arch_release_task_struct(struct task_struct *tsk); #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \ - _TIF_NOHZ) + _TIF_NOHZ | _TIF_SYSCALL_EMU) #define INIT_THREAD_INFO(tsk) \ { \ diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index b82e0a9b3da3..9353355cb91a 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1819,8 +1819,12 @@ static void tracehook_report_syscall(struct pt_regs *regs, int syscall_trace_enter(struct pt_regs *regs) { - if (test_thread_flag(TIF_SYSCALL_TRACE)) + if (test_thread_flag(TIF_SYSCALL_TRACE) || + test_thread_flag(TIF_SYSCALL_EMU)) { tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); + if (!in_syscall(regs) || test_thread_flag(TIF_SYSCALL_EMU)) + return -1; + } /* Do the secure computing after ptrace; failures should be fast. */ if (secure_computing(NULL) == -1)