From nobody Tue Mar 11 15:08:39 2025 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ZBxwy4Rslz5qgJP for ; Tue, 11 Mar 2025 15:08:50 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZBxwx5QKnz3NFM; Tue, 11 Mar 2025 15:08:49 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 52BF8eus036277; Tue, 11 Mar 2025 17:08:43 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 52BF8eus036277 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 52BF8dvk036276; Tue, 11 Mar 2025 17:08:39 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 11 Mar 2025 17:08:39 +0200 From: Konstantin Belousov To: Gleb Popov Cc: freebsd-hackers Subject: Re: Would we want pidfd_open(2) & SO_PEERPIDFD? Message-ID: References: List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on tom.home X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Queue-Id: 4ZBxwx5QKnz3NFM X-Spamd-Bar: ---- On Tue, Mar 11, 2025 at 10:12:33AM +0300, Gleb Popov wrote: > On Wed, Feb 12, 2025 at 8:17 AM Konstantin Belousov wrote: > > > > On Wed, Feb 12, 2025 at 07:10:25AM +0300, Gleb Popov wrote: > > > On Tue, Feb 11, 2025 at 9:57 PM Konstantin Belousov wrote: > > > > > > > > > > > > The semantic of the Linux' fd returned by pidfd_open() is not compatible > > > > with our pidfd. > > > > > > What's the difference, exactly? > > > I mean, it is still a descriptor and the only thing I need to do with > > > it is check if it is still open. We even have pdgetpid() to go from > > > the fd to a PID. This all looks like a perfect match to me. > > > > Read the man page for Linux pidfd_open(), and compare with our procdesc(4). > > The one feature _you plan to use_ might be almost identical, but everything > > else is different. > > When I started this thread the only use case I had was my own D-Bus > service I'm writing. Now it turned out that a new version of > xdg-desktop-portal [1] also started to rely on pidfd's passed by > callers. > > I agree that our procdesc is indeed different compared to Linux pidfd, > but not having a compatibility shim of some sort would mean a lot of > non-upstreamable patching for dbus and xdg-desktop-portal. I'm not > skilled enough to determine what parts of this API can be emulated in > a userland library a-la libepoll-shim or libudev-dev. At the bare > minimum I need a way to obtain a procdesc from a connected unix socket > via getsockopt(LOCAL_PEERCRED) or something like that. > > [1] https://github.com/flatpak/xdg-desktop-portal/ We can provide the FreeBSD procdesc from unix socket for the peer. But you need to evaluate is the result actually useful, taking into account the different semantic. Also, the waitpid(2) issue might become more serious.