Re: [LTP] [PATCH] ioctl_pidfd02-06: Add CONFIG_USER_NS and CONFIG_PID_NS to needs_kconfigs

Petr Vorel
2025-12-15T16:14:27Z

Hi,
...
> > > +++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd02.c
> > > @@ -81,5 +81,10 @@ static struct tst_test test = {
> > > {&info0, .size = sizeof(*info0)},
> > > {&info1, .size = sizeof(*info1)},
> > > {}
> > > + },
> > > + .needs_kconfigs = (const char *[]) {
> > > + "CONFIG_USER_NS",
> > > + "CONFIG_PID_NS",

> > How about to check /proc/self/ns/user and /proc/self/ns/pid as ioctl_ns06.c
> > does?

> > int exists = access("/proc/self/ns/user", F_OK);

> > if (exists < 0)
> > tst_res(TCONF, "namespace not available");

> > Long time ago we tried to avoid forcing config. Is it now considered as better?
> > (maybe more readable?) Or we would keep checking /proc (or /sys) but add a
> > comment for required functions?

> This case is specific to the CONFIG_PID_NS/CONFIG_USER_NS configurations
> and the feature can't be tested if kernel is not configured with them.
> Manual is clear about it: https://www.man7.org/linux/man-pages/man7/pid_namespaces.7.html

And https://www.man7.org/linux/man-pages/man7/user_namespaces.7.html.

Yeah, I understand that. The dependency of CLONE_NEWUSER/CLONE_NEWPID is also
visible in kernel sources (e.g. fs/nsfs.c). But my question was different:
Do we now prefer everything kind of document with .needs_kconfigs, even it's
possible to detect it otherwise? (speed of parsing kconfig, kind of hard request
for kconfig being available even we can figure the support otherwise).

And if we decide for forcing kconfig, we should update ioctl_ns06.c, which does
/proc based detection (i.e. to use the same approach).

Kind regards,
Petr