[LTP] [PATCH v2] Correctly check if PIDFD_INFO_EXIT is available

Andrea Cervesato andrea.cervesato@suse.com
Wed Jul 30 14:04:49 CEST 2025


On 7/30/25 11:35 AM, Cyril Hrubis wrote:
> Hi!
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
>
It seems we need to add also a couple of errno checks more. 
ioctl(PIDFD_INFO_EXIT ...) starts to fail with EINVAL from a certain 
version of the kernel, after introducing `pidfd_ioctl` function in 
fs/pidfs.c, while before only ENOTTY was raised.

After the introduction of "cdda1f26e74b - pidfd: add ioctl to retrieve 
pid info" in v6.13, the logic inside the kernel changed and we get ESRCH 
error due to the introduction of `struct pidfd_info`, but the lack of 
PIDFD_INFO_EXIT support: at that specific commit, only PIDFD_INFO_PID is 
supported.

This is due to the implementation of `pidfd_ioctl()`, that is not 
validating commands before asking for a pid task.

I guess there's either a enhancement to do in the kernel implementation, 
or a lack of checks from our side. Since we are talking about 3 versions 
of the kernel ago, we should probably verify that kernel doesn't support 
PIDFD_INFO_EXIT by looking at the following ioctl() errno:

- ENOTTY
- EINVAL
- ESRCH

- Andrea



More information about the ltp mailing list