[PATCHv2] tst-pidfd.c: Test is UNSUPPORTED without PTRACE_MODE_ATTACH_REALCREDS
Mark Wielaard
mark@klomp.org
Mon Jun 27 10:50:16 GMT 2022
pidfd_getfd will fail with errno EPERM if the calling process did not
have PTRACE_MODE_ATTACH_REALCREDS permissions. Use FAIL_UNSUPPORTED
in that case.
---
v2: separate ENOSYS and EPERM checks and FAIL_UNSUPPORTED messages
https://code.wildebeest.org/git/user/mjw/glibc/commit/?h=container-perms&id=5b3288ce83c920b84efb589ad1e434035d873eb9
sysdeps/unix/sysv/linux/tst-pidfd.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/tst-pidfd.c b/sysdeps/unix/sysv/linux/tst-pidfd.c
index d93b6faa6f..8a6db8fe01 100644
--- a/sysdeps/unix/sysv/linux/tst-pidfd.c
+++ b/sysdeps/unix/sysv/linux/tst-pidfd.c
@@ -92,11 +92,16 @@ do_test (void)
{
/* The pidfd_getfd syscall was the last in the set of pidfd related
syscalls added to the kernel. Use pidfd_getfd to decide if this
- kernel has pidfd support that we can test. */
+ kernel has pidfd support that we can test. And that we have
+ PTRACE_MODE_ATTACH_REALCREDS permissions to use pidfd_getfd. */
int r = pidfd_getfd (0, 0, 1);
TEST_VERIFY_EXIT (r == -1);
if (errno == ENOSYS)
FAIL_UNSUPPORTED ("kernel does not support pidfd_getfd, skipping test");
+ if (errno == EPERM)
+ FAIL_UNSUPPORTED ("don't have permission to use pidfd_getfd "
+ "(missing PTRACE_MODE_ATTACH_REALCREDS?), "
+ "skipping test");
}
ppid = getpid ();
--
2.18.4
More information about the Libc-alpha
mailing list