Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Mar 2025 08:27:14 +0300
From:      Gleb Popov <arrowd@freebsd.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-hackers <freebsd-hackers@freebsd.org>
Subject:   Re: Would we want pidfd_open(2) & SO_PEERPIDFD?
Message-ID:  <CALH631=582=rpqCaR6FQTF_4C88NRf%2BLGnZR3fAynVvuNNWheA@mail.gmail.com>
In-Reply-To: <Z-I5Vwb3383R6UZs@kib.kiev.ua>
References:  <CALH631mgztNmngL1Hffbbcf0n-kLZP-2YmsMLJ8Xi33HV8uuvw@mail.gmail.com> <Z6udhDuj4uBjNUsM@kib.kiev.ua> <CALH631=7MnCAe67yPqG%2BAJfy_CPxf3HUxsfeVvgmiTEXEy27Bg@mail.gmail.com> <Z6wuyS4uBQJbCG-c@kib.kiev.ua> <CALH631m7DZKOLkjn4Z9z7arE9xwfEEjaGVSO=5KyHJ=iZ8o9Qw@mail.gmail.com> <Z9BR90ijwniJr2IJ@kib.kiev.ua> <CALH631mhpv7tzr1vhNgF2Hs6=ynSrMeuP1=NeXU63FEAmfUwRw@mail.gmail.com> <Z-I5Vwb3383R6UZs@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

On Tue, Mar 25, 2025 at 8:04 AM Konstantin Belousov <kostikbel@gmail.com> wrote:
>
> Can this be summarized as just a use of pidfd to
> - get the pid of the peer
> - ensure the peer liveness?
>
> I do not see much need of pidfd for this functionality.

What's the alternative? Tapping into a socket with
getsockopt(LOCAL_PEERCRED) to obtain a PID via xucred is not an option
because a client is not required to maintain an established connection
to a D-Bus socket.

The high level code expects a descriptor with some properties, so we
either provide it or have to patch large parts of the code using it.
Emulating pidfd somehow is also fine to me, but I have no idea how to
do that. libinotify-kqueue example shows that emulating a descriptor
with certain properties is quite a non-trivial task.

> pidfd takes ownership of the parent/child relation.  Wait() family of the
> functions clean after zombies, but this functionality is subsumed by
> the procdesc, so it is 'kind of' contradicts each other.  Also, as I
> can guess, wait() contradicts the capsicum idea of representing all
> access rights as file descriptors, since the special relation with the
> child presented yet another special process right.

Yes, this is a problem, and I have no experience to have an opinion there.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALH631=582=rpqCaR6FQTF_4C88NRf%2BLGnZR3fAynVvuNNWheA>