about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/tst-pidfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/tst-pidfd.c')
-rw-r--r--sysdeps/unix/sysv/linux/tst-pidfd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/tst-pidfd.c b/sysdeps/unix/sysv/linux/tst-pidfd.c
index d93b6faa6f..037af22290 100644
--- a/sysdeps/unix/sysv/linux/tst-pidfd.c
+++ b/sysdeps/unix/sysv/linux/tst-pidfd.c
@@ -142,6 +142,13 @@ do_test (void)
     xrecvfrom (sockets[0], &remote_fd, sizeof (remote_fd), 0, NULL, 0);
 
     int fd = pidfd_getfd (pidfd, remote_fd, 0);
+    /* pidfd_getfd may fail with EPERM if the process does not have
+       PTRACE_MODE_ATTACH_REALCREDS permissions. This means the call
+       may be denied if the process doesn't have CAP_SYS_PTRACE or
+       if a LSM security_ptrace_access_check denies access.  */
+    if (fd == -1 && errno == EPERM)
+      FAIL_UNSUPPORTED ("don't have permission to use pidfd_getfd on pidfd, "
+			"skipping test");
     TEST_VERIFY (fd > 0);
 
     char *path = xasprintf ("/proc/%d/fd/%d", pid, remote_fd);