From patchwork Thu Feb 28 18:32: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: 159427 Delivered-To: patch@linaro.org Received: by 2002:ac9:18c7:0:0:0:0:0 with SMTP id i7csp987886oce; Thu, 28 Feb 2019 10:32:45 -0800 (PST) X-Google-Smtp-Source: APXvYqxOAnuRBoH64BNddim9auKDbvBdTx0ndgCPJ1NvH50zwQ47XGPR6KV4G3d9WkKDWoTVFjHE X-Received: by 2002:a17:902:282b:: with SMTP id e40mr767458plb.111.1551378765208; Thu, 28 Feb 2019 10:32:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551378765; cv=none; d=google.com; s=arc-20160816; b=lQra93QesFc1SwwQnhiYlhlzdReA3Tqc19bx66s8MJ14LdkulJ0R4Z/TORJS5UAgsT TVDDqQtg1Mot4LXPH7URVMvnjYqW4ppk151R5t+WGlYI8HkJlw/O29s9B7ITBj0LRndW Dn365Z8WqQDIYMEfBO1MkEuRHZtngUsUmlY2Sydg5VEFahsQc2sqzrnWNe+dW/WbUG4P iMSWTwITqt0ucRPYEFP63a0AaZeieLKRdC5x0hvnytl1I1jzg/4OhONsLCiAASoXJtpM WIW0jJe7uq9XBwZ+9IQwRA2uZ02pu0mTtECvp36HUcpjGs74063sRNe/9J5wvifoiZYl x0Vw== 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=tJXSkxSqlnGSIWoUyWccRwyDJ0zxcD2O2YaMUB6+ANU=; b=Dmx+Qf1Nsdj8T0volaA/yNkl+77gzmkm5qAHkv4IwmWuLryXmJ8wJhLeWnbFeWzg/k wLuq0FS1vyBOnO7BJrzoiYukqyX5kWGmhVUbtqb3u7wJPF+GmXQwrhaUfheYYWlTlX9c Wz4MDC6qns2JTwcsG47esIVbi5YFadTwrfLRvbMjX5hVq21r6lEr+2zY+Y/RhKMDNMPy /M2FB3qPSQNPghE+InnXSJlx5JyCmhgyJ+xYDA+jhGrsWSRFiOhvvj8HfvOLJzIZxW4t kCXWGr6roJKtobR41+ce40tBa77ALGQxKi2C2tl5LdGtOGWL/SBTanRgfQtrTEi9x8l7 OD4A== 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 11si18065511pfh.90.2019.02.28.10.32.44; Thu, 28 Feb 2019 10:32:45 -0800 (PST) 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 S2387725AbfB1Scn (ORCPT + 31 others); Thu, 28 Feb 2019 13:32:43 -0500 Received: from foss.arm.com ([217.140.101.70]:52948 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732645AbfB1Scl (ORCPT ); Thu, 28 Feb 2019 13:32:41 -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 34012174E; Thu, 28 Feb 2019 10:32:41 -0800 (PST) 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 63F233F5C1; Thu, 28 Feb 2019 10:32:38 -0800 (PST) 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 Subject: [PATCH 4/6] powerpc: use common ptrace_syscall_enter hook to handle _TIF_SYSCALL_EMU Date: Thu, 28 Feb 2019 18:32:18 +0000 Message-Id: <20190228183220.15626-5-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228183220.15626-1-sudeep.holla@arm.com> References: <20190228183220.15626-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 | 50 ++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 28 deletions(-) -- 2.17.1 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index cb7e1439cafb..978cd2aac29e 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -3264,37 +3264,31 @@ long do_syscall_trace_enter(struct pt_regs *regs) { u32 flags; - user_exit(); - - flags = READ_ONCE(current_thread_info()->flags) & - (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE); + 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 (flags) { - int rc = tracehook_report_syscall_entry(regs); + user_exit(); - 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]. */