Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4047789imu; Sat, 24 Nov 2018 17:10:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/UtbvWNv/gVTwRsOb/NIrmwfYqGTmuT53TYved3qQIj7YY3CjFw62anSr9myP3tcPJ02+Wt X-Received: by 2002:a63:e302:: with SMTP id f2mr19968371pgh.320.1543108237076; Sat, 24 Nov 2018 17:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543108237; cv=none; d=google.com; s=arc-20160816; b=ZSunsmHSb741DtMjA7vSCh15LKbmJGl6Dekm4FjfAhSjwn8DLDaUvo+nt65p4hSuiu 0SC6iXmW5UfnGCxPVFlwxxOif4yS4QjNzYPWgF/uzXUL6VD1BMWRHgpNrBRVF/iDrh86 8y4UXe9UuTi+3TH6kXJtVS7ChapsXETWDB0LG0rfSysLzCuRhVlyhqiBL59J1vQAVxhG MAKvdKgByEznqSvgkz0lUkzX9c5YB4fjtn0JJNqTaf2jBD5Tgh/ppZfTZmLjm9rNEYW0 SPckOKXTG3DE1PQ+6KtkNg/2SPOjPdiMx2T5rcqh0D3wHDYm+rw5lPQqLcjUZZLgQkRD gBVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=QTT8QQpntBVyzzvfy5+pP52CYAAA76Na+9H796/tAgo=; b=SIiqHCqKPXTA+pZi4G2eQBaEhZvwe+rb/YQ1j4xxPnyP3jvSYiNllwtJ8hUEU9BPWb dHbNP/tqFthfkb0R0EZgb6FiUq8EpDzxzioND976/Ko/3yAiB9JaG0wCRx6VfQABc00B j0Y+3fPsxlG/JwC810R3UawhiduicQ5pjTsTblvGTe106UdP9V4YFNrfrxEfUwkGJcdA Tq9g7XxK0Wyq+3RPIgAVZC5xEEJcjSgK0zh1nc1OtcwPUpm4od8IRk166D1kXQIz28km l3ErX8yOYLFZqar+w/FTGg7mvvXbXUegvEiVSikjd29Bs4hKrnQ8PMiRly7RhTN45lP3 Yarw== 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 h91si22766302pld.411.2018.11.24.17.10.22; Sat, 24 Nov 2018 17:10:37 -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 S1726968AbeKYL6J (ORCPT + 99 others); Sun, 25 Nov 2018 06:58:09 -0500 Received: from air.basealt.ru ([194.107.17.39]:58450 "EHLO air.basealt.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbeKYL6J (ORCPT ); Sun, 25 Nov 2018 06:58:09 -0500 Received: by air.basealt.ru (Postfix, from userid 490) id A6738589AE9; Sun, 25 Nov 2018 01:08:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 Received: from akathisia (broadband-46-188-15-144.2com.net [46.188.15.144]) by air.basealt.ru (Postfix) with ESMTPSA id F3A18589AE8; Sun, 25 Nov 2018 01:08:17 +0000 (UTC) Date: Sun, 25 Nov 2018 02:08:17 +0100 From: Elvira Khabirova To: oleg@redhat.com, rostedt@goodmis.org, mingo@redhat.com Cc: linux-kernel@vger.kernel.org, ldv@altlinux.org, esyr@redhat.com, luto@kernel.org, strace-devel@lists.strace.io Subject: [PATCH v3 1/3] ptrace: pass type of a syscall-stop in ptrace_message Message-ID: <20181125020817.7857cc56@akathisia> In-Reply-To: <20181125020659.785c7b29@akathisia> References: <20181125020659.785c7b29@akathisia> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Define two constants, PTRACE_EVENTMSG_SYSCALL_ENTRY and PTRACE_EVENTMSG_SYSCALL_EXIT, and place them in ptrace_message for the duration of syscall-stops. This way ptracers can distinguish syscall-enter-stops from syscall-exit-stops using PTRACE_GETEVENTMSG request. Signed-off-by: Elvira Khabirova Signed-off-by: Dmitry V. Levin --- include/linux/tracehook.h | 9 ++++++--- include/uapi/linux/ptrace.h | 10 ++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h index 40b0b4c1bf7b..633a83fe7051 100644 --- a/include/linux/tracehook.h +++ b/include/linux/tracehook.h @@ -57,13 +57,15 @@ struct linux_binprm; /* * ptrace report for syscall entry and exit looks identical. */ -static inline int ptrace_report_syscall(struct pt_regs *regs) +static inline int ptrace_report_syscall(struct pt_regs *regs, + unsigned long message) { int ptrace = current->ptrace; if (!(ptrace & PT_PTRACED)) return 0; + current->ptrace_message = message; ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0)); /* @@ -76,6 +78,7 @@ static inline int ptrace_report_syscall(struct pt_regs *regs) current->exit_code = 0; } + current->ptrace_message = 0; return fatal_signal_pending(current); } @@ -101,7 +104,7 @@ static inline int ptrace_report_syscall(struct pt_regs *regs) static inline __must_check int tracehook_report_syscall_entry( struct pt_regs *regs) { - return ptrace_report_syscall(regs); + return ptrace_report_syscall(regs, PTRACE_EVENTMSG_SYSCALL_ENTRY); } /** @@ -126,7 +129,7 @@ static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step) if (step) user_single_step_report(regs); else - ptrace_report_syscall(regs); + ptrace_report_syscall(regs, PTRACE_EVENTMSG_SYSCALL_EXIT); } /** diff --git a/include/uapi/linux/ptrace.h b/include/uapi/linux/ptrace.h index d5a1b8a492b9..cb138902d042 100644 --- a/include/uapi/linux/ptrace.h +++ b/include/uapi/linux/ptrace.h @@ -104,6 +104,16 @@ struct seccomp_metadata { #define PTRACE_O_MASK (\ 0x000000ff | PTRACE_O_EXITKILL | PTRACE_O_SUSPEND_SECCOMP) +/* + * These values are stored in task->ptrace_message by tracehook_report_syscall_* + * to describe current syscall-stop. + * + * Values for these constants are chosen so that they do not appear + * in task->ptrace_message by other means. + */ +#define PTRACE_EVENTMSG_SYSCALL_ENTRY 0x80000000U +#define PTRACE_EVENTMSG_SYSCALL_EXIT 0x90000000U + #include -- 2.19.1