1 This patch allows us to skip tests that require PTRACE_ATTACH in situations
2 where PTRACE_ATTACH is only allowed when CAP_SYS_PTRACE is held (i.e., for
5 Reported at <https://bugzilla.redhat.com/show_bug.cgi?id=1210966>.
7 --- elfutils-0.161/tests/run-deleted.sh 2015-04-11 16:38:33.028556235 +0200
8 +++ elfutils-0.161/tests/run-deleted.sh 2015-04-11 16:46:15.012442185 +0200
11 . $srcdir/backtrace-subr.sh
13 +# Check whether the Yama policy allows us to use PTRACE_ATTACH.
14 +if [ -f /proc/sys/kernel/yama/ptrace_scope ]
16 + if [ `cat /proc/sys/kernel/yama/ptrace_scope` -ne 0 ]
22 tempfiles deleted deleted-lib.so
23 cp -p ${abs_builddir}/deleted ${abs_builddir}/deleted-lib.so .
25 --- elfutils-0.161/tests/vdsosyms.c 2015-04-11 16:40:20.633461110 +0200
26 +++ elfutils-0.161/tests/vdsosyms.c 2015-04-11 16:45:06.611866677 +0200
30 #include <sys/types.h>
31 +#include <sys/stat.h>
34 #include ELFUTILS_HEADER(dwfl)
36 @@ -68,6 +70,7 @@ module_callback (Dwfl_Module *mod, void
38 main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
40 + static const char ptrace_scope_file[] = "/proc/sys/kernel/yama/ptrace_scope";
41 static char *debuginfo_path;
42 static const Dwfl_Callbacks proc_callbacks =
44 @@ -76,6 +79,20 @@ main (int argc __attribute__ ((unused)),
46 .find_elf = dwfl_linux_proc_find_elf,
49 + /* Check whether the Yama policy allows us to use PTRACE_ATTACH. */
50 + int ptrace_scope = open (ptrace_scope_file, O_RDONLY);
51 + if (ptrace_scope >= 0)
54 + int count = read (ptrace_scope, buf, sizeof buf);
57 + /* We're not allowed, so skip this test. */
59 + close (ptrace_scope);
62 Dwfl *dwfl = dwfl_begin (&proc_callbacks);
64 error (2, 0, "dwfl_begin: %s", dwfl_errmsg (-1));