From patchwork Mon Mar 18 10:49:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 160485 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp2500522jad; Mon, 18 Mar 2019 03:49:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7YTxVVrOHE0ENG1Z4vXG2hq3HwRr8AoxRxLJnxpXNW2SQWgvpnxyrEQZh2XKGmQS1DJ0E X-Received: by 2002:a17:902:8506:: with SMTP id bj6mr19066755plb.60.1552906193357; Mon, 18 Mar 2019 03:49:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552906193; cv=none; d=google.com; s=arc-20160816; b=fuOFotuU/D5wOrX1kx8AcHyesXfyW6F+WVKfUJ3Iov0Pr05VEUsmPUraexDNCe/3Xc kZvnl5lYRX2/Kb/BaMs23Skro/x0PuqPhYNoxwNAfMwLYo6SsAKCgslvzgFdoovXtPl6 ITxM/1KoqIDyp437rCM8rg1y1R10PAHcv9TxO7Ls6kSVIWyknuHwm+7MhdIbDosUwO2O vBQh/cr9epbnojq3+kU11JbVf/zTY68LZLFhI1Cb5q9uUr3xBvrSJkwNe/OvLJ150sH8 uKIkxFjUunCnCk38X6J+9evWV03b0n/97qGQ6hOxaoWjNNpPL4clPvcTRLxzGg0ZpntU xd2A== 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=26z/nkogKM0IGAMwbEelqB88p5s/vBdplxcyH6sIp8I=; b=uYSOE127Cs0fvMTcFUE0CaLsZ4O7yWr0oY9VRH2PDrdNfJ/OgxPhNW/xhM5dgK8mEk 8PHgBU5f40i0zazrohMinkuMSlCc7yKlWUF/KYI1D139XjlRsMsPBp1wwdFCFdSFi8j2 hT8DgPLD3YsrWp4XBrQ+HvZ69pcA4VxhDBvLhKZmgVPwp2bwvu0ubUF05WorgFIUvJ3g bKCf7/fDEzOWPACbzSthTnUN2eDXk4U7qxAz4v4GBtF7+CkKcNkla+/IXZMQw5k4IsW2 ZeraBQ6CeCbGCeHsLzpl36XW6e3NQwdMOB4Necmwx7sMFdZCqMgDHPFT5wLrMiuV+pVV H48w== 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 y5si9007474plk.150.2019.03.18.03.49.53; Mon, 18 Mar 2019 03:49:53 -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 S1727717AbfCRKtv (ORCPT + 31 others); Mon, 18 Mar 2019 06:49:51 -0400 Received: from foss.arm.com ([217.140.101.70]:59758 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727632AbfCRKts (ORCPT ); Mon, 18 Mar 2019 06:49:48 -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 816E4174E; Mon, 18 Mar 2019 03:49:48 -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 8D41B3F614; Mon, 18 Mar 2019 03:49:45 -0700 (PDT) From: Sudeep Holla To: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: Sudeep Holla , Catalin Marinas , Will Deacon , Oleg Nesterov , Paul Mackerras , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Richard Weinberger , jdike@addtoit.com, Steve Capper , Haibo Xu , Bin Lu , Andy Lutomirski Subject: [PATCH v2 4/6] powerpc: use common ptrace_syscall_enter hook to handle _TIF_SYSCALL_EMU Date: Mon, 18 Mar 2019 10:49:23 +0000 Message-Id: <20190318104925.16600-5-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190318104925.16600-1-sudeep.holla@arm.com> References: <20190318104925.16600-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have a new hook ptrace_syscall_enter that can be called from syscall entry code and it handles PTRACE_SYSEMU in generic code, we can do some cleanup using the same in do_syscall_trace_enter. Cc: Oleg Nesterov Cc: Paul Mackerras Cc: Michael Ellerman Signed-off-by: Sudeep Holla --- arch/powerpc/kernel/ptrace.c | 48 ++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 27 deletions(-) -- 2.17.1 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 2e2183b800a8..05579a5dcb12 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -3278,35 +3278,29 @@ long do_syscall_trace_enter(struct pt_regs *regs) user_exit(); - flags = READ_ONCE(current_thread_info()->flags) & - (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE); - - if (flags) { - int rc = tracehook_report_syscall_entry(regs); + if (unlikely(ptrace_syscall_enter(regs))) { + /* + * A nonzero return code from tracehook_report_syscall_entry() + * tells us to prevent the syscall execution, but we are not + * going to execute it anyway. + * + * Returning -1 will skip the syscall execution. We want to + * avoid clobbering any registers, so we don't goto the skip + * label below. + */ + return -1; + } - if (unlikely(flags & _TIF_SYSCALL_EMU)) { - /* - * A nonzero return code from - * tracehook_report_syscall_entry() tells us to prevent - * the syscall execution, but we are not going to - * execute it anyway. - * - * Returning -1 will skip the syscall execution. We want - * to avoid clobbering any registers, so we don't goto - * the skip label below. - */ - return -1; - } + flags = READ_ONCE(current_thread_info()->flags) & _TIF_SYSCALL_TRACE; - if (rc) { - /* - * The tracer decided to abort the syscall. Note that - * the tracer may also just change regs->gpr[0] to an - * invalid syscall number, that is handled below on the - * exit path. - */ - goto skip; - } + if (flags && tracehook_report_syscall_entry(regs)) { + /* + * The tracer decided to abort the syscall. Note that + * the tracer may also just change regs->gpr[0] to an + * invalid syscall number, that is handled below on the + * exit path. + */ + goto skip; } /* Run seccomp after ptrace; allow it to set gpr[3]. */