Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3112821ybz; Mon, 27 Apr 2020 10:10:31 -0700 (PDT) X-Google-Smtp-Source: APiQypLsqDoEkFS/qnOAdzr4ddg12M6JaBGn82ZaLT1puHav1RmxoBCaPI68j+vjgWH4FLoSgKxY X-Received: by 2002:a17:906:e5a:: with SMTP id q26mr19567320eji.261.1588007431825; Mon, 27 Apr 2020 10:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588007431; cv=none; d=google.com; s=arc-20160816; b=ic7rf9OST8GkJbpTS3Q4bGE7ppmtrdLBTvmGJE31d8M7Ywvc6wscf33FqKBFNHftj9 tUTMrESPxtzEkfR6XGLw0pZTSGFE7x84ePkCpr5jS7Z3Arf9FrJtS26UEzPCfjQrptJy TwGlxqYr0XSxUCOl8nse+ngDhe62yuq0qnYhej+y8Q7mE3g9wqeer4sBRpaRSqJs+tL8 +VdQsnnr1gtNbjtrUaoQK10x7fOR47KxkzrcVwENNv64Es8IfnL7P8DMJbDEQ7rSWLZc mdrXaMZrT/708jBrlAKTimXbbt12+wV3yf/wUlUjqvckzF1FguEYnloi0xPHl9Iz5GXE b1lg== 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=MokV7zpiA2oNZulqpNCvGKpblMPxtb7w+Do0UhIOT2k=; b=bRyHa34/+uY2tmnHaF+vqiBNIEQadnN8JRXgjrKOZwIjjXgxDakfgEXnftr9iXDY7E Dgf49nvuVNC+WqdVzszSHRE/DlfGNuoyKHXVdo+eIxa/I6G00Eopcja2zLLcVwqsTqKw AinSZNbne7cPXGJxdqvIlQ2fxfNAhgt0ClQMy5/cLnBXWUEyK+XjYN6GoYXvEgzDYBIo X1NmbVV0gafWlDo9OSIqztexzGq5uQE1ToPTT9k5RPt7NLbKpsma8TQcp/03siUUEhkm VGCqu+0K1VHQNkoxfUFuNJd9PaFUgShG7BP9o7ZGkkY51nrmXij1Dp46Yr9WGYFUXCAX Ygkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si112096edv.395.2020.04.27.10.10.07; Mon, 27 Apr 2020 10:10:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726404AbgD0RIb (ORCPT + 99 others); Mon, 27 Apr 2020 13:08:31 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:37408 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726194AbgD0RIa (ORCPT ); Mon, 27 Apr 2020 13:08:30 -0400 Received: from ip5f5af183.dynamic.kabel-deutschland.de ([95.90.241.131] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jT7F6-0005PO-1P; Mon, 27 Apr 2020 17:08:28 +0000 Date: Mon, 27 Apr 2020 19:08:26 +0200 From: Christian Brauner To: Hagen Paul Pfeifer Cc: linux-kernel@vger.kernel.org, Florian Weimer , Al Viro , Christian Brauner , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Arnd Bergmann , Brian Gerst , Sami Tolvanen , David Howells , Aleksa Sarai , Andy Lutomirski , Oleg Nesterov , "Eric W . Biederman" , Arnaldo Carvalho de Melo , Sargun Dhillon , linux-api@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: [RFC v2] ptrace, pidfd: add pidfd_ptrace syscall Message-ID: <20200427170826.mdklazcrn4xaeafm@wittgenstein> References: <20200426130100.306246-1-hagen@jauu.net> <20200426163430.22743-1-hagen@jauu.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200426163430.22743-1-hagen@jauu.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 26, 2020 at 06:34:30PM +0200, Hagen Paul Pfeifer wrote: > Working on a safety-critical stress testing tool, using ptrace in an > rather uncommon way (stop, peeking memory, ...) for a bunch of > applications in an automated way I realized that once opened processes > where restarted and PIDs recycled. Resulting in monitoring and > manipulating the wrong processes. > > With the advent of pidfd we are now able to stick with one stable handle > to identifying processes exactly. We now have the ability to get this > race free. Sending signals now works like a charm, next step is to > extend the functionality also for ptrace. > > API: > long pidfd_ptrace(int pidfd, enum __ptrace_request request, > void *addr, void *data, unsigned flags); I'm in general not opposed to this if there's a clear need for this and users that are interested. But I think if people really prefer having this a new syscall then we should probably try to improve on the old one. Things that come to mind right away without doing a deep review are replacing the void *addr pointer with a dedicated struct ptract_args or union ptrace_args and a size argument. If we're not doing something like this or something more fundamental we can equally well either just duplicate all enums in the old ptrace syscall and append a _PIDFD to it where it makes sense. Christian