Skip to contentSkip to conversation

ioctl_pidfd05: Check if PIDFD_INFO_EXIT is available

PATCH In review Avinesh Kumar 3 participants 4 messages Sep 17, 2025 – Sep 22, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ioctl_pidfd05: Check if PIDFD_INFO_EXIT is available

This test also needs this check as it might fail with
ioctl_pidfd05.c:45: TFAIL: ioctl(pidfd, PIDFD_GET_INFO, NULL) expected EINVAL: ENOTTY (25) ioctl_pidfd05.c:46: TFAIL: ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid) expected EINVAL: ENOTTY (25) when system does not have PIDFD_INFO_EXIT implementation.

---
 testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c +8 -1
index c379717b3..01ea363b6 100644
@@ -14,7 +14,7 @@
 #include "tst_test.h"
 #include "lapi/pidfd.h"
 #include "lapi/sched.h"
-#include "lapi/ioctl.h"
+#include "ioctl_pidfd.h"
 
 struct pidfd_info_invalid {
 	uint32_t dummy;
@@ -48,8 +48,15 @@ static void run(void)
 	SAFE_CLOSE(pidfd);
 }
 
+static void setup(void)
+{
+	if (!ioctl_pidfd_info_exit_supported())
+		tst_brk(TCONF, "PIDFD_INFO_EXIT is not supported by ioctl()");
+}
+
 static struct tst_test test = {
 	.test_all = run,
+	.setup = setup,
 	.forks_child = 1,
 	.bufs = (struct tst_buffers []) {
 		{&args, .size = sizeof(*args)},
Signature · 5 lines
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#1 lore raw

Hi Avinesh,

Quoted 4 lines

This test also needs this check as it might fail with
ioctl_pidfd05.c:45: TFAIL: ioctl(pidfd, PIDFD_GET_INFO, NULL) expected EINVAL: ENOTTY (25) ioctl_pidfd05.c:46: TFAIL: ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid) expected EINVAL: ENOTTY (25) when system does not have PIDFD_INFO_EXIT implementation.

Thanks for the fix!. As a quick fix this would work, because ioctl_pidfd_info_exit_supported() is using ioctl(fd, PIDFD_GET_INFO, ...).

But because PIDFD_GET_INFO was added in 6.12:
cdda1f26e74b ("pidfd: add ioctl to retrieve pid info") # v6.12-rc3 and PIDFD_INFO_EXIT in v6.14:
7477d7dce48a ("pidfs: allow to retrieve exit information") # v6.14-rc1 it'd make sense to create ioctl_pidfd_get_info_supported() which would be also used by ioctl_pidfd_info_exit_supported().
Why? There is 6.12 LTSS kernel branch which will get TCONF instead of being tested.

It could be done ioctl_pidfd_get_info_supported() could return int64_t mask (__u64 mask struct pidfd_info member if supported or -1 if ioctl() returned -1. ioctl_pidfd_info_exit_supported() would just evaluate that. Other option is just code duplicity.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi!

Quoted 19 lines
Quoted 4 lines

This test also needs this check as it might fail with
ioctl_pidfd05.c:45: TFAIL: ioctl(pidfd, PIDFD_GET_INFO, NULL) expected EINVAL: ENOTTY (25) ioctl_pidfd05.c:46: TFAIL: ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid) expected EINVAL: ENOTTY (25) when system does not have PIDFD_INFO_EXIT implementation.

Thanks for the fix!. As a quick fix this would work, because ioctl_pidfd_info_exit_supported() is using ioctl(fd, PIDFD_GET_INFO, ...).

But because PIDFD_GET_INFO was added in 6.12:
cdda1f26e74b ("pidfd: add ioctl to retrieve pid info") # v6.12-rc3 and PIDFD_INFO_EXIT in v6.14:
7477d7dce48a ("pidfs: allow to retrieve exit information") # v6.14-rc1 it'd make sense to create ioctl_pidfd_get_info_supported() which would be also used by ioctl_pidfd_info_exit_supported().
Why? There is 6.12 LTSS kernel branch which will get TCONF instead of being tested.

Quoted 4 lines

It could be done ioctl_pidfd_get_info_supported() could return int64_t mask (__u64 mask struct pidfd_info member if supported or -1 if ioctl() returned -1. ioctl_pidfd_info_exit_supported() would just evaluate that. Other option is just code duplicity.

Yes please, we need another check just for PIDFD_GET_INFO with empty mask.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Hi Petr and Cyril,

Quoted 20 lines · CEST Cyril Hrubis

Hi!

Quoted 19 lines
Quoted 4 lines

This test also needs this check as it might fail with
ioctl_pidfd05.c:45: TFAIL: ioctl(pidfd, PIDFD_GET_INFO, NULL) expected EINVAL: ENOTTY (25) ioctl_pidfd05.c:46: TFAIL: ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid) expected EINVAL: ENOTTY (25) when system does not have PIDFD_INFO_EXIT implementation.

Thanks for the fix!. As a quick fix this would work, because ioctl_pidfd_info_exit_supported() is using ioctl(fd, PIDFD_GET_INFO, ...).

But because PIDFD_GET_INFO was added in 6.12:
cdda1f26e74b ("pidfd: add ioctl to retrieve pid info") # v6.12-rc3 and PIDFD_INFO_EXIT in v6.14:
7477d7dce48a ("pidfs: allow to retrieve exit information") # v6.14-rc1 it'd make sense to create ioctl_pidfd_get_info_supported() which would be also used by ioctl_pidfd_info_exit_supported().
Why? There is 6.12 LTSS kernel branch which will get TCONF instead of being tested.

Quoted 9 lines
Quoted 4 lines

It could be done ioctl_pidfd_get_info_supported() could return int64_t mask (__u64 mask struct pidfd_info member if supported or -1 if ioctl() returned -1. ioctl_pidfd_info_exit_supported() would just evaluate that. Other option is just code duplicity.

Yes please, we need another check just for PIDFD_GET_INFO with empty mask.

Thank you both for reviewing and suggesting the correct approach. I have sent the new patch [1].

[1] https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

Regards,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp