| /linux/tools/testing/selftests/pidfd/ |
| H A D | pidfd_file_handle_test.c | 28 int pidfd; in FIXTURE() local 47 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 48 ASSERT_GE(self->pidfd, 0); in FIXTURE_SETUP() 119 EXPECT_EQ(close(self->pidfd), 0); in FIXTURE_TEARDOWN() 148 int pidfd = -EBADF; in TEST_F() local 160 pidfd = open_by_handle_at(self->pidfd, fh, 0); in TEST_F() 161 ASSERT_GE(pidfd, 0); in TEST_F() 163 ASSERT_EQ(fstat(pidfd, &st2), 0); in TEST_F() 166 ASSERT_EQ(close(pidfd), 0); in TEST_F() 168 pidfd = open_by_handle_at(self->pidfd, fh, O_CLOEXEC); in TEST_F() [all …]
|
| H A D | pidfd_wait.c | 31 int pidfd = -1; in TEST() local 35 .pidfd = ptr_to_u64(&pidfd), in TEST() 44 pidfd = open("/proc/self", O_DIRECTORY | O_RDONLY | O_CLOEXEC); in TEST() 45 ASSERT_GE(pidfd, 0); in TEST() 47 pid = sys_waitid(P_PIDFD, pidfd, &info, WEXITED); in TEST() 49 EXPECT_EQ(close(pidfd), 0); in TEST() 50 pidfd = -1; in TEST() 52 pidfd = open("/dev/null", O_RDONLY | O_CLOEXEC); in TEST() 53 ASSERT_GE(pidfd, 0); in TEST() 55 pid = sys_waitid(P_PIDFD, pidfd, &info, WEXITED); in TEST() [all …]
|
| H A D | pidfd_test.c | 33 static pid_t pidfd_clone(int flags, int *pidfd, int (*fn)(void *)) in pidfd_clone() argument 39 return __clone2(fn, stack, stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 41 return clone(fn, stack + stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 53 static int send_signal(int pidfd) in send_signal() argument 57 if (sys_pidfd_send_signal(pidfd, SIGUSR1, NULL, 0) < 0) { in send_signal() 74 int pidfd = (int)(intptr_t)arg; in send_signal_worker() local 78 ret = send_signal(pidfd); in send_signal_worker() 88 int pidfd; in test_pidfd_send_signal_simple_success() local 104 pidfd = open("/proc/self", O_DIRECTORY | O_CLOEXEC); in test_pidfd_send_signal_simple_success() 105 if (pidfd < 0) in test_pidfd_send_signal_simple_success() [all …]
|
| H A D | pidfd_bind_mount.c | 23 int pidfd; in FIXTURE() local 39 self->pidfd = sys_pidfd_open(getpid(), 0); in FIXTURE_SETUP() 40 ASSERT_GE(self->pidfd, 0); in FIXTURE_SETUP() 41 ASSERT_GE(fstat(self->pidfd, &self->st1), 0); in FIXTURE_SETUP() 42 ASSERT_EQ(ioctl(self->pidfd, FS_IOC_GETVERSION, &self->gen1), 0); in FIXTURE_SETUP() 61 fd_tree = sys_open_tree(self->pidfd, "", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC | AT_EMPTY_PATH); in TEST_F() 73 int pidfd; in TEST_F() local 76 sprintf(proc_path, "/proc/self/fd/%d", self->pidfd); in TEST_F() 77 pidfd = open(proc_path, O_RDONLY | O_NOCTTY | O_CLOEXEC); in TEST_F() 78 ASSERT_GE(pidfd, 0); in TEST_F() [all …]
|
| H A D | pidfd_open_test.c | 87 static pid_t get_pid_from_fdinfo_file(int pidfd, const char *key, size_t keylen) in get_pid_from_fdinfo_file() argument 96 snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", pidfd); in get_pid_from_fdinfo_file() 127 int pidfd = -1, ret = 1; in main() local 132 pidfd = sys_pidfd_open(-1, 0); in main() 133 if (pidfd >= 0) { in main() 141 pidfd = sys_pidfd_open(getpid(), 1); in main() 142 if (pidfd >= 0) { in main() 150 pidfd = sys_pidfd_open(getpid(), 0); in main() 151 if (pidfd < 0) { in main() 157 pid = get_pid_from_fdinfo_file(pidfd, "Pid:", sizeof("Pid:") - 1); in main() [all …]
|
| H A D | pidfd_poll_test.c | 48 int pidfd; in main() local 68 pidfd = sys_pidfd_open(child_pid, 0); in main() 69 if (pidfd < 0) in main() 80 if (sys_pidfd_send_signal(pidfd, SIGKILL, NULL, 0)) in main() 85 fds.fd = pidfd; in main() 106 close(pidfd); in main()
|
| H A D | pidfd_getfd_test.c | 127 int pidfd; in FIXTURE() local 157 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 158 ASSERT_GE(self->pidfd, 0); in FIXTURE_SETUP() 172 EXPECT_EQ(0, close(self->pidfd)); in FIXTURE_TEARDOWN() 198 fd = sys_pidfd_getfd(self->pidfd, self->remote_fd, 0); in TEST_F() 210 fd = sys_pidfd_getfd(self->pidfd, self->remote_fd, 0); in TEST_F() 229 fd = sys_pidfd_getfd(self->pidfd, UNKNOWN_FD, 0); in TEST_F() 250 fds.fd = self->pidfd; in TEST_F() 263 EXPECT_EQ(sys_pidfd_getfd(self->pidfd, self->remote_fd, 0), -1); in TEST_F()
|
| H A D | pidfd.h | 254 static inline int sys_pidfd_send_signal(int pidfd, int sig, siginfo_t *info, in sys_pidfd_send_signal() argument 257 return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags); in sys_pidfd_send_signal() 260 static inline int sys_pidfd_getfd(int pidfd, int fd, int flags) in sys_pidfd_getfd() argument 262 return syscall(__NR_pidfd_getfd, pidfd, fd, flags); in sys_pidfd_getfd() 270 static inline pid_t create_child(int *pidfd, unsigned flags) in create_child() argument 275 .pidfd = ptr_to_u64(pidfd), in create_child()
|
| H A D | pidfd_fdinfo_test.c | 165 static int verify_fdinfo(int pidfd, struct error *err, const char *prefix, in verify_fdinfo() argument 182 snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", pidfd); in verify_fdinfo() 186 pidfd); in verify_fdinfo() 212 prefix, pidfd); in verify_fdinfo() 220 int pidfd; in child_fdinfo_nspid_test() local 244 pidfd = *(int *)args; in child_fdinfo_nspid_test() 245 r = verify_fdinfo(pidfd, &err, "NSpid:", 6, "\t0\n"); in child_fdinfo_nspid_test()
|
| H A D | pidfd_info_test.c | 704 int pidfd; in TEST() local 707 pid = create_child(&pidfd, 0); in TEST() 714 ASSERT_EQ(ioctl(pidfd, PIDFD_GET_INFO, &info), 0); in TEST() 729 sys_pidfd_send_signal(pidfd, SIGKILL, NULL, 0); in TEST() 730 sys_waitid(P_PIDFD, pidfd, NULL, WEXITED); in TEST() 731 close(pidfd); in TEST() 744 int pidfd; in TEST() local 747 pid = create_child(&pidfd, 0); in TEST() 753 ASSERT_EQ(ioctl(pidfd, PIDFD_GET_INFO, &info), 0); in TEST() 761 sys_pidfd_send_signal(pidfd, SIGKILL, NULL, 0); in TEST() [all …]
|
| H A D | pidfd_setns_test.c | 57 int pidfd; in FIXTURE() local 112 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 113 EXPECT_GT(self->pidfd, 0) { in FIXTURE_SETUP() 127 self->child_pidfd_derived_nsfds[i] = ioctl(self->pidfd, info->pidfd_ioctl, 0); in FIXTURE_SETUP() 150 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 151 EXPECT_GE(self->pidfd, 0) { in FIXTURE_SETUP() 399 ASSERT_NE(setns(self->pidfd, 0), 0); in TEST_F() 402 ASSERT_NE(setns(self->pidfd, -1), 0); in TEST_F() 405 ASSERT_NE(setns(self->pidfd, CLONE_VM), 0); in TEST_F() 408 ASSERT_NE(setns(self->pidfd, CLONE_NEWUSER | CLONE_VM), 0); in TEST_F()
|
| /linux/samples/pidfd/ |
| H A D | pidfd-metadata.c | 34 static pid_t pidfd_clone(int flags, int *pidfd) in pidfd_clone() argument 40 return __clone2(do_child, stack, stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 42 return clone(do_child, stack + stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 46 static inline int sys_pidfd_send_signal(int pidfd, int sig, siginfo_t *info, in sys_pidfd_send_signal() argument 49 return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags); in sys_pidfd_send_signal() 52 static int pidfd_metadata_fd(pid_t pid, int pidfd) in pidfd_metadata_fd() argument 68 ret = sys_pidfd_send_signal(pidfd, 0, NULL, 0); in pidfd_metadata_fd() 86 int pidfd = -1, ret = EXIT_FAILURE; in main() local 92 pid = pidfd_clone(CLONE_PIDFD, &pidfd); in main() 95 if (pidfd == -1) { in main() [all …]
|
| H A D | .gitignore | 2 /pidfd-metadata
|
| /linux/tools/testing/selftests/namespaces/ |
| H A D | regression_pidfd_setns_test.c | 35 int pidfd = -1; in TEST() local 46 child_pid = create_child(&pidfd, 0); in TEST() 66 ASSERT_GE(pidfd, 0); in TEST() 74 ret = setns(pidfd, CLONE_NEWUTS | CLONE_NEWIPC); in TEST() 76 close(pidfd); in TEST() 88 int pidfd = -1; in TEST() local 95 child_pid = create_child(&pidfd, CLONE_NEWUSER | CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWNET); in TEST() 105 ASSERT_GE(pidfd, 0); in TEST() 108 ret = setns(pidfd, CLONE_NEWUTS | CLONE_NEWIPC); in TEST() 109 close(pidfd); in TEST()
|
| /linux/tools/testing/selftests/mm/ |
| H A D | mrelease_test.c | 51 static void run_negative_tests(int pidfd) in run_negative_tests() argument 54 if (!syscall(__NR_process_mrelease, pidfd, (unsigned int)-1) || in run_negative_tests() 62 if (!syscall(__NR_process_mrelease, pidfd, 0) || errno != EINVAL) in run_negative_tests() 79 int pipefd[2], pidfd; in main() local 137 pidfd = syscall(__NR_pidfd_open, pid, 0); in main() 138 if (pidfd < 0) { in main() 145 run_negative_tests(pidfd); in main() 150 success = (syscall(__NR_process_mrelease, pidfd, 0) == 0); in main() 171 close(pidfd); in main()
|
| H A D | process_madv.c | 25 int pidfd; in FIXTURE() local 31 self->pidfd = PIDFD_SELF; in FIXTURE_SETUP() 48 static ssize_t sys_process_madvise(int pidfd, const struct iovec *iovec, in sys_process_madvise() argument 51 return syscall(__NR_process_madvise, pidfd, iovec, vlen, advice, flags); in sys_process_madvise() 65 int pidfd = self->pidfd; in TEST_F() local 94 ret = sys_process_madvise(pidfd, vec, madvise_pages, MADV_DONTNEED, 0); in TEST_F() 291 int pidfd = self->pidfd; in TEST_F() local 304 ret = sys_process_madvise(pidfd, &vec, 1025, MADV_DONTNEED, 0); in TEST_F() 321 int pidfd = self->pidfd; in TEST_F() local 336 ret = sys_process_madvise(pidfd, &vec, 1, MADV_DONTNEED, invalid_flag); in TEST_F()
|
| /linux/tools/testing/selftests/coredump/ |
| H A D | coredump_socket_test.c | 80 int pidfd, ret, status; in TEST_F() local 192 pidfd = sys_pidfd_open(pid, 0); in TEST_F() 193 ASSERT_GE(pidfd, 0); in TEST_F() 199 ASSERT_TRUE(get_pidfd_info(pidfd, &info)); in TEST_F() 211 int pidfd, ret, status; in TEST_F() local 321 pidfd = sys_pidfd_open(pid, 0); in TEST_F() 322 ASSERT_GE(pidfd, 0); in TEST_F() 324 ASSERT_TRUE(get_pidfd_info(pidfd, &info)); in TEST_F() 330 ASSERT_EQ(sys_pidfd_send_signal(pidfd, SIGKILL, NULL, 0), 0); in TEST_F() 331 ASSERT_EQ(close(pidfd), 0); in TEST_F() [all …]
|
| H A D | coredump_socket_protocol_test.c | 82 int pidfd, ret, status; in TEST_F() local 219 pidfd = sys_pidfd_open(pid, 0); in TEST_F() 220 ASSERT_GE(pidfd, 0); in TEST_F() 226 ASSERT_TRUE(get_pidfd_info(pidfd, &info)); in TEST_F() 239 int pidfd, ret, status; in TEST_F() local 363 pidfd = sys_pidfd_open(pid, 0); in TEST_F() 364 ASSERT_GE(pidfd, 0); in TEST_F() 370 ASSERT_TRUE(get_pidfd_info(pidfd, &info)); in TEST_F() 379 int pidfd, ret, status; in TEST_F() local 503 pidfd = sys_pidfd_open(pid, 0); in TEST_F() [all …]
|
| /linux/tools/testing/selftests/net/af_unix/ |
| H A D | scm_pidfd.c | 97 static pid_t get_pid_from_fdinfo_file(int pidfd, const char *key, size_t keylen) in get_pid_from_fdinfo_file() argument 106 snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", pidfd); in get_pid_from_fdinfo_file() 134 int *pidfd; member 150 if (cmsg->cmsg_len < sizeof(*res->pidfd)) { in parse_cmsg() 155 res->pidfd = (void *)CMSG_DATA(cmsg); in parse_cmsg() 169 if (!res->pidfd) { in parse_cmsg() 225 get_pid_from_fdinfo_file(*res.pidfd, "Pid:", sizeof("Pid:") - 1); in cmsg_check() 228 close(*res.pidfd); in cmsg_check() 232 close(*res.pidfd); in cmsg_check() 284 if (ioctl(*res.pidfd, PIDFD_GET_INFO, &info)) { in cmsg_check_dead() [all …]
|
| /linux/tools/testing/selftests/filesystems/overlayfs/ |
| H A D | set_layers_via_fds.c | 22 int pidfd; in FIXTURE() local 27 self->pidfd = -EBADF; in FIXTURE_SETUP() 34 if (self->pidfd >= 0) { in FIXTURE_TEARDOWN() 35 EXPECT_EQ(sys_pidfd_send_signal(self->pidfd, SIGKILL, NULL, 0), 0); in FIXTURE_TEARDOWN() 36 EXPECT_EQ(close(self->pidfd), 0); in FIXTURE_TEARDOWN() 236 int pidfd; in TEST_F() local 281 pid = create_child(&pidfd, 0); in TEST_F() 292 ASSERT_GE(close(pidfd), 0); in TEST_F() 294 pid = create_child(&pidfd, 0); in TEST_F() 305 ASSERT_GE(close(pidfd), 0); in TEST_F() [all …]
|
| /linux/samples/vfs/ |
| H A D | mountinfo.c | 214 int pidfd, mntns, ret, opt; in main() local 236 pidfd = syscall(__NR_pidfd_open, pid, 0); in main() 237 if (pidfd < 0) { in main() 243 mntns = ioctl(pidfd, PIDFD_GET_MNT_NAMESPACE, NULL); in main() 248 close(pidfd); in main()
|
| /linux/kernel/ |
| H A D | pid.c | 571 struct task_struct *pidfd_get_task(int pidfd, unsigned int *flags) in pidfd_get_task() argument 578 switch (pidfd) { in pidfd_get_task() 588 pid = pidfd_get_pid(pidfd, &f_flags); in pidfd_get_task() 622 int pidfd; in pidfd_create() local 625 pidfd = pidfd_prepare(pid, flags, &pidfd_file); in pidfd_create() 626 if (pidfd < 0) in pidfd_create() 627 return pidfd; in pidfd_create() 629 fd_install(pidfd, pidfd_file); in pidfd_create() 630 return pidfd; in pidfd_create() 905 SYSCALL_DEFINE3(pidfd_getfd, int, pidfd, int, fd, in SYSCALL_DEFINE3() argument [all …]
|
| /linux/tools/testing/selftests/pid_namespace/ |
| H A D | Makefile | 6 LOCAL_HDRS += $(selfdir)/pidfd/pidfd.h
|
| /linux/tools/testing/selftests/cgroup/ |
| H A D | Makefile | 21 LOCAL_HDRS += $(selfdir)/clone3/clone3_selftests.h $(selfdir)/pidfd/pidfd.h
|
| /linux/arch/sparc/kernel/ |
| H A D | process.c | 80 args.pidfd = compat_ptr(regs->u_regs[UREG_I2]); in sparc_clone() 86 args.pidfd = (int __user *)regs->u_regs[UREG_I2]; in sparc_clone()
|