Re: [PATCH v5] pidfd: add ioctl to retrieve pid info

From: Oleg Nesterov
Date: Sun Oct 06 2024 - 14:56:10 EST


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.