aboutsummaryrefslogtreecommitdiff
path: root/support/xptrace.h
diff options
context:
space:
mode:
authorStefan Liebler <stli@linux.ibm.com>2019-09-18 12:40:00 +0200
committerStefan Liebler <stli@linux.ibm.com>2019-09-18 12:42:39 +0200
commit2f9046fb059e94fe254c9a4ff5bcd52182069e44 (patch)
tree87aea58e9ee081f70571cc6daaa8f81ea6df9b37 /support/xptrace.h
parent87accae3978c77c1a50d19ea8e3da3f0248d2612 (diff)
downloadglibc-2f9046fb059e94fe254c9a4ff5bcd52182069e44.tar
glibc-2f9046fb059e94fe254c9a4ff5bcd52182069e44.tar.gz
glibc-2f9046fb059e94fe254c9a4ff5bcd52182069e44.tar.bz2
glibc-2f9046fb059e94fe254c9a4ff5bcd52182069e44.zip
Add UNSUPPORTED check in elf/tst-pldd.
The testcase forks a child process and runs pldd with PID of this child. On systems where /proc/sys/kernel/yama/ptrace_scope differs from zero, pldd will fail with /usr/bin/pldd: cannot attach to process 3: Operation not permitted This patch checks if ptrace_scope exists, is zero "classic ptrace permissions" or one "restricted ptrace". If ptrace_scope exists and has a higher restriction, then the test is marked as UNSUPPORTED. The case "restricted ptrace" is handled by rearranging the processes involved during the test. Now we have the following process tree: -parent: do_test (performs output checks) --subprocess 1: pldd_process (becomes pldd via execve) ---subprocess 2: target_process (ptraced via pldd) ChangeLog: * elf/tst-pldd.c (do_test): Add UNSUPPORTED check. Rearrange subprocesses. (pldd_process): New function. * support/Makefile (libsupport-routines): Add support_ptrace. * support/xptrace.h: New file. * support/support_ptrace.c: Likewise.
Diffstat (limited to 'support/xptrace.h')
-rw-r--r--support/xptrace.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/support/xptrace.h b/support/xptrace.h
new file mode 100644
index 0000000000..7af8926805
--- /dev/null
+++ b/support/xptrace.h
@@ -0,0 +1,32 @@
+/* Support functions handling ptrace_scope.
+ Copyright (C) 2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_PTRACE_H
+#define SUPPORT_PTRACE_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* Return the current YAMA mode set on the machine (0 to 3) or -1
+ if YAMA is not supported. */
+int support_ptrace_scope (void);
+
+__END_DECLS
+
+#endif