Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp720605imu; Fri, 7 Dec 2018 07:57:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/UOF0ITS8NZzrUGoVp64GzBnlJOb+lZL3rZN/bCE1RO268+pSv8cgp+B8eZYO2TIK25V9DK X-Received: by 2002:a17:902:7882:: with SMTP id q2mr2679634pll.305.1544198220442; Fri, 07 Dec 2018 07:57:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544198220; cv=none; d=google.com; s=arc-20160816; b=rtxMXXw2LLMuJRwWqgL/16llOWVQ+LPwutKQdOijlKYsHE/wqn/6fvaWqDHK4CgeTL fI2Yt4+u2NfwX5oZz55cmglbx9VmmbRBGWckcVzNnxVA/0scNC2HWHXVQ5nQhizbyVoF I+fRvBxhkmJjs5V8vMlZWRI+6P5VZxpbFLfoIic6JhswV8dJ6E7ERxVVavglg4399nXb +WLxFqXwXMgbwq62mXwRGhpOGNC6OUBRmKj2x+spwRSeoX8Rd2KCUGjkj0KaTZfNFPQs t+ndxfjraKGl8CDdC4AsKr9t7diM0g8AXmy/+Ka4a+BjDjruApyB6ZJD65Q5vyXMcObF a6ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=FFeyjIs34vlFlGheC42l0g92lWwa1c0hMI7K2eUbt0U=; b=STkZxmmNSuJBRRjf79lHex8dqf/ihISQgz/jYMcFcq2iICOdkGvUpUTjm2djQSAzJ+ +YnFiZCzKOviJ9A8KWzrJf2aH7H/Z9/YSgT3rKQ3sYU4fpsvtl7pX5pUN16Er2c/UViU Xk7OE1oxWJoVzWvL1qOGNMC2cVDpM/98VkU/0fbyqGIpcxxUJyFf89G/ii2/wqKYLwfH 1C/dU+UVbQf/CNLymGQ98xivczN7cxqOomNzlBkStAz6WMuqxhED+C7H9/10mLTRwRqJ gM6PWX9IvvbbMY/CzEDbSXwIkkF7b5Fp8UIO/FNRiwvWLZQLUQJXANhPYsZlFFlb/5mm wPGg== 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 90si3196761plb.17.2018.12.07.07.56.44; Fri, 07 Dec 2018 07:57:00 -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 S1726099AbeLGP4J (ORCPT + 99 others); Fri, 7 Dec 2018 10:56:09 -0500 Received: from vmicros1.altlinux.org ([194.107.17.57]:37288 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbeLGP4J (ORCPT ); Fri, 7 Dec 2018 10:56:09 -0500 Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 0952672CC59; Fri, 7 Dec 2018 18:56:06 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id EB8CE7CE9F4; Fri, 7 Dec 2018 18:56:05 +0300 (MSK) Date: Fri, 7 Dec 2018 18:56:05 +0300 From: "Dmitry V. Levin" To: Michael Ellerman Cc: Elvira Khabirova , Benjamin Herrenschmidt , Paul Mackerras , Oleg Nesterov , Breno Leitao , Andy Lutomirski , Eugene Syromyatnikov , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v5] powerpc/ptrace: replace ptrace_report_syscall() with a tracehook call Message-ID: <20181207155605.GB28964@altlinux.org> References: <20181116121701.14359da0@akathisia> <87ftw12nyn.fsf@concordia.ellerman.id.au> <20181119210139.GA8360@altlinux.org> <87efbe166y.fsf@concordia.ellerman.id.au> <20181203031823.GE11573@altlinux.org> <20181207011946.GA18558@altlinux.org> <87y391k2tq.fsf@concordia.ellerman.id.au> <20181207154255.GA28964@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181207154255.GA28964@altlinux.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Elvira Khabirova Arch code should use tracehook_*() helpers, as documented in include/linux/tracehook.h, ptrace_report_syscall() is not expected to be used outside that file. The patch does not look very nice, but at least it is correct and opens the way for PTRACE_GET_SYSCALL_INFO API. Co-authored-by: Dmitry V. Levin Fixes: 5521eb4bca2d ("powerpc/ptrace: Add support for PTRACE_SYSEMU") Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Oleg Nesterov Cc: Breno Leitao Cc: Andy Lutomirski Cc: Eugene Syromyatnikov Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Elvira Khabirova Signed-off-by: Dmitry V. Levin --- v5: reverted to a simple approach, compile- and run-tested v4: rewritten to call tracehook_report_syscall_entry() once, compile-tested v3: add a descriptive comment v2: explicitly ignore tracehook_report_syscall_entry() return code arch/powerpc/kernel/ptrace.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index afb819f4ca68..714c3480c52d 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -3266,12 +3266,17 @@ long do_syscall_trace_enter(struct pt_regs *regs) user_exit(); if (test_thread_flag(TIF_SYSCALL_EMU)) { - ptrace_report_syscall(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 register also, thus, not 'gotoing' * skip label. */ + if (tracehook_report_syscall_entry(regs)) + ; return -1; } -- ldv