Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4873999imu; Mon, 12 Nov 2018 19:38:41 -0800 (PST) X-Google-Smtp-Source: AJdET5e730bKmTvV93FWbMCiC/Q/ITfiNs5Etd0COkQeFtCit9H3DUk8/l51zenVG2zI0FXqEdnp X-Received: by 2002:a17:902:8ec2:: with SMTP id x2-v6mr3455554plo.157.1542080321490; Mon, 12 Nov 2018 19:38:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542080321; cv=none; d=google.com; s=arc-20160816; b=JccLjnw4PT/HcBLAW4LLgoqhqamJtWcQp+/HNnY0CZ3KKRt94TpRwVi3FZmEpMqyOB AOl8G2w3OeXvan6aESIb2p0fb+y4QOWlLxaf8vuScvgAUlkSHxphOuetspHGecocUIVn SpJR0Xj2/eOTX7cFr4FbStOHYC4vtukRJ8B+Ln2OyslWnU8Y4POHSicc8TkdHxFcg8qi k3zXPhBQJApYcXs6rjILNRvHx2+2olw8GACuqf3HxzlJh7JtyNdAQeaEzfGl1bJLEa1f LtAwC1oRfMVN7ege7s1H31qjq585AFWbWUmS2Mlg9waqgtKSdvv+hde++gTMntGvHdHU Lstg== 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:message-id:subject:cc:to:from:date; bh=1lnllzTT9hli/NF/vDL0+NXiWNlqD8jwns7r9dsT7Ns=; b=uzjrfAmqQE9/re5M8SEZsVgGXYHWLNQzBpEF/4n/HQczZ3447KrnxUoV/laO4rFMDt J3VQeiOGDl+ND5ocmEFtZDJcblLIsNqYrzenfHCGJo+vk3CD4tIilXyXQu+Bk2/IsQo8 2HF8QuGGb01IPIRh21MvigAaqxty9KavXgOzE2BmK7f5Dxp6RPcH7F0l8Urd+q94NSKx 41q0cw3PmiJHRCYHPjqdgxLwF+fKN4YLkAk5MR+RJowMO/ywIxO8jzWgdmU7umTzve4J 88XRDN+pLi2eG2vjX3G49in/g0zEOuBvdIINtDnXuvr/27PA16sabHUT/6YUJzoqPA5y BePw== 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 f7-v6si17976347pgh.159.2018.11.12.19.38.25; Mon, 12 Nov 2018 19:38:41 -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 S1730320AbeKMNeP (ORCPT + 99 others); Tue, 13 Nov 2018 08:34:15 -0500 Received: from vmicros1.altlinux.org ([194.107.17.57]:45860 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726111AbeKMNeP (ORCPT ); Tue, 13 Nov 2018 08:34:15 -0500 Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 0891872CA5E; Tue, 13 Nov 2018 06:38:03 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id E856B7CD1FF; Tue, 13 Nov 2018 06:38:02 +0300 (MSK) Date: Tue, 13 Nov 2018 06:38:02 +0300 From: "Dmitry V. Levin" To: Andy Lutomirski , Oleg Nesterov , Elvira Khabirova Cc: Steven Rostedt , Ingo Molnar , Eugene Syromiatnikov , LKML , strace-devel@lists.strace.io Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request Message-ID: <20181113033802.GA24679@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 07, 2018 at 12:44:58PM -0800, Andy Lutomirski wrote: > > On Nov 6, 2018, at 7:27 PM, Elvira Khabirova wrote: > > > > PTRACE_GET_SYSCALL_INFO lets ptracer obtain details of the syscall > > the tracee is blocked in. The request returns meaningful data only > > when the tracee is in a syscall-enter-stop or a syscall-exit-stop. > > > > There are two reasons for a special syscall-related ptrace request. > > > > Firstly, with the current ptrace API there are cases when ptracer cannot > > retrieve necessary information about syscalls. Some examples include: > > * The notorious int-0x80-from-64-bit-task issue. See [1] for details. > > In short, if a 64-bit task performs a syscall through int 0x80, its tracer > > has no reliable means to find out that the syscall was, in fact, > > a compat syscall, and misidentifies it. > > * Syscall-enter-stop and syscall-exit-stop look the same for the tracer. > > Common practice is to keep track of the sequence of ptrace-stops in order > > not to mix the two syscall-stops up. But it is not as simple as it looks; > > for example, strace had a (just recently fixed) long-standing bug where > > attaching strace to a tracee that is performing the execve system call > > led to the tracer identifying the following syscall-exit-stop as > > syscall-enter-stop, which messed up all the state tracking. > > * Since the introduction of commit 84d77d3f06e7e8dea057d10e8ec77ad71f721be3 > > ("ptrace: Don't allow accessing an undumpable mm"), both PTRACE_PEEKDATA > > and process_vm_readv become unavailable when the process dumpable flag > > is cleared. On ia64 this results in all syscall arguments being unavailable. > > > > Secondly, ptracers also have to support a lot of arch-specific code for > > obtaining information about the tracee. For some architectures, this > > requires a ptrace(PTRACE_PEEKUSER, ...) invocation for every syscall > > argument and return value. > > > > PTRACE_GET_SYSCALL_INFO returns the following structure: > > > > struct ptrace_syscall_info { > > __u8 op; /* 0 for entry, 1 for exit */ > > Please consider adding another op for a seccomp stop. If there are going to be more than two values, I'd suggest introducing a enum or at least define appropriate macros. wrt PTRACE_EVENT_SECCOMP, I don't see how the current proposed implementation of PTRACE_GET_SYSCALL_INFO (based on ptrace_message) could work in case of PTRACE_EVENT_SECCOMP (which also sets ptrace_message). Any ideas? -- ldv