Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4048982imu; Sat, 24 Nov 2018 17:12:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/VWwbMpts2kAKwduKAV+GJ75lhbwRkhSrm2Epm7+4PWz6FKjtqlP/NjLn2Eex8Maozodo1J X-Received: by 2002:a63:d10:: with SMTP id c16mr19731952pgl.382.1543108343516; Sat, 24 Nov 2018 17:12:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543108343; cv=none; d=google.com; s=arc-20160816; b=UfAm3KUPOQlqWq3fXFJbdTFj9Yb6H0RB+0AC8VCOe2XjNxwt9NaP0R7zqAezgemsoq 2WdD2Z2omKlGfI3ka9D8QNPJU3JpCpyRnFCLhGsQrLpuK6n/YscEi/QksF4kowZzGWNX eHh6irI810vW3K2px75BWg/Pukl6fLKMnb0Lk/csGiYnHStWAa17YZoji7Fq9TtM8/Fx xHcdj/T2VwxvpV7SurRSf3LpKkeLgWXDPiXhXaJita+2sD2NLWRDVYcddutGaSZNsEYS +PjXDgw2d2sCSTfS2/agKtZJi0Xy2bbRSkCuK5RJJ5nSwGMD3Qs61oa11YxgTCatLrfU Kh/A== 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=t6ch+BqghtRrmO6MzbdD4LR/k2k/acjyrCdg0xwlPh0=; b=rlLjYIOtO20urCRJChAl+BkKwohDm9l08PZETbwyc/rS/l6pmjl0OllVqNpMfXW7Yv 5wFjWWFNhdvep8DoDt3J84kBXO3M7c+KPun9XirFaxHUAFnVDB01OOzOEC/sXmx2EFkP sSX6PKHFHbdGuAoytmJPha00HQphu27k3aU6ThhaXAeMh94sjSdrS50nadmuVzwAdg/o fwIRLnXfnzV9fXfhL+gIo/8vv+HxZDSer6GbzUWCapoP9Me+Jg20Nx2f1cbDYIJRm9RP Ti7H/FYPZG6FxbIE0HFbq/SrrYc8xyJ3Blsue6W/ElwAGFs6J2vL/nXdlJaTk24qqYW5 PUPw== 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 bg3-v6si59326282plb.350.2018.11.24.17.12.08; Sat, 24 Nov 2018 17:12:23 -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 S1727001AbeKYL7Z (ORCPT + 99 others); Sun, 25 Nov 2018 06:59:25 -0500 Received: from air.basealt.ru ([194.107.17.39]:59392 "EHLO air.basealt.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbeKYL7Y (ORCPT ); Sun, 25 Nov 2018 06:59:24 -0500 Received: by air.basealt.ru (Postfix, from userid 490) id 27488589AE9; Sun, 25 Nov 2018 01:09:35 +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 49FE0589AE8; Sun, 25 Nov 2018 01:09:33 +0000 (UTC) Date: Sun, 25 Nov 2018 02:09:32 +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: [RFC PATCH v3 3/3] ptrace: add PTRACE_EVENT_SECCOMP support to PTRACE_GET_SYSCALL_INFO Message-ID: <20181125020932.054e05a6@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 Extend PTRACE_GET_SYSCALL_INFO to support PTRACE_EVENT_SECCOMP stops. The information returned is the same as for syscall-enter-stops. Signed-off-by: Elvira Khabirova Signed-off-by: Dmitry V. Levin --- include/linux/ptrace.h | 1 + include/linux/sched.h | 1 + include/linux/tracehook.h | 1 + kernel/ptrace.c | 7 +++++-- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index 6c2ffed907f5..a993d0fde865 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h @@ -166,6 +166,7 @@ static inline void ptrace_event(int event, unsigned long message) { if (unlikely(ptrace_event_enabled(current, event))) { current->ptrace_message = message; + current->ptrace_event = event; ptrace_notify((event << 8) | SIGTRAP); } else if (event == PTRACE_EVENT_EXEC) { /* legacy EXEC report via SIGTRAP */ diff --git a/include/linux/sched.h b/include/linux/sched.h index a51c13c2b1a0..86215fb654d6 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -964,6 +964,7 @@ struct task_struct { /* Ptrace state: */ unsigned long ptrace_message; + int ptrace_event; kernel_siginfo_t *last_siginfo; struct task_io_accounting ioac; diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h index 633a83fe7051..5d2e5aa07a5c 100644 --- a/include/linux/tracehook.h +++ b/include/linux/tracehook.h @@ -66,6 +66,7 @@ static inline int ptrace_report_syscall(struct pt_regs *regs, return 0; current->ptrace_message = message; + current->ptrace_event = 0; ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0)); /* diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 92c47cd5ad84..74a37e74c7f1 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -904,7 +904,9 @@ static int ptrace_get_syscall(struct task_struct *child, unsigned long actual_size; unsigned long write_size; - if (child->ptrace_message == PTRACE_EVENTMSG_SYSCALL_ENTRY) { + if ((child->ptrace_event == 0 && + child->ptrace_message == PTRACE_EVENTMSG_SYSCALL_ENTRY) || + child->ptrace_event == PTRACE_EVENT_SECCOMP) { int i; info.op = PTRACE_SYSCALL_INFO_ENTRY; @@ -917,7 +919,8 @@ static int ptrace_get_syscall(struct task_struct *child, for (i = 0; i < ARRAY_SIZE(args); i++) info.entry.args[i] = args[i]; actual_size = offsetofend(struct ptrace_syscall_info, entry); - } else if (child->ptrace_message == PTRACE_EVENTMSG_SYSCALL_EXIT) { + } else if (child->ptrace_event == 0 && + child->ptrace_message == PTRACE_EVENTMSG_SYSCALL_EXIT) { info.op = PTRACE_SYSCALL_INFO_EXIT; info.arch = syscall_get_arch(child); info.exit.rval = syscall_get_error(child, regs); -- 2.19.1