* [LTP] [PATCH v3 1/8] Provide pidfd parameter in tst_clone_args
2025-07-07 17:05 [LTP] [PATCH v3 0/8] ioctl_pidfd testing suite Andrea Cervesato
@ 2025-07-07 17:05 ` Andrea Cervesato
2025-07-07 17:05 ` [LTP] [PATCH v3 2/8] Fallback PIDFD_GET_INFO related definitions Andrea Cervesato
` (6 subsequent siblings)
7 siblings, 0 replies; 17+ messages in thread
From: Andrea Cervesato @ 2025-07-07 17:05 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
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] 17+ messages in thread* [LTP] [PATCH v3 2/8] Fallback PIDFD_GET_INFO related definitions
2025-07-07 17:05 [LTP] [PATCH v3 0/8] ioctl_pidfd testing suite Andrea Cervesato
2025-07-07 17:05 ` [LTP] [PATCH v3 1/8] Provide pidfd parameter in tst_clone_args Andrea Cervesato
@ 2025-07-07 17:05 ` Andrea Cervesato
2025-07-07 17:05 ` [LTP] [PATCH v3 3/8] Add ioctl_pidfd01 test Andrea Cervesato
` (5 subsequent siblings)
7 siblings, 0 replies; 17+ messages in thread
From: Andrea Cervesato @ 2025-07-07 17:05 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
configure.ac | 2 ++
include/lapi/pidfd.h | 39 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 69c5be7362a0e9f2fdaf3e6bd01f92f6f4880108..c830b40cbbb248e6f58040d9353e0da87b288732 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 <linux/pidfd.h>])
+
# Tools knobs
# Bash
diff --git a/include/lapi/pidfd.h b/include/lapi/pidfd.h
index 9ca8e5aa23626646ebb2f18880abd5e52298bfc6..a3205032cf7d702fd8a014456933f8495f5984e2 100644
--- a/include/lapi/pidfd.h
+++ b/include/lapi/pidfd.h
@@ -8,14 +8,51 @@
#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
+# 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)
--
2.50.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 17+ messages in thread* [LTP] [PATCH v3 3/8] Add ioctl_pidfd01 test
2025-07-07 17:05 [LTP] [PATCH v3 0/8] ioctl_pidfd testing suite Andrea Cervesato
2025-07-07 17:05 ` [LTP] [PATCH v3 1/8] Provide pidfd parameter in tst_clone_args Andrea Cervesato
2025-07-07 17:05 ` [LTP] [PATCH v3 2/8] Fallback PIDFD_GET_INFO related definitions Andrea Cervesato
@ 2025-07-07 17:05 ` Andrea Cervesato
2025-07-09 9:16 ` Cyril Hrubis
2025-07-07 17:05 ` [LTP] [PATCH v3 4/8] Add ioctl_pidfd02 test Andrea Cervesato
` (4 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-07-07 17:05 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.
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 2 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
testcases/kernel/syscalls/ioctl/ioctl_pidfd.h | 38 ++++++++++++++++
testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c | 58 +++++++++++++++++++++++++
4 files changed, 99 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_pidfd.h b/testcases/kernel/syscalls/ioctl/ioctl_pidfd.h
new file mode 100644
index 0000000000000000000000000000000000000000..1a87d90982c353d8ca75140e405b42a24be4408d
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2025 Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+#ifndef IOCTL_PIDFD_H
+#define IOCTL_PIDFD_H
+
+#include "tst_test.h"
+#include "lapi/pidfd.h"
+
+static inline int ioctl_pidfd_supported(void)
+{
+ int ret = 0;
+ pid_t pid;
+ int pidfd;
+ struct pidfd_info info;
+
+ memset(&info, 0, sizeof(struct pidfd_info));
+ info.mask = PIDFD_INFO_EXIT;
+
+ pid = SAFE_FORK();
+ if (!pid)
+ exit(100);
+
+ pidfd = SAFE_PIDFD_OPEN(pid, 0);
+ SAFE_WAITPID(pid, NULL, 0);
+
+ SAFE_IOCTL(pidfd, PIDFD_GET_INFO, &info);
+ SAFE_CLOSE(pidfd);
+
+ if (info.mask & PIDFD_INFO_EXIT)
+ ret = 1;
+
+ return ret;
+}
+
+#endif
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c
new file mode 100644
index 0000000000000000000000000000000000000000..d9231e79b15c0866bd4c965634f6b01c157da1ce
--- /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 "ioctl_pidfd.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)
+{
+ if (!ioctl_pidfd_supported())
+ tst_brk(TCONF, "PIDFD_INFO_EXIT is not supported by ioctl()");
+
+ info->mask = PIDFD_INFO_EXIT;
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .forks_child = 1,
+ .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] 17+ messages in thread* Re: [LTP] [PATCH v3 3/8] Add ioctl_pidfd01 test
2025-07-07 17:05 ` [LTP] [PATCH v3 3/8] Add ioctl_pidfd01 test Andrea Cervesato
@ 2025-07-09 9:16 ` Cyril Hrubis
0 siblings, 0 replies; 17+ messages in thread
From: Cyril Hrubis @ 2025-07-09 9:16 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> Verify that ioctl() raises the right errors when an application provides
> the wrong file descriptor.
>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> runtest/syscalls | 2 +
> testcases/kernel/syscalls/ioctl/.gitignore | 1 +
> testcases/kernel/syscalls/ioctl/ioctl_pidfd.h | 38 ++++++++++++++++
> testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c | 58 +++++++++++++++++++++++++
> 4 files changed, 99 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_pidfd.h b/testcases/kernel/syscalls/ioctl/ioctl_pidfd.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..1a87d90982c353d8ca75140e405b42a24be4408d
> --- /dev/null
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd.h
> @@ -0,0 +1,38 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (c) 2025 Andrea Cervesato <andrea.cervesato@suse.com>
> + */
> +
> +#ifndef IOCTL_PIDFD_H
> +#define IOCTL_PIDFD_H
> +
> +#include "tst_test.h"
> +#include "lapi/pidfd.h"
> +
> +static inline int ioctl_pidfd_supported(void)
This should be named ioctl_pidfd_info_exit_supported() since we are
checking specially for the IOCTL_INFO_EXIT flag.
> +{
> + int ret = 0;
> + pid_t pid;
> + int pidfd;
> + struct pidfd_info info;
We have to assume the support is in if the kernel is new enough,
otherwise we will not detect when the code in kernel breaks when it's
suposed to work:
if (tst_kvercmp(6, 15, 0) >= 0)
return 1;
> + memset(&info, 0, sizeof(struct pidfd_info));
> + info.mask = PIDFD_INFO_EXIT;
> +
> + pid = SAFE_FORK();
> + if (!pid)
> + exit(100);
> +
> + pidfd = SAFE_PIDFD_OPEN(pid, 0);
> + SAFE_WAITPID(pid, NULL, 0);
> +
> + SAFE_IOCTL(pidfd, PIDFD_GET_INFO, &info);
> + SAFE_CLOSE(pidfd);
> +
> + if (info.mask & PIDFD_INFO_EXIT)
> + ret = 1;
> +
> + return ret;
> +}
> +
> +#endif
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..d9231e79b15c0866bd4c965634f6b01c157da1ce
> --- /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 "ioctl_pidfd.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)
> +{
> + if (!ioctl_pidfd_supported())
> + tst_brk(TCONF, "PIDFD_INFO_EXIT is not supported by ioctl()");
> +
> + info->mask = PIDFD_INFO_EXIT;
> +}
> +
> +static struct tst_test test = {
> + .test_all = run,
> + .setup = setup,
> + .forks_child = 1,
> + .bufs = (struct tst_buffers []) {
> + {&info, .size = sizeof(*info)},
> + {}
> + }
> +};
>
> --
> 2.50.0
>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 17+ messages in thread
* [LTP] [PATCH v3 4/8] Add ioctl_pidfd02 test
2025-07-07 17:05 [LTP] [PATCH v3 0/8] ioctl_pidfd testing suite Andrea Cervesato
` (2 preceding siblings ...)
2025-07-07 17:05 ` [LTP] [PATCH v3 3/8] Add ioctl_pidfd01 test Andrea Cervesato
@ 2025-07-07 17:05 ` Andrea Cervesato
2025-07-09 9:46 ` Cyril Hrubis
2025-07-07 17:05 ` [LTP] [PATCH v3 5/8] Add ioctl_pidfd03 test Andrea Cervesato
` (3 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-07-07 17:05 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 | 84 +++++++++++++++++++++++++
3 files changed, 86 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..9279f59046e46f4291ef6eb5e89b1cfcf2d18b6c
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd02.c
@@ -0,0 +1,84 @@
+// 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 "ioctl_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(info1->exit_code, status);
+
+ TST_EXP_EQ_LI(WEXITSTATUS(info1->exit_code), 100);
+}
+
+static void setup(void)
+{
+ if (!ioctl_pidfd_supported())
+ tst_brk(TCONF, "PIDFD_INFO_EXIT is not supported by ioctl()");
+}
+
+static struct tst_test test = {
+ .test = run,
+ .setup = setup,
+ .tcnt = 2,
+ .forks_child = 1,
+ .needs_checkpoints = 1,
+ .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] 17+ messages in thread* [LTP] [PATCH v3 5/8] Add ioctl_pidfd03 test
2025-07-07 17:05 [LTP] [PATCH v3 0/8] ioctl_pidfd testing suite Andrea Cervesato
` (3 preceding siblings ...)
2025-07-07 17:05 ` [LTP] [PATCH v3 4/8] Add ioctl_pidfd02 test Andrea Cervesato
@ 2025-07-07 17:05 ` Andrea Cervesato
2025-07-09 10:22 ` Cyril Hrubis
2025-07-07 17:05 ` [LTP] [PATCH v3 6/8] Add ioctl_pidfd04 test Andrea Cervesato
` (2 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-07-07 17:05 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 | 62 +++++++++++++++++++++++++
3 files changed, 64 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..39acc301f0b4ac2105ad97fca91d16c20af92131
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd03.c
@@ -0,0 +1,62 @@
+// 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 "ioctl_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 void setup(void)
+{
+ if (!ioctl_pidfd_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)},
+ {&info, .size = sizeof(*info)},
+ {}
+ }
+};
--
2.50.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 17+ messages in thread* [LTP] [PATCH v3 6/8] Add ioctl_pidfd04 test
2025-07-07 17:05 [LTP] [PATCH v3 0/8] ioctl_pidfd testing suite Andrea Cervesato
` (4 preceding siblings ...)
2025-07-07 17:05 ` [LTP] [PATCH v3 5/8] Add ioctl_pidfd03 test Andrea Cervesato
@ 2025-07-07 17:05 ` Andrea Cervesato
2025-07-09 10:26 ` Cyril Hrubis
2025-07-07 17:05 ` [LTP] [PATCH v3 7/8] Add ioctl_pidfd05 test Andrea Cervesato
2025-07-07 17:05 ` [LTP] [PATCH v3 8/8] Add ioctl_pidfd06 test Andrea Cervesato
7 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-07-07 17:05 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 | 70 +++++++++++++++++++++++++
3 files changed, 72 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..c4e60e21fe4c9e510e07b2081617b128ffe5b6c7
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd04.c
@@ -0,0 +1,70 @@
+// 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 "ioctl_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 void setup(void)
+{
+ if (!ioctl_pidfd_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,
+ .needs_checkpoints = 1,
+ .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] 17+ messages in thread* [LTP] [PATCH v3 7/8] Add ioctl_pidfd05 test
2025-07-07 17:05 [LTP] [PATCH v3 0/8] ioctl_pidfd testing suite Andrea Cervesato
` (5 preceding siblings ...)
2025-07-07 17:05 ` [LTP] [PATCH v3 6/8] Add ioctl_pidfd04 test Andrea Cervesato
@ 2025-07-07 17:05 ` Andrea Cervesato
2025-07-09 12:01 ` Cyril Hrubis
2025-07-07 17:05 ` [LTP] [PATCH v3 8/8] Add ioctl_pidfd06 test Andrea Cervesato
7 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-07-07 17:05 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 | 57 +++++++++++++++++++++++++
3 files changed, 59 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..81a5e4f22746491d4cbea67d74a58586cc016d14
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.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() 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,
+ .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] 17+ messages in thread* [LTP] [PATCH v3 8/8] Add ioctl_pidfd06 test
2025-07-07 17:05 [LTP] [PATCH v3 0/8] ioctl_pidfd testing suite Andrea Cervesato
` (6 preceding siblings ...)
2025-07-07 17:05 ` [LTP] [PATCH v3 7/8] Add ioctl_pidfd05 test Andrea Cervesato
@ 2025-07-07 17:05 ` Andrea Cervesato
2025-07-23 13:08 ` Cyril Hrubis
7 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato @ 2025-07-07 17:05 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 | 64 +++++++++++++++++++++++++
3 files changed, 66 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..7bc0b2c55d5d81e146b10decc2517754c64a9a78
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c
@@ -0,0 +1,64 @@
+// 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 "ioctl_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 void setup(void)
+{
+ if (!ioctl_pidfd_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)},
+ {&info, .size = sizeof(*info)},
+ {}
+ }
+};
--
2.50.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [LTP] [PATCH v3 8/8] Add ioctl_pidfd06 test
2025-07-07 17:05 ` [LTP] [PATCH v3 8/8] Add ioctl_pidfd06 test Andrea Cervesato
@ 2025-07-23 13:08 ` Cyril Hrubis
2025-07-23 13:59 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 17+ messages in thread
From: Cyril Hrubis @ 2025-07-23 13:08 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> +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);
> + }
SAFE_CLOSE(pid_child) here?
Otherwise we end up out of file descriptors with large enough -i
parameter.
Otherwise:
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] 17+ messages in thread* Re: [LTP] [PATCH v3 8/8] Add ioctl_pidfd06 test
2025-07-23 13:08 ` Cyril Hrubis
@ 2025-07-23 13:59 ` Andrea Cervesato via ltp
2025-07-23 14:03 ` Cyril Hrubis
0 siblings, 1 reply; 17+ messages in thread
From: Andrea Cervesato via ltp @ 2025-07-23 13:59 UTC (permalink / raw)
To: Cyril Hrubis, Andrea Cervesato; +Cc: ltp
On 7/23/25 3:08 PM, Cyril Hrubis wrote:
> SAFE_CLOSE(pid_child) here?
>
> Otherwise we end up out of file descriptors with large enough -i
> parameter.
>
> Otherwise:
>
> Reviewed-by: Cyril Hrubis<chrubis@suse.cz>
Do you mean pidfd? In that case it has to be applied also for the all
the other patches as following:
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c
b/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c
index df4bec384..66b96a29c 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c
@@ -44,6 +44,10 @@ static void run(void)
TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, info), ESRCH);
exit(0);
}
+
+ tst_reap_children();
+
+ SAFE_CLOSE(pidfd);
}
static void setup(void)
- Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [LTP] [PATCH v3 8/8] Add ioctl_pidfd06 test
2025-07-23 13:59 ` Andrea Cervesato via ltp
@ 2025-07-23 14:03 ` Cyril Hrubis
0 siblings, 0 replies; 17+ messages in thread
From: Cyril Hrubis @ 2025-07-23 14:03 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c
> b/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c
> index df4bec384..66b96a29c 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c
> @@ -44,6 +44,10 @@ static void run(void)
> TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, info), ESRCH);
> exit(0);
> }
> +
> + tst_reap_children();
Don't we wait() for the children in the test?
> + SAFE_CLOSE(pidfd);
Otherwise yes, we need to close the pidfd at the end of the iteration.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 17+ messages in thread