From: Christian Brauner <brauner@kernel.org>
To: Luca Boccassi <luca.boccassi@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>,
linux-kernel@vger.kernel.org, christian@brauner.io
Subject: Re: [PATCH v5] pidfd: add ioctl to retrieve pid info
Date: Mon, 7 Oct 2024 14:11:59 +0200 [thread overview]
Message-ID: <20241007-endsieg-pigmente-357468af306b@brauner> (raw)
In-Reply-To: <CAMw=ZnQUfCy2RBHdkBJ9r-tK5OBidQd=zCKHeJGcfprj4+ELJg@mail.gmail.com>
On Sun, Oct 06, 2024 at 10:33:08PM GMT, Luca Boccassi wrote:
> On Sun, 6 Oct 2024 at 19:56, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > On 10/06, Luca Boccassi wrote:
> > >
> > > I see, so what should I do here then? Check both? Or none?
> >
> > I don't know, because I don't know how are you going to use this API.
> >
> > > The caller
> > > needs to verify that the data is still valid at the point they use it
> > > anyway,
> >
> > So "none" should work fine? Just it should be documented that, say,
> > kinfo.pid can be 0 if we race with the exiting task.
> >
> > Just in case, you can also use lock_task_sighand() || return -ESRCH,
> > this way kinfo.*pid can't be zero. But I don't think this will buy too
> > much, the task can exit right after pidfd_info() returns.
> >
> > Oleg.
>
> I think what we should do is check if any of those fields was set to
> 0, and return ESRCH in that case. This way either we return a full set
> of metadata that was correct at the time it was taken, or we provide
> nothing and a clear error. We cannot solve the race as you mentioned,
> but I think it is important to avoid providing incomplete information,
> so that either the data is complete or nothing is given back. If the
> information is complete but becomes stale later, that can happen and
> it's ok.
Agree.
next prev parent reply other threads:[~2024-10-07 12:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-06 14:54 luca.boccassi
2024-10-06 17:21 ` Oleg Nesterov
2024-10-06 17:52 ` Luca Boccassi
2024-10-06 18:55 ` Oleg Nesterov
2024-10-06 21:33 ` Luca Boccassi
2024-10-07 12:11 ` Christian Brauner [this message]
2024-10-06 17:38 ` Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241007-endsieg-pigmente-357468af306b@brauner \
--to=brauner@kernel.org \
--cc=christian@brauner.io \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.boccassi@gmail.com \
--cc=oleg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®