* [LTP] [PATCH v2 0/8] ioctl_pidfd testing suite
@ 2025-07-04 11:30 Andrea Cervesato
2025-07-04 11:30 ` [LTP] [PATCH v2 1/8] Provide pidfd parameter in tst_clone_args Andrea Cervesato
` (7 more replies)
0 siblings, 8 replies; 24+ messages in thread
From: Andrea Cervesato @ 2025-07-04 11:30 UTC (permalink / raw)
To: ltp
The testing suite has been created to cover the new feature
PIDFD_INFO_EXIT provided by kernel 6.15.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Changes in v2:
- ioctl_pidfd02: check all flags of info before and after process being
reaped. Include a fork() test
- ioctl_pidfd03: verify process info before being reaped
- add more error tests
- Link to v1: https://lore.kernel.org/r/20250626-ioctl_pidfd_suite-v1-0-165b9abf0296@suse.com
---
Andrea Cervesato (8):
Provide pidfd parameter in tst_clone_args
Fallback PIDFD_GET_INFO related definitions
Add ioctl_pidfd01 test
Add ioctl_pidfd02 test
Add ioctl_pidfd03 test
Add ioctl_pidfd04 test
Add ioctl_pidfd05 test
Add ioctl_pidfd06 test
configure.ac | 2 +
include/lapi/pidfd.h | 37 +++++++++++
include/tst_clone.h | 1 +
lib/tst_clone.c | 1 +
runtest/syscalls | 7 +++
testcases/kernel/syscalls/ioctl/.gitignore | 6 ++
testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c | 58 +++++++++++++++++
testcases/kernel/syscalls/ioctl/ioctl_pidfd02.c | 82 +++++++++++++++++++++++++
testcases/kernel/syscalls/ioctl/ioctl_pidfd03.c | 57 +++++++++++++++++
testcases/kernel/syscalls/ioctl/ioctl_pidfd04.c | 65 ++++++++++++++++++++
testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c | 58 +++++++++++++++++
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c | 59 ++++++++++++++++++
12 files changed, 433 insertions(+)
---
base-commit: f6b76fe373d1932ce1d2248e83ff284085145797
change-id: 20250626-ioctl_pidfd_suite-322aa2375c42
Best regards,
--
Andrea Cervesato <andrea.cervesato@suse.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* [LTP] [PATCH v2 1/8] Provide pidfd parameter in tst_clone_args
2025-07-04 11:30 [LTP] [PATCH v2 0/8] ioctl_pidfd testing suite Andrea Cervesato
@ 2025-07-04 11:30 ` Andrea Cervesato
2025-07-07 11:44 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 2/8] Fallback PIDFD_GET_INFO related definitions Andrea Cervesato
` (6 subsequent siblings)
7 siblings, 1 reply; 24+ messages in thread
From: Andrea Cervesato @ 2025-07-04 11:30 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
include/tst_clone.h | 1 +
lib/tst_clone.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/include/tst_clone.h b/include/tst_clone.h
index a57d761ca56dc113dde81a0ed17f15e8f2e58924..a07689c78f575ae6ca87c0952b3e48b3a626012c 100644
--- a/include/tst_clone.h
+++ b/include/tst_clone.h
@@ -12,6 +12,7 @@
/* The parts of clone3's clone_args we support */
struct tst_clone_args {
uint64_t flags;
+ uint64_t pidfd;
uint64_t exit_signal;
uint64_t cgroup;
};
diff --git a/lib/tst_clone.c b/lib/tst_clone.c
index 2aa00beb1a191d8c4a68a96ba529fc48d3777e84..8638052e2ecac2af3a290f01106e10dc8cdc62d1 100644
--- a/lib/tst_clone.c
+++ b/lib/tst_clone.c
@@ -14,6 +14,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)
{
struct clone_args args = {
.flags = tst_args->flags,
+ .pidfd = tst_args->pidfd,
.exit_signal = tst_args->exit_signal,
.cgroup = tst_args->cgroup,
};
--
2.50.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [LTP] [PATCH v2 2/8] Fallback PIDFD_GET_INFO related definitions
2025-07-04 11:30 [LTP] [PATCH v2 0/8] ioctl_pidfd testing suite Andrea Cervesato
2025-07-04 11:30 ` [LTP] [PATCH v2 1/8] Provide pidfd parameter in tst_clone_args Andrea Cervesato
@ 2025-07-04 11:30 ` Andrea Cervesato
2025-07-07 11:48 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 3/8] Add ioctl_pidfd01 test Andrea Cervesato
` (5 subsequent siblings)
7 siblings, 1 reply; 24+ messages in thread
From: Andrea Cervesato @ 2025-07-04 11:30 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
configure.ac | 2 ++
include/lapi/pidfd.h | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/configure.ac b/configure.ac
index 69c5be7362a0e9f2fdaf3e6bd01f92f6f4880108..7132c00df97870e234fd5b8c9fcaf1beb263cf06 100644
--- a/configure.ac
+++ b/configure.ac
@@ -259,6 +259,8 @@ AC_CHECK_TYPES([struct cachestat],,,[#include <sys/mman.h>])
AC_CHECK_TYPES([struct mnt_id_req],,,[#include <sys/mount.h>])
AC_CHECK_TYPES([struct statmount],,,[#include <sys/mount.h>])
+AC_CHECK_TYPES([struct pidfd_info],,,[#include <uapi/linux/pidfd.h>])
+
# Tools knobs
# Bash
diff --git a/include/lapi/pidfd.h b/include/lapi/pidfd.h
index 9ca8e5aa23626646ebb2f18880abd5e52298bfc6..55a44d5840c01bda7b31237c5c0d54ebba8155c5 100644
--- a/include/lapi/pidfd.h
+++ b/include/lapi/pidfd.h
@@ -8,16 +8,53 @@
#define LAPI_PIDFD_H__
#include <fcntl.h>
+#include <stdint.h>
+#include <sys/ioctl.h>
+
#ifdef HAVE_SYS_PIDFD_H
# include <sys/pidfd.h>
#endif
+
#include "config.h"
#include "lapi/syscalls.h"
+#ifndef HAVE_STRUCT_PIDFD_INFO
+struct pidfd_info {
+ uint64_t mask;
+ uint64_t cgroupid;
+ uint32_t pid;
+ uint32_t tgid;
+ uint32_t ppid;
+ uint32_t ruid;
+ uint32_t rgid;
+ uint32_t euid;
+ uint32_t egid;
+ uint32_t suid;
+ uint32_t sgid;
+ uint32_t fsuid;
+ uint32_t fsgid;
+ int32_t exit_code;
+ uint32_t coredump_mask;
+ uint32_t __spare1;
+};
+#endif
+
#ifndef PIDFD_NONBLOCK
#define PIDFD_NONBLOCK O_NONBLOCK
#endif
+#ifndef PIDFS_IOCTL_MAGIC
+#define PIDFS_IOCTL_MAGIC 0xFF
+#endif
+
+#ifndef PIDFD_GET_INFO
+#define PIDFD_GET_INFO _IOWR(PIDFS_IOCTL_MAGIC, 11, struct pidfd_info)
+#endif
+
+#ifndef PIDFD_INFO_EXIT
+#define PIDFD_INFO_EXIT (1UL << 3)
+#endif
+
static inline void pidfd_send_signal_supported(void)
{
/* allow the tests to fail early */
--
2.50.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [LTP] [PATCH v2 3/8] Add ioctl_pidfd01 test
2025-07-04 11:30 [LTP] [PATCH v2 0/8] ioctl_pidfd testing suite Andrea Cervesato
2025-07-04 11:30 ` [LTP] [PATCH v2 1/8] Provide pidfd parameter in tst_clone_args Andrea Cervesato
2025-07-04 11:30 ` [LTP] [PATCH v2 2/8] Fallback PIDFD_GET_INFO related definitions Andrea Cervesato
@ 2025-07-04 11:30 ` Andrea Cervesato
2025-07-07 12:00 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test Andrea Cervesato
` (4 subsequent siblings)
7 siblings, 1 reply; 24+ messages in thread
From: Andrea Cervesato @ 2025-07-04 11:30 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Verify that ioctl() raises the right errors when an application provides
the wrong file descriptor.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 2 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c | 58 +++++++++++++++++++++++++
3 files changed, 61 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index 582422ac9ca8ccae598c626a11cf6ee7c30f0e3a..7f6312ce5fa241a778d8dda7f8ee9edd0a8800e6 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -612,6 +612,8 @@ ioctl_ficlonerange01 ioctl_ficlonerange01
ioctl_ficlonerange02 ioctl_ficlonerange02
ioctl_fiemap01 ioctl_fiemap01
+ioctl_pidfd01 ioctl_pidfd01
+
inotify_init1_01 inotify_init1_01
inotify_init1_02 inotify_init1_02
diff --git a/testcases/kernel/syscalls/ioctl/.gitignore b/testcases/kernel/syscalls/ioctl/.gitignore
index 53a82bb5770ba196811965150fd262ec5d4a6e01..aa952c1a7bae0ae2dbb04de0595f10d508b6759a 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -29,3 +29,4 @@
/ioctl_ficlonerange01
/ioctl_ficlonerange02
/ioctl_fiemap01
+/ioctl_pidfd01
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c
new file mode 100644
index 0000000000000000000000000000000000000000..dbece2b611ecea2e253bd5e784b196f4e0ee73f2
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * Verify that ioctl() raises the right errors when an application provides
+ * the wrong file descriptor.
+ */
+
+#include "tst_test.h"
+#include "lapi/pidfd.h"
+#include "lapi/ioctl.h"
+
+static int exp_errnos[] = {
+ EINVAL,
+ EBADF,
+ ENOTTY,
+};
+
+static struct pidfd_info *info;
+
+static void test_bad_pidfd(struct tst_fd *fd_in)
+{
+ if (fd_in->type == TST_FD_PIDFD) {
+ tst_res(TINFO, "Skipping pidfd: SUCCESS");
+ return;
+ }
+
+ TST_EXP_FAIL_ARR(ioctl(fd_in->fd, PIDFD_GET_INFO, info),
+ exp_errnos, ARRAY_SIZE(exp_errnos),
+ "ioctl(%s, PIDFD_GET_INFO, info)",
+ tst_fd_desc(fd_in));
+}
+
+static void run(void)
+{
+ TST_FD_FOREACH(fd) {
+ tst_res(TINFO, "%s -> ...", tst_fd_desc(&fd));
+ test_bad_pidfd(&fd);
+ }
+}
+
+static void setup(void)
+{
+ info->mask = PIDFD_INFO_EXIT;
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .forks_child = 1,
+ .min_kver = "6.15",
+ .bufs = (struct tst_buffers []) {
+ {&info, .size = sizeof(*info)},
+ {}
+ }
+};
--
2.50.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test
2025-07-04 11:30 [LTP] [PATCH v2 0/8] ioctl_pidfd testing suite Andrea Cervesato
` (2 preceding siblings ...)
2025-07-04 11:30 ` [LTP] [PATCH v2 3/8] Add ioctl_pidfd01 test Andrea Cervesato
@ 2025-07-04 11:30 ` Andrea Cervesato
2025-07-07 12:33 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 5/8] Add ioctl_pidfd03 test Andrea Cervesato
` (3 subsequent siblings)
7 siblings, 1 reply; 24+ messages in thread
From: Andrea Cervesato @ 2025-07-04 11:30 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Check if the ioctl() function allows retrieval of a child's exit code
using PIDFD_INFO_EXIT from a process that can be isolated or not from
the child.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
testcases/kernel/syscalls/ioctl/ioctl_pidfd02.c | 82 +++++++++++++++++++++++++
3 files changed, 84 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index 7f6312ce5fa241a778d8dda7f8ee9edd0a8800e6..23f335846663d62a39e6de3a8f6948c1b0acf8a5 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -613,6 +613,7 @@ ioctl_ficlonerange02 ioctl_ficlonerange02
ioctl_fiemap01 ioctl_fiemap01
ioctl_pidfd01 ioctl_pidfd01
+ioctl_pidfd02 ioctl_pidfd02
inotify_init1_01 inotify_init1_01
inotify_init1_02 inotify_init1_02
diff --git a/testcases/kernel/syscalls/ioctl/.gitignore b/testcases/kernel/syscalls/ioctl/.gitignore
index aa952c1a7bae0ae2dbb04de0595f10d508b6759a..1c81c2bed8db952af0c93fb1ce5bfbad82794b60 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -30,3 +30,4 @@
/ioctl_ficlonerange02
/ioctl_fiemap01
/ioctl_pidfd01
+/ioctl_pidfd02
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd02.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd02.c
new file mode 100644
index 0000000000000000000000000000000000000000..a5a9a561ff676607d68a33ed5572d4c3cdb28f26
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd02.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * Check if the ioctl() function allows retrieval of a child's exit code
+ * using PIDFD_INFO_EXIT from a process that can be isolated or not from the
+ * child.
+ */
+
+#include "tst_test.h"
+#include "lapi/pidfd.h"
+#include "lapi/sched.h"
+
+static struct tst_clone_args *args;
+static struct pidfd_info *info0, *info1;
+
+static void run(unsigned int isolate)
+{
+ int status;
+ int pidfd = 0;
+ pid_t pid_child;
+
+ memset(args, 0, sizeof(struct tst_clone_args));
+ memset(info0, 0, sizeof(struct pidfd_info));
+ memset(info1, 0, sizeof(struct pidfd_info));
+
+ if (isolate) {
+ args->flags = CLONE_PIDFD | CLONE_NEWUSER | CLONE_NEWPID;
+ args->pidfd = (uint64_t)&pidfd;
+ args->exit_signal = SIGCHLD;
+
+ pid_child = SAFE_CLONE(args);
+ } else {
+ pid_child = SAFE_FORK();
+ }
+
+ if (!pid_child) {
+ TST_CHECKPOINT_WAIT(0);
+ exit(100);
+ }
+
+ if (!isolate)
+ pidfd = SAFE_PIDFD_OPEN(pid_child, 0);
+
+ /* child is not reaped and ioctl() won't provide any exit status info */
+ info0->mask = PIDFD_INFO_EXIT;
+ SAFE_IOCTL(pidfd, PIDFD_GET_INFO, info0);
+ TST_EXP_EQ_LI(info0->mask & PIDFD_INFO_EXIT, 0);
+ TST_EXP_EQ_LI(info0->exit_code, 0);
+
+ TST_CHECKPOINT_WAKE(0);
+
+ SAFE_WAITPID(pid_child, &status, 0);
+
+ /* child is now reaped and ioctl() will provide the exit status */
+ info1->mask = PIDFD_INFO_EXIT;
+ SAFE_IOCTL(pidfd, PIDFD_GET_INFO, info1);
+
+ TST_EXP_EQ_LI(info1->mask & PIDFD_INFO_EXIT, PIDFD_INFO_EXIT);
+ TST_EXP_EQ_LI(WIFEXITED(info1->exit_code), WIFEXITED(status));
+ TST_EXP_EQ_LI(WEXITSTATUS(info1->exit_code), WEXITSTATUS(status));
+
+ TST_EXP_EXPR(info0->exit_code != info1->exit_code,
+ "info0->exit_code (%i) != info1->exit_code (%i)",
+ info0->exit_code, info1->exit_code);
+}
+
+static struct tst_test test = {
+ .test = run,
+ .tcnt = 2,
+ .forks_child = 1,
+ .needs_checkpoints = 1,
+ .min_kver = "6.15",
+ .bufs = (struct tst_buffers []) {
+ {&args, .size = sizeof(*args)},
+ {&info0, .size = sizeof(*info0)},
+ {&info1, .size = sizeof(*info1)},
+ {}
+ }
+};
--
2.50.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [LTP] [PATCH v2 5/8] Add ioctl_pidfd03 test
2025-07-04 11:30 [LTP] [PATCH v2 0/8] ioctl_pidfd testing suite Andrea Cervesato
` (3 preceding siblings ...)
2025-07-04 11:30 ` [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test Andrea Cervesato
@ 2025-07-04 11:30 ` Andrea Cervesato
2025-07-07 12:44 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 6/8] Add ioctl_pidfd04 test Andrea Cervesato
` (2 subsequent siblings)
7 siblings, 1 reply; 24+ messages in thread
From: Andrea Cervesato @ 2025-07-04 11:30 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Verify that ioctl() returns ESRCH when a process attempts to access
the exit status of an isolated child using `PIDFD_GET_INFO` and
`PIDFD_INFO_EXIT` is not defined in `struct pidfd_info`.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
testcases/kernel/syscalls/ioctl/ioctl_pidfd03.c | 57 +++++++++++++++++++++++++
3 files changed, 59 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index 23f335846663d62a39e6de3a8f6948c1b0acf8a5..8eec613a941a83b1fed25f96cdce617da0b0ef34 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -614,6 +614,7 @@ ioctl_fiemap01 ioctl_fiemap01
ioctl_pidfd01 ioctl_pidfd01
ioctl_pidfd02 ioctl_pidfd02
+ioctl_pidfd03 ioctl_pidfd03
inotify_init1_01 inotify_init1_01
inotify_init1_02 inotify_init1_02
diff --git a/testcases/kernel/syscalls/ioctl/.gitignore b/testcases/kernel/syscalls/ioctl/.gitignore
index 1c81c2bed8db952af0c93fb1ce5bfbad82794b60..08387dc8f2bc43f8f3a75264841da4beee28bfac 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -31,3 +31,4 @@
/ioctl_fiemap01
/ioctl_pidfd01
/ioctl_pidfd02
+/ioctl_pidfd03
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd03.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd03.c
new file mode 100644
index 0000000000000000000000000000000000000000..17cc9eb1bf60024a78e2be9bf15ae186a987b358
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd03.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * Verify that ioctl() returns ESRCH when a process attempts to access the
+ * exit status of an isolated child using `PIDFD_GET_INFO` and
+ * `PIDFD_INFO_EXIT` is not defined in `struct pidfd_info`.
+ */
+
+#include "tst_test.h"
+#include "lapi/pidfd.h"
+#include "lapi/sched.h"
+
+static struct tst_clone_args *args;
+static struct pidfd_info *info;
+
+static void run(void)
+{
+ int status;
+ int pidfd = 0;
+ pid_t pid_child;
+
+ memset(args, 0, sizeof(struct tst_clone_args));
+
+ args->flags = CLONE_PIDFD | CLONE_NEWUSER | CLONE_NEWPID;
+ args->pidfd = (uint64_t)&pidfd;
+ args->exit_signal = SIGCHLD;
+
+ pid_child = SAFE_CLONE(args);
+ if (!pid_child)
+ exit(100);
+
+ info->mask = 0;
+
+ /* child is not reaped, so ioctl() will pass */
+ SAFE_IOCTL(pidfd, PIDFD_GET_INFO, info);
+ TST_EXP_EQ_LI(info->mask & PIDFD_INFO_EXIT, 0);
+
+ SAFE_WAITPID(pid_child, &status, 0);
+
+ /* child is now reaped, so we get ESRCH */
+ TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, info), ESRCH);
+ TST_EXP_EQ_LI(info->mask & PIDFD_INFO_EXIT, 0);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .forks_child = 1,
+ .min_kver = "6.15",
+ .bufs = (struct tst_buffers []) {
+ {&args, .size = sizeof(*args)},
+ {&info, .size = sizeof(*info)},
+ {}
+ }
+};
--
2.50.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [LTP] [PATCH v2 6/8] Add ioctl_pidfd04 test
2025-07-04 11:30 [LTP] [PATCH v2 0/8] ioctl_pidfd testing suite Andrea Cervesato
` (4 preceding siblings ...)
2025-07-04 11:30 ` [LTP] [PATCH v2 5/8] Add ioctl_pidfd03 test Andrea Cervesato
@ 2025-07-04 11:30 ` Andrea Cervesato
2025-07-07 12:56 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 7/8] Add ioctl_pidfd05 test Andrea Cervesato
2025-07-04 11:30 ` [LTP] [PATCH v2 8/8] Add ioctl_pidfd06 test Andrea Cervesato
7 siblings, 1 reply; 24+ messages in thread
From: Andrea Cervesato @ 2025-07-04 11:30 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Verify that ioctl() permits to obtain the exit code of an isolated
signaled child via PIDFD_INFO_EXIT from within a process.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
testcases/kernel/syscalls/ioctl/ioctl_pidfd04.c | 65 +++++++++++++++++++++++++
3 files changed, 67 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index 8eec613a941a83b1fed25f96cdce617da0b0ef34..a28f4857ffccc070665361f2741ddbaa480d1153 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -615,6 +615,7 @@ ioctl_fiemap01 ioctl_fiemap01
ioctl_pidfd01 ioctl_pidfd01
ioctl_pidfd02 ioctl_pidfd02
ioctl_pidfd03 ioctl_pidfd03
+ioctl_pidfd04 ioctl_pidfd04
inotify_init1_01 inotify_init1_01
inotify_init1_02 inotify_init1_02
diff --git a/testcases/kernel/syscalls/ioctl/.gitignore b/testcases/kernel/syscalls/ioctl/.gitignore
index 08387dc8f2bc43f8f3a75264841da4beee28bfac..b6203828f324647ccf5d809e80e2ada515817006 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -32,3 +32,4 @@
/ioctl_pidfd01
/ioctl_pidfd02
/ioctl_pidfd03
+/ioctl_pidfd04
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd04.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd04.c
new file mode 100644
index 0000000000000000000000000000000000000000..355d9a030cae538af7c1da5b1f4b1fd8a593f23a
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd04.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * Verify that ioctl() permits to obtain the exit code of an isolated signaled
+ * child via PIDFD_INFO_EXIT from within a process.
+ */
+
+#include "tst_test.h"
+#include "lapi/pidfd.h"
+#include "lapi/sched.h"
+
+static struct tst_clone_args *args;
+static struct pidfd_info *info;
+
+static void run(void)
+{
+ int status;
+ int pidfd = 0;
+ pid_t pid_child;
+
+ memset(args, 0, sizeof(struct tst_clone_args));
+ memset(info, 0, sizeof(struct pidfd_info));
+
+ info->mask = PIDFD_INFO_EXIT;
+
+ args->flags = CLONE_PIDFD | CLONE_NEWUSER | CLONE_NEWPID;
+ args->pidfd = (uint64_t)&pidfd;
+ args->exit_signal = SIGCHLD;
+
+ pid_child = SAFE_CLONE(args);
+ if (!pid_child) {
+ TST_CHECKPOINT_WAKE_AND_WAIT(0);
+ exit(1);
+ }
+
+ TST_CHECKPOINT_WAIT(0);
+
+ SAFE_KILL(pid_child, SIGKILL);
+ SAFE_WAITPID(pid_child, &status, 0);
+
+ SAFE_IOCTL(pidfd, PIDFD_GET_INFO, info);
+
+ TST_EXP_EQ_LI(info->mask & PIDFD_INFO_EXIT, PIDFD_INFO_EXIT);
+ TST_EXP_EQ_LI(WIFSIGNALED(info->exit_code), WIFSIGNALED(status));
+ TST_EXP_EQ_LI(WEXITSTATUS(info->exit_code), WEXITSTATUS(status));
+ TST_EXP_EQ_LI(WTERMSIG(info->exit_code), WTERMSIG(status));
+
+ TST_EXP_EXPR(WIFSIGNALED(info->exit_code) &&
+ WTERMSIG(info->exit_code) == SIGKILL);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .forks_child = 1,
+ .needs_checkpoints = 1,
+ .min_kver = "6.15",
+ .bufs = (struct tst_buffers []) {
+ {&args, .size = sizeof(*args)},
+ {&info, .size = sizeof(*info)},
+ {}
+ }
+};
--
2.50.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [LTP] [PATCH v2 7/8] Add ioctl_pidfd05 test
2025-07-04 11:30 [LTP] [PATCH v2 0/8] ioctl_pidfd testing suite Andrea Cervesato
` (5 preceding siblings ...)
2025-07-04 11:30 ` [LTP] [PATCH v2 6/8] Add ioctl_pidfd04 test Andrea Cervesato
@ 2025-07-04 11:30 ` Andrea Cervesato
2025-07-07 13:16 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 8/8] Add ioctl_pidfd06 test Andrea Cervesato
7 siblings, 1 reply; 24+ messages in thread
From: Andrea Cervesato @ 2025-07-04 11:30 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Verify that ioctl() raises an EINVAL error when PIDFD_GET_INFO
is used. This happens when:
- info parameter is NULL
- info parameter is providing the wrong size
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c | 58 +++++++++++++++++++++++++
3 files changed, 60 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index a28f4857ffccc070665361f2741ddbaa480d1153..91908312df82f677e6fa711653b56de8e5ccf016 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -616,6 +616,7 @@ ioctl_pidfd01 ioctl_pidfd01
ioctl_pidfd02 ioctl_pidfd02
ioctl_pidfd03 ioctl_pidfd03
ioctl_pidfd04 ioctl_pidfd04
+ioctl_pidfd05 ioctl_pidfd05
inotify_init1_01 inotify_init1_01
inotify_init1_02 inotify_init1_02
diff --git a/testcases/kernel/syscalls/ioctl/.gitignore b/testcases/kernel/syscalls/ioctl/.gitignore
index b6203828f324647ccf5d809e80e2ada515817006..4658173eac337a8e9cae1844340f9ecc0e55218f 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -33,3 +33,4 @@
/ioctl_pidfd02
/ioctl_pidfd03
/ioctl_pidfd04
+/ioctl_pidfd05
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
new file mode 100644
index 0000000000000000000000000000000000000000..c5bec82f12a067283c7ea286f36b6f651c8f1ffd
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * Verify that ioctl() raises an EINVAL error when PIDFD_GET_INFO is used. This
+ * happens when:
+ *
+ * - info parameter is NULL
+ * - info parameter is providing the wrong size
+ */
+
+#include "tst_test.h"
+#include "lapi/pidfd.h"
+#include "lapi/sched.h"
+#include "lapi/ioctl.h"
+
+struct pidfd_info_invalid {
+ uint32_t dummy;
+};
+
+#define PIDFD_GET_INFO_SHORT _IOWR(PIDFS_IOCTL_MAGIC, 11, struct pidfd_info_invalid)
+
+static struct tst_clone_args *args;
+static struct pidfd_info_invalid *info_invalid;
+
+static void run(void)
+{
+ int pidfd = 0;
+ pid_t pid_child;
+
+ memset(args, 0, sizeof(struct tst_clone_args));
+
+ info_invalid->dummy = 1;
+
+ args->flags = CLONE_PIDFD | CLONE_NEWUSER | CLONE_NEWPID;
+ args->pidfd = (uint64_t)&pidfd;
+ args->exit_signal = SIGCHLD;
+
+ pid_child = SAFE_CLONE(args);
+ if (!pid_child)
+ exit(0);
+
+ TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, NULL), EINVAL);
+ TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid), EINVAL);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .forks_child = 1,
+ .min_kver = "6.15",
+ .bufs = (struct tst_buffers []) {
+ {&args, .size = sizeof(*args)},
+ {&info_invalid, .size = sizeof(*info_invalid)},
+ {}
+ }
+};
--
2.50.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [LTP] [PATCH v2 8/8] Add ioctl_pidfd06 test
2025-07-04 11:30 [LTP] [PATCH v2 0/8] ioctl_pidfd testing suite Andrea Cervesato
` (6 preceding siblings ...)
2025-07-04 11:30 ` [LTP] [PATCH v2 7/8] Add ioctl_pidfd05 test Andrea Cervesato
@ 2025-07-04 11:30 ` Andrea Cervesato
2025-07-07 13:27 ` Cyril Hrubis
7 siblings, 1 reply; 24+ messages in thread
From: Andrea Cervesato @ 2025-07-04 11:30 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Verify that ioctl() doesn't allow to obtain the exit status of an
isolated process via PIDFD_INFO_EXIT in within an another isolated
process, which doesn't have any parent connection.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c | 59 +++++++++++++++++++++++++
3 files changed, 61 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index 91908312df82f677e6fa711653b56de8e5ccf016..dd4e92da286c1683807abdd35f271e37fa796bef 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -617,6 +617,7 @@ ioctl_pidfd02 ioctl_pidfd02
ioctl_pidfd03 ioctl_pidfd03
ioctl_pidfd04 ioctl_pidfd04
ioctl_pidfd05 ioctl_pidfd05
+ioctl_pidfd06 ioctl_pidfd06
inotify_init1_01 inotify_init1_01
inotify_init1_02 inotify_init1_02
diff --git a/testcases/kernel/syscalls/ioctl/.gitignore b/testcases/kernel/syscalls/ioctl/.gitignore
index 4658173eac337a8e9cae1844340f9ecc0e55218f..396fe62da37246e0d32f469a519dae98b4fab3d9 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -34,3 +34,4 @@
/ioctl_pidfd03
/ioctl_pidfd04
/ioctl_pidfd05
+/ioctl_pidfd06
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c
new file mode 100644
index 0000000000000000000000000000000000000000..6d77982eced49929caecc8280d7091a18aa8ac02
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * Verify that ioctl() doesn't allow to obtain the exit status of an isolated
+ * process via PIDFD_INFO_EXIT in within an another isolated process, which
+ * doesn't have any parent connection.
+ */
+
+#include "tst_test.h"
+#include "lapi/pidfd.h"
+#include "lapi/sched.h"
+
+static struct tst_clone_args *args;
+static struct pidfd_info *info;
+
+static void run(void)
+{
+ int pidfd;
+ pid_t pid_child;
+
+ memset(args, 0, sizeof(struct tst_clone_args));
+ memset(info, 0, sizeof(struct pidfd_info));
+
+ info->mask = PIDFD_INFO_EXIT;
+
+ args->flags = CLONE_PIDFD | CLONE_NEWUSER | CLONE_NEWPID;
+ args->pidfd = (uint64_t)&pidfd;
+ args->exit_signal = SIGCHLD;
+
+ pid_child = SAFE_CLONE(args);
+ if (!pid_child)
+ exit(100);
+
+ SAFE_WAITPID(pid_child, NULL, 0);
+
+ memset(args, 0, sizeof(struct tst_clone_args));
+
+ args->flags = CLONE_NEWUSER | CLONE_NEWPID;
+ args->exit_signal = SIGCHLD;
+
+ if (!SAFE_CLONE(args)) {
+ TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, info), ESRCH);
+ exit(0);
+ }
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .forks_child = 1,
+ .min_kver = "6.15",
+ .bufs = (struct tst_buffers []) {
+ {&args, .size = sizeof(*args)},
+ {&info, .size = sizeof(*info)},
+ {}
+ }
+};
--
2.50.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 1/8] Provide pidfd parameter in tst_clone_args
2025-07-04 11:30 ` [LTP] [PATCH v2 1/8] Provide pidfd parameter in tst_clone_args Andrea Cervesato
@ 2025-07-07 11:44 ` Cyril Hrubis
0 siblings, 0 replies; 24+ messages in thread
From: Cyril Hrubis @ 2025-07-07 11:44 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 2/8] Fallback PIDFD_GET_INFO related definitions
2025-07-04 11:30 ` [LTP] [PATCH v2 2/8] Fallback PIDFD_GET_INFO related definitions Andrea Cervesato
@ 2025-07-07 11:48 ` Cyril Hrubis
0 siblings, 0 replies; 24+ messages in thread
From: Cyril Hrubis @ 2025-07-07 11:48 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> configure.ac | 2 ++
> include/lapi/pidfd.h | 37 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 39 insertions(+)
>
> diff --git a/configure.ac b/configure.ac
> index 69c5be7362a0e9f2fdaf3e6bd01f92f6f4880108..7132c00df97870e234fd5b8c9fcaf1beb263cf06 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -259,6 +259,8 @@ AC_CHECK_TYPES([struct cachestat],,,[#include <sys/mman.h>])
> AC_CHECK_TYPES([struct mnt_id_req],,,[#include <sys/mount.h>])
> AC_CHECK_TYPES([struct statmount],,,[#include <sys/mount.h>])
>
> +AC_CHECK_TYPES([struct pidfd_info],,,[#include <uapi/linux/pidfd.h>])
^
Just: <linux/pidfd.h>
When kernel headers are packaged and later installed on a system they
do not have the uapi/ directory prefix anymore.
> +
> # Tools knobs
>
> # Bash
> diff --git a/include/lapi/pidfd.h b/include/lapi/pidfd.h
> index 9ca8e5aa23626646ebb2f18880abd5e52298bfc6..55a44d5840c01bda7b31237c5c0d54ebba8155c5 100644
> --- a/include/lapi/pidfd.h
> +++ b/include/lapi/pidfd.h
> @@ -8,16 +8,53 @@
> #define LAPI_PIDFD_H__
>
> #include <fcntl.h>
> +#include <stdint.h>
> +#include <sys/ioctl.h>
> +
> #ifdef HAVE_SYS_PIDFD_H
> # include <sys/pidfd.h>
> #endif
> +
> #include "config.h"
> #include "lapi/syscalls.h"
>
> +#ifndef HAVE_STRUCT_PIDFD_INFO
> +struct pidfd_info {
> + uint64_t mask;
> + uint64_t cgroupid;
> + uint32_t pid;
> + uint32_t tgid;
> + uint32_t ppid;
> + uint32_t ruid;
> + uint32_t rgid;
> + uint32_t euid;
> + uint32_t egid;
> + uint32_t suid;
> + uint32_t sgid;
> + uint32_t fsuid;
> + uint32_t fsgid;
> + int32_t exit_code;
> + uint32_t coredump_mask;
> + uint32_t __spare1;
> +};
> +#endif
> +
> #ifndef PIDFD_NONBLOCK
> #define PIDFD_NONBLOCK O_NONBLOCK
> #endif
Generally you are supposed to indent the inner macros by spaces after
the hash. So it looks like:
#ifndef ..
# define
# ifdef
# define
# endif
#endif
With these two small things fixed:
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 3/8] Add ioctl_pidfd01 test
2025-07-04 11:30 ` [LTP] [PATCH v2 3/8] Add ioctl_pidfd01 test Andrea Cervesato
@ 2025-07-07 12:00 ` Cyril Hrubis
0 siblings, 0 replies; 24+ messages in thread
From: Cyril Hrubis @ 2025-07-07 12:00 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test
2025-07-04 11:30 ` [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test Andrea Cervesato
@ 2025-07-07 12:33 ` Cyril Hrubis
2025-07-07 15:25 ` Andrea Cervesato via ltp
2025-07-07 15:28 ` Andrea Cervesato via ltp
0 siblings, 2 replies; 24+ messages in thread
From: Cyril Hrubis @ 2025-07-07 12:33 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> diff --git a/testcases/kernel/syscalls/ioctl/.gitignore b/testcases/kernel/syscalls/ioctl/.gitignore
> index aa952c1a7bae0ae2dbb04de0595f10d508b6759a..1c81c2bed8db952af0c93fb1ce5bfbad82794b60 100644
> --- a/testcases/kernel/syscalls/ioctl/.gitignore
> +++ b/testcases/kernel/syscalls/ioctl/.gitignore
> @@ -30,3 +30,4 @@
> /ioctl_ficlonerange02
> /ioctl_fiemap01
> /ioctl_pidfd01
> +/ioctl_pidfd02
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd02.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd02.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..a5a9a561ff676607d68a33ed5572d4c3cdb28f26
> --- /dev/null
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd02.c
> @@ -0,0 +1,82 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2025 Andrea Cervesato <andrea.cervesato@suse.com>
> + */
> +
> +/*\
> + * Check if the ioctl() function allows retrieval of a child's exit code
> + * using PIDFD_INFO_EXIT from a process that can be isolated or not from the
> + * child.
> + */
> +
> +#include "tst_test.h"
> +#include "lapi/pidfd.h"
> +#include "lapi/sched.h"
> +
> +static struct tst_clone_args *args;
> +static struct pidfd_info *info0, *info1;
> +
> +static void run(unsigned int isolate)
> +{
> + int status;
> + int pidfd = 0;
> + pid_t pid_child;
> +
> + memset(args, 0, sizeof(struct tst_clone_args));
> + memset(info0, 0, sizeof(struct pidfd_info));
> + memset(info1, 0, sizeof(struct pidfd_info));
> +
> + if (isolate) {
> + args->flags = CLONE_PIDFD | CLONE_NEWUSER | CLONE_NEWPID;
> + args->pidfd = (uint64_t)&pidfd;
> + args->exit_signal = SIGCHLD;
> +
> + pid_child = SAFE_CLONE(args);
> + } else {
> + pid_child = SAFE_FORK();
> + }
> +
> + if (!pid_child) {
> + TST_CHECKPOINT_WAIT(0);
> + exit(100);
> + }
> +
> + if (!isolate)
> + pidfd = SAFE_PIDFD_OPEN(pid_child, 0);
> +
> + /* child is not reaped and ioctl() won't provide any exit status info */
> + info0->mask = PIDFD_INFO_EXIT;
> + SAFE_IOCTL(pidfd, PIDFD_GET_INFO, info0);
> + TST_EXP_EQ_LI(info0->mask & PIDFD_INFO_EXIT, 0);
> + TST_EXP_EQ_LI(info0->exit_code, 0);
> +
> + TST_CHECKPOINT_WAKE(0);
> +
> + SAFE_WAITPID(pid_child, &status, 0);
> +
> + /* child is now reaped and ioctl() will provide the exit status */
> + info1->mask = PIDFD_INFO_EXIT;
> + SAFE_IOCTL(pidfd, PIDFD_GET_INFO, info1);
> +
> + TST_EXP_EQ_LI(info1->mask & PIDFD_INFO_EXIT, PIDFD_INFO_EXIT);
> + TST_EXP_EQ_LI(WIFEXITED(info1->exit_code), WIFEXITED(status));
> + TST_EXP_EQ_LI(WEXITSTATUS(info1->exit_code), WEXITSTATUS(status));
> +
> + TST_EXP_EXPR(info0->exit_code != info1->exit_code,
> + "info0->exit_code (%i) != info1->exit_code (%i)",
> + info0->exit_code, info1->exit_code);
Wouldn't it be just easier to check that info1->exit_code == 100? We
already asserted that info0->exit_code == 0 and because 100 != 0 we will
get this assertion already covered.
> +}
> +
> +static struct tst_test test = {
> + .test = run,
> + .tcnt = 2,
> + .forks_child = 1,
> + .needs_checkpoints = 1,
> + .min_kver = "6.15",
We just backported this into 6.12 in SUSE so we would need a different
runtime detection than this. Generally it's a good idea to avoid kernel
version checks if possible.
Looking at the kernel code it looks that if the PIDFD_INFO_EXIT is not
supported we will get ESRCH in the second case. So I suppose that better
fix would be to allow ESRCH in the second case if kernel is older than
6.15 instead of skipping the whole test.
> + .bufs = (struct tst_buffers []) {
> + {&args, .size = sizeof(*args)},
> + {&info0, .size = sizeof(*info0)},
> + {&info1, .size = sizeof(*info1)},
> + {}
> + }
> +};
>
> --
> 2.50.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 5/8] Add ioctl_pidfd03 test
2025-07-04 11:30 ` [LTP] [PATCH v2 5/8] Add ioctl_pidfd03 test Andrea Cervesato
@ 2025-07-07 12:44 ` Cyril Hrubis
0 siblings, 0 replies; 24+ messages in thread
From: Cyril Hrubis @ 2025-07-07 12:44 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> +static struct tst_test test = {
> + .test_all = run,
> + .forks_child = 1,
> + .min_kver = "6.15",
Same here, otherwise the test looks good.
> + .bufs = (struct tst_buffers []) {
> + {&args, .size = sizeof(*args)},
> + {&info, .size = sizeof(*info)},
> + {}
> + }
> +};
>
> --
> 2.50.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 6/8] Add ioctl_pidfd04 test
2025-07-04 11:30 ` [LTP] [PATCH v2 6/8] Add ioctl_pidfd04 test Andrea Cervesato
@ 2025-07-07 12:56 ` Cyril Hrubis
0 siblings, 0 replies; 24+ messages in thread
From: Cyril Hrubis @ 2025-07-07 12:56 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> +static struct tst_test test = {
> + .test_all = run,
> + .forks_child = 1,
> + .needs_checkpoints = 1,
> + .min_kver = "6.15",
Here as well, the rest looks fine.
> + .bufs = (struct tst_buffers []) {
> + {&args, .size = sizeof(*args)},
> + {&info, .size = sizeof(*info)},
> + {}
> + }
> +};
>
> --
> 2.50.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 7/8] Add ioctl_pidfd05 test
2025-07-04 11:30 ` [LTP] [PATCH v2 7/8] Add ioctl_pidfd05 test Andrea Cervesato
@ 2025-07-07 13:16 ` Cyril Hrubis
0 siblings, 0 replies; 24+ messages in thread
From: Cyril Hrubis @ 2025-07-07 13:16 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> +static void run(void)
> +{
> + int pidfd = 0;
> + pid_t pid_child;
> +
> + memset(args, 0, sizeof(struct tst_clone_args));
> +
> + info_invalid->dummy = 1;
> +
> + args->flags = CLONE_PIDFD | CLONE_NEWUSER | CLONE_NEWPID;
> + args->pidfd = (uint64_t)&pidfd;
> + args->exit_signal = SIGCHLD;
> +
> + pid_child = SAFE_CLONE(args);
> + if (!pid_child)
> + exit(0);
> +
> + TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, NULL), EINVAL);
> + TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid), EINVAL);
> +}
> +
> +static struct tst_test test = {
> + .test_all = run,
> + .forks_child = 1,
> + .min_kver = "6.15",
If I'm looking right PIDFD_INFO has been added to 6.13. So in this case
I would allow the call to fail with ENOTTY before 6.13 instead.
> + .bufs = (struct tst_buffers []) {
> + {&args, .size = sizeof(*args)},
> + {&info_invalid, .size = sizeof(*info_invalid)},
> + {}
> + }
> +};
>
> --
> 2.50.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 8/8] Add ioctl_pidfd06 test
2025-07-04 11:30 ` [LTP] [PATCH v2 8/8] Add ioctl_pidfd06 test Andrea Cervesato
@ 2025-07-07 13:27 ` Cyril Hrubis
0 siblings, 0 replies; 24+ messages in thread
From: Cyril Hrubis @ 2025-07-07 13:27 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> +static struct tst_test test = {
> + .test_all = run,
> + .forks_child = 1,
> + .min_kver = "6.15",
In this case we also have to allow the call to fail with ENOTTY before
6.13 instead I think.
> + .bufs = (struct tst_buffers []) {
> + {&args, .size = sizeof(*args)},
> + {&info, .size = sizeof(*info)},
> + {}
> + }
> +};
>
> --
> 2.50.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test
2025-07-07 12:33 ` Cyril Hrubis
@ 2025-07-07 15:25 ` Andrea Cervesato via ltp
2025-07-07 15:28 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 24+ messages in thread
From: Andrea Cervesato via ltp @ 2025-07-07 15:25 UTC (permalink / raw)
To: Cyril Hrubis, Andrea Cervesato; +Cc: ltp
On 7/7/25 2:33 PM, Cyril Hrubis wrote:
> Wouldn't it be just easier to check that info1->exit_code == 100? We
info1->exit_code is the equivalent of the "wstatus" set by waitpid(), so
eventually we should:
TST_EXP_EQ_LI(info1->exit_code, status);
- Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test
2025-07-07 12:33 ` Cyril Hrubis
2025-07-07 15:25 ` Andrea Cervesato via ltp
@ 2025-07-07 15:28 ` Andrea Cervesato via ltp
2025-07-07 15:31 ` Cyril Hrubis
2025-07-07 15:37 ` Cyril Hrubis
1 sibling, 2 replies; 24+ messages in thread
From: Andrea Cervesato via ltp @ 2025-07-07 15:28 UTC (permalink / raw)
To: Cyril Hrubis, Andrea Cervesato; +Cc: ltp
On 7/7/25 2:33 PM, Cyril Hrubis wrote:
> Looking at the kernel code it looks that if the PIDFD_INFO_EXIT is not
> supported we will get ESRCH in the second case. So I suppose that better
> fix would be to allow ESRCH in the second case if kernel is older than
> 6.15 instead of skipping the whole test.
Maybe it makes more sense to check PIDFD_INFO_EXIT is available via
configure.ac and eventually check for this support in the setup(). So we
avoid weird runtime checks. WDYT?
- Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test
2025-07-07 15:28 ` Andrea Cervesato via ltp
@ 2025-07-07 15:31 ` Cyril Hrubis
2025-07-07 15:39 ` Cyril Hrubis
2025-07-07 15:37 ` Cyril Hrubis
1 sibling, 1 reply; 24+ messages in thread
From: Cyril Hrubis @ 2025-07-07 15:31 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> > Looking at the kernel code it looks that if the PIDFD_INFO_EXIT is not
> > supported we will get ESRCH in the second case. So I suppose that better
> > fix would be to allow ESRCH in the second case if kernel is older than
> > 6.15 instead of skipping the whole test.
>
> Maybe it makes more sense to check PIDFD_INFO_EXIT is available via
> configure.ac and eventually check for this support in the setup(). So we
> avoid weird runtime checks. WDYT?
Forget about configure checks, these are useless since the version of
the kernel never corresponds to the kernel headers installed on the
system.
The only way how to do things is to check if something is present at a
runtime.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test
2025-07-07 15:28 ` Andrea Cervesato via ltp
2025-07-07 15:31 ` Cyril Hrubis
@ 2025-07-07 15:37 ` Cyril Hrubis
2025-07-07 16:04 ` Andrea Cervesato via ltp
2025-07-07 16:06 ` Andrea Cervesato via ltp
1 sibling, 2 replies; 24+ messages in thread
From: Cyril Hrubis @ 2025-07-07 15:37 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> > Looking at the kernel code it looks that if the PIDFD_INFO_EXIT is not
> > supported we will get ESRCH in the second case. So I suppose that better
> > fix would be to allow ESRCH in the second case if kernel is older than
> > 6.15 instead of skipping the whole test.
>
> Maybe it makes more sense to check PIDFD_INFO_EXIT is available via
> configure.ac and eventually check for this support in the setup(). So we
> avoid weird runtime checks. WDYT?
And if you think about checking PIDFD_INFO_EXIT in the test setup() that
may be doable. But there is no need for configure checks in that case,
we just use PIDFD_INFO_EXIT fallback definition from the lapi headers.
I suppose adding a check for support that would be called if kernel
version is older than 6.15 would work as well.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test
2025-07-07 15:31 ` Cyril Hrubis
@ 2025-07-07 15:39 ` Cyril Hrubis
0 siblings, 0 replies; 24+ messages in thread
From: Cyril Hrubis @ 2025-07-07 15:39 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> > > Looking at the kernel code it looks that if the PIDFD_INFO_EXIT is not
> > > supported we will get ESRCH in the second case. So I suppose that better
> > > fix would be to allow ESRCH in the second case if kernel is older than
> > > 6.15 instead of skipping the whole test.
> >
> > Maybe it makes more sense to check PIDFD_INFO_EXIT is available via
> > configure.ac and eventually check for this support in the setup(). So we
> > avoid weird runtime checks. WDYT?
>
> Forget about configure checks, these are useless since the version of
> the kernel never corresponds to the kernel headers installed on the
> system.
>
> The only way how to do things is to check if something is present at a
> runtime.
To sum it up configure checks should be only used to detect if fallback
definitions should be enabled or not.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test
2025-07-07 15:37 ` Cyril Hrubis
@ 2025-07-07 16:04 ` Andrea Cervesato via ltp
2025-07-07 16:06 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 24+ messages in thread
From: Andrea Cervesato via ltp @ 2025-07-07 16:04 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
On 7/7/25 5:37 PM, Cyril Hrubis wrote:
> Hi!
>>> Looking at the kernel code it looks that if the PIDFD_INFO_EXIT is not
>>> supported we will get ESRCH in the second case. So I suppose that better
>>> fix would be to allow ESRCH in the second case if kernel is older than
>>> 6.15 instead of skipping the whole test.
>> Maybe it makes more sense to check PIDFD_INFO_EXIT is available via
>> configure.ac and eventually check for this support in the setup(). So we
>> avoid weird runtime checks. WDYT?
> And if you think about checking PIDFD_INFO_EXIT in the test setup() that
> may be doable. But there is no need for configure checks in that case,
> we just use PIDFD_INFO_EXIT fallback definition from the lapi headers.
>
> I suppose adding a check for support that would be called if kernel
> version is older than 6.15 would work as well.
>
If PIDFD_INFO_EXIT is defined, then struct pidfd_info.exit_code will be defined. We can verify this via configure.ac.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test
2025-07-07 15:37 ` Cyril Hrubis
2025-07-07 16:04 ` Andrea Cervesato via ltp
@ 2025-07-07 16:06 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 24+ messages in thread
From: Andrea Cervesato via ltp @ 2025-07-07 16:06 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
On 7/7/25 5:37 PM, Cyril Hrubis wrote:
> Hi!
>>> Looking at the kernel code it looks that if the PIDFD_INFO_EXIT is not
>>> supported we will get ESRCH in the second case. So I suppose that better
>>> fix would be to allow ESRCH in the second case if kernel is older than
>>> 6.15 instead of skipping the whole test.
>> Maybe it makes more sense to check PIDFD_INFO_EXIT is available via
>> configure.ac and eventually check for this support in the setup(). So we
>> avoid weird runtime checks. WDYT?
> And if you think about checking PIDFD_INFO_EXIT in the test setup() that
> may be doable. But there is no need for configure checks in that case,
> we just use PIDFD_INFO_EXIT fallback definition from the lapi headers.
>
> I suppose adding a check for support that would be called if kernel
> version is older than 6.15 would work as well.
>
If PIDFD_INFO_EXIT is defined, then struct pidfd_info.exit_code will be defined. We can verify this via configure.ac.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2025-07-07 16:06 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-04 11:30 [LTP] [PATCH v2 0/8] ioctl_pidfd testing suite Andrea Cervesato
2025-07-04 11:30 ` [LTP] [PATCH v2 1/8] Provide pidfd parameter in tst_clone_args Andrea Cervesato
2025-07-07 11:44 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 2/8] Fallback PIDFD_GET_INFO related definitions Andrea Cervesato
2025-07-07 11:48 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 3/8] Add ioctl_pidfd01 test Andrea Cervesato
2025-07-07 12:00 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 4/8] Add ioctl_pidfd02 test Andrea Cervesato
2025-07-07 12:33 ` Cyril Hrubis
2025-07-07 15:25 ` Andrea Cervesato via ltp
2025-07-07 15:28 ` Andrea Cervesato via ltp
2025-07-07 15:31 ` Cyril Hrubis
2025-07-07 15:39 ` Cyril Hrubis
2025-07-07 15:37 ` Cyril Hrubis
2025-07-07 16:04 ` Andrea Cervesato via ltp
2025-07-07 16:06 ` Andrea Cervesato via ltp
2025-07-04 11:30 ` [LTP] [PATCH v2 5/8] Add ioctl_pidfd03 test Andrea Cervesato
2025-07-07 12:44 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 6/8] Add ioctl_pidfd04 test Andrea Cervesato
2025-07-07 12:56 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 7/8] Add ioctl_pidfd05 test Andrea Cervesato
2025-07-07 13:16 ` Cyril Hrubis
2025-07-04 11:30 ` [LTP] [PATCH v2 8/8] Add ioctl_pidfd06 test Andrea Cervesato
2025-07-07 13:27 ` Cyril Hrubis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.