Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5897425imu; Mon, 26 Nov 2018 06:38:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xe7rqpKvADAsTs7DGkRYDxqBEBG8wNT8ghw7NMx8vcUdlttPmoB48jpoTONONQTzmGiI11 X-Received: by 2002:a63:3546:: with SMTP id c67mr25506960pga.284.1543243092007; Mon, 26 Nov 2018 06:38:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543243091; cv=none; d=google.com; s=arc-20160816; b=P0ZK3c0ICpvigK6CjURDUaqKNgLYzc9/PPp0TJJLAgvfOCrSpMysXqJuEc/mHtWZZM K6sc/kGXrw38iUtHDhcsYz+r7Vdq/+yDArlP3WcIUrb+3gQbZ/gsSHaLriXJwE8DfXo6 DHJXMHz3GH9IRshh0nLrC0e9/HyC/llT5L9MUj5/VJlOfN4oORZxC159Dm8kZkdfP0Aa YoowPY9ZC8SdEkU3Eydsh9TzrrFYrRmlz3J46r5QBUG5oOxk2nj0lXof0T06679uYDJf NXjfS8yEseuoyq8+hASMNKmLhsgRzy0YHlO2A5XXoyfFCgwzacFgvkLi6svrSnu9NGCC 0hcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rNcmtqUPzL89xM1j0gTcWgPzLay+PaaSeh0SQNu6szM=; b=VcOpxTqVz7oo9C3dUktPTEcpLY0fpikvQvOqOsdHnXJG/FzTAhwnRLtehVhvg8QMbP /D7H3avgbxacM0e0TLezfX23q4mpcgzUGPeqcNNz3RmhQMzc0B/A5LOuu/Q5FSas1F7B n9oiZGy+TbI2EAjHslbabGOgovPzmG3Wzcup+sMf7/x6V9lFGFq/s35CFvXEwhFr36wA d9wFxaj3ZfGSeW6O8lxGgM5BSnG0MM3C0xr7RBHE5JEhQvd+Q5WzcBZ0Z0qmRvOsYtHg j5DJ5srbJnBsDN47p9A1nDKI2sQ9805gfG8XxUoxEFnZfY+81lH1ZUnt7Ze3T4rS2oh+ 792g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si377301pgt.155.2018.11.26.06.37.56; Mon, 26 Nov 2018 06:38:11 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726887AbeK0BaH (ORCPT + 99 others); Mon, 26 Nov 2018 20:30:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47951 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726279AbeK0BaH (ORCPT ); Mon, 26 Nov 2018 20:30:07 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7FBA2155AC; Mon, 26 Nov 2018 14:35:48 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.12]) by smtp.corp.redhat.com (Postfix) with SMTP id 488A383EB8; Mon, 26 Nov 2018 14:35:25 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 26 Nov 2018 15:35:48 +0100 (CET) Date: Mon, 26 Nov 2018 15:35:24 +0100 From: Oleg Nesterov To: Elvira Khabirova Cc: rostedt@goodmis.org, mingo@redhat.com, linux-kernel@vger.kernel.org, ldv@altlinux.org, esyr@redhat.com, luto@kernel.org, strace-devel@lists.strace.io, linux-api@vger.kernel.org Subject: Re: [RFC PATCH RESEND v3 3/3] ptrace: add PTRACE_EVENT_SECCOMP support to PTRACE_GET_SYSCALL_INFO Message-ID: <20181126143524.GB1660@redhat.com> References: <20181125022150.46258a20@akathisia> <20181125022340.5703400f@akathisia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181125022340.5703400f@akathisia> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 26 Nov 2018 14:35:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/25, Elvira Khabirova wrote: > > Extend PTRACE_GET_SYSCALL_INFO to support PTRACE_EVENT_SECCOMP stops. > The information returned is the same as for syscall-enter-stops. Oh, this is not nice ;) there must be a better option, I hope... Plus Can't ptrace_get_syscall() check child->exit_code == (PTRACE_EVENT_SECCOMP << 8) | SIGTRAP; to detect the PTRACE_EVENT_SECCOMP case? Oleg. > 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 >