[LTP] [PATCH 5/6] Add ioctl_pidfd03 test

Cyril Hrubis chrubis@suse.cz
Mon Jun 30 16:30:18 CEST 2025


Hi!
> > If I'm reading the kernel code correctly, we should get the same result
> > even before the pid was waited for, so we may as well do this check
> > twice, once before the WAITPID() and once after the WAITPID().
> In this case, ESRCH is obtained only when info->mask == 0 __after__ 
> child has been reaped.
> If child has not completed, we obtain the same result of the 
> ioctl_pidfd02 check before waitpid().

Sigh, right, I misread the kernel code again.

We get ESRCH in the case of:

- the target pid is not in our namespace or child namespace
- task was reaped and PIDFD_INFO_EXIT was not set

- task was reaped before we called get_task_cred()
- task was reaped after we filled in data from task_cred
  (there is another check at the end of the function to make sure we do
  not return stale data)

So I suppose that we can hit the first two, the second two are
inherently racy.


So after all with a pidfd pointing to a process in a child pid namespace
we get all the uids/gids and pid filled in. Possibly changed by
mappings, but I suppose these are going to be 1:1 since we haven't set
any mapping tables.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list