public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] ioctl_pidfd05: Check if PIDFD_INFO_EXIT is available
@ 2025-09-17 16:54 Avinesh Kumar
  2025-09-17 17:46 ` Petr Vorel
  0 siblings, 1 reply; 4+ messages in thread
From: Avinesh Kumar @ 2025-09-17 16:54 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
 testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
index c379717b3..01ea363b6 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
@@ -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)},
-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] ioctl_pidfd05: Check if PIDFD_INFO_EXIT is available
  2025-09-17 16:54 [LTP] [PATCH] ioctl_pidfd05: Check if PIDFD_INFO_EXIT is available Avinesh Kumar
@ 2025-09-17 17:46 ` Petr Vorel
  2025-09-18 13:31   ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2025-09-17 17:46 UTC (permalink / raw)
  To: Avinesh Kumar; +Cc: ltp

Hi Avinesh,

> 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.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] ioctl_pidfd05: Check if PIDFD_INFO_EXIT is available
  2025-09-17 17:46 ` Petr Vorel
@ 2025-09-18 13:31   ` Cyril Hrubis
  2025-09-22 20:44     ` Avinesh Kumar
  0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2025-09-18 13:31 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi!
> > 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.
> 
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> 
> 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.

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

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] ioctl_pidfd05: Check if PIDFD_INFO_EXIT is available
  2025-09-18 13:31   ` Cyril Hrubis
@ 2025-09-22 20:44     ` Avinesh Kumar
  0 siblings, 0 replies; 4+ messages in thread
From: Avinesh Kumar @ 2025-09-22 20:44 UTC (permalink / raw)
  To: Petr Vorel, Cyril Hrubis; +Cc: ltp

Hi Petr and Cyril,

On Thursday, September 18, 2025 3:31:03 PM CEST Cyril Hrubis wrote:
> Hi!
> > > 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.
> > 
> > Reviewed-by: Petr Vorel <pvorel@suse.cz>
> > 
> > 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.
> 
> 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/20250922203927.14552-1-akumar@suse.de/


Regards,
Avinesh




-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-09-22 20:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 16:54 [LTP] [PATCH] ioctl_pidfd05: Check if PIDFD_INFO_EXIT is available Avinesh Kumar
2025-09-17 17:46 ` Petr Vorel
2025-09-18 13:31   ` Cyril Hrubis
2025-09-22 20:44     ` Avinesh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox