This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Make guality.h handle Yama restricted ptrace mode

guality.exp is silently skipped on Linux systems with
kernel.yama.ptrace_scope=1 because gdb fails to attach to the
sanity check test.  This patch uses PR_SET_PTRACER (where available)
to avoid this.

prctl was apparently added in Linux 2.1.57, so I don't think we
need any tests other than __linux for the #include.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?


2019-07-07  Richard Sandiford  <>

	* gcc.dg/guality/guality.h: Include <sys/prctl.h> on Linux targets.
	(main): Use PR_SET_PTRACER where available.

Index: gcc/testsuite/gcc.dg/guality/guality.h
--- gcc/testsuite/gcc.dg/guality/guality.h	2019-03-08 18:15:03.052868249 +0000
+++ gcc/testsuite/gcc.dg/guality/guality.h	2019-07-07 10:18:20.240698144 +0100
@@ -23,6 +23,9 @@ the Free Software Foundation; either ver
 #include <string.h>
 #include <stdint.h>
 #include <unistd.h>
+#ifdef __linux
+#include <sys/prctl.h>
 /* This is a first cut at checking that debug information matches
    run-time.  The idea is to annotate programs with GUALCHK* macros
@@ -214,6 +217,10 @@ main (int argc, char *argv[])
   int i;
   char *argv0 = argv[0];
+#if defined(PR_SET_PTRACER_ANY)
+  prctl (PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
   guality_gdb_command = getenv ("GUALITY_GDB");
   if (!guality_gdb_command)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]