public inbox for
help / color / mirror / Atom feed
From: Mark Wielaard <>
Subject: [glibc] tst-pidfd.c: UNSUPPORTED if we get EPERM on valid pidfd_getfd call
Date: Fri, 29 Jul 2022 17:26:39 +0000 (GMT)	[thread overview]
Message-ID: <> (raw);h=325ba824b0611e14e96b38dbc486acf255f9e568

commit 325ba824b0611e14e96b38dbc486acf255f9e568
Author: Mark Wielaard <>
Date:   Sun Jun 26 22:17:17 2022 +0200

    tst-pidfd.c: UNSUPPORTED if we get EPERM on valid pidfd_getfd call
    pidfd_getfd can fail for a valid pidfd with errno EPERM for various
    reasons in a restricted environment. Use FAIL_UNSUPPORTED in that case.
    Reviewed-by: Adhemerval Zanella  <>
    Reviewed-by: Carlos O'Donell <>

 sysdeps/unix/sysv/linux/tst-pidfd.c | 7 +++++++
 1 file changed, 7 insertions(+)

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);

                 reply	other threads:[~2022-07-29 17:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).