summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-12-27 09:14:45 +0000
committerJakub Jelinek <jakub@redhat.com>2007-12-27 09:14:45 +0000
commitf163450fc0969ebd6f63c5d9bd059f6f0d107d75 (patch)
tree1d7cb198dead8b16362e6ed6b8f71f52fb50a0d0 /elf
parentc5899b63ebb80de72b909a475e1dd41b99a4080c (diff)
downloadglibc-f163450fc0969ebd6f63c5d9bd059f6f0d107d75.tar.gz
glibc-f163450fc0969ebd6f63c5d9bd059f6f0d107d75.tar.xz
glibc-f163450fc0969ebd6f63c5d9bd059f6f0d107d75.zip
Updated to fedora-glibc-20071227T0908 cvs/fedora-glibc-2_7_90-2
Diffstat (limited to 'elf')
-rw-r--r--elf/tst-execstack.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/elf/tst-execstack.c b/elf/tst-execstack.c
index 4b06615451..a835e4c0d6 100644
--- a/elf/tst-execstack.c
+++ b/elf/tst-execstack.c
@@ -2,6 +2,7 @@
    on load of a DSO that requires executable stacks.  */
 
 #include <dlfcn.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -45,9 +46,43 @@ waiter_thread (void *arg)
 }
 #endif
 
+
+static bool allow_execstack = true;
+
+
 static int
 do_test (void)
 {
+  /* Check whether SELinux is enabled and disallows executable stacks.  */
+  FILE *fp = fopen ("/selinux/enforce", "r");
+  if (fp != NULL)
+    {
+      char *line = NULL;
+      size_t linelen = 0;
+
+      bool enabled = false;
+      ssize_t n = getline (&line, &linelen, fp);
+      if (n > 0 && line[0] != '0')
+	enabled = true;
+
+      fclose (fp);
+
+      if (enabled)
+	{
+	  fp = fopen ("/selinux/booleans/allow_execstack", "r");
+	  if (fp != NULL)
+	    {
+	      n = getline (&line, &linelen, fp);
+	      if (n > 0 && line[0] == '0')
+		allow_execstack = false;
+	    }
+
+	  fclose (fp);
+	}
+    }
+
+  printf ("executable stacks %sallowed\n", allow_execstack ? "" : "not ");
+
   static void *f;		/* Address of this is used in other threads. */
 
 #if USE_PTHREADS
@@ -77,7 +112,7 @@ do_test (void)
   if (h == NULL)
     {
       printf ("cannot load: %s\n", dlerror ());
-      return 1;
+      return allow_execstack;
     }
 
   f = dlsym (h, "tryme");
@@ -113,10 +148,10 @@ do_test (void)
      Let them run to test it.  */
   pthread_barrier_wait (&go_barrier);
 
-  pthread_exit (0);
+  pthread_exit (! allow_execstack);
 #endif
 
-  return 0;
+  return ! allow_execstack;
 }
 
 static void