patches/glibc/ports-2.13/340-dl_execstack-PaX-support.patch
author Michael Hope <michael.hope@linaro.org>
Wed Oct 19 15:27:32 2011 +1300 (2011-10-19)
changeset 2739 f320e22f2cba
permissions -rw-r--r--
arch: add softfp support

Some architectures support a mixed hard/soft floating point, where
the compiler emits hardware floating point instructions, but passes
the operands in core (aka integer) registers.

For example, ARM supports this mode (to come in the next changeset).

Add support for softfp cross compilers to the GCC and GLIBC
configuration. Needed for Ubuntu and other distros that are softfp.

Signed-off-by: Michael Hope <michael.hope@linaro.org>
[yann.morin.1998@anciens.enib.fr: split the original patch]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
yann@2438
     1
	With latest versions of glibc, a lot of apps failed on a PaX enabled
yann@2438
     2
	system with:
yann@2438
     3
		 cannot enable executable stack as shared object requires: Permission denied
yann@2438
     4
	
yann@2438
     5
	This is due to PaX 'exec-protecting' the stack, and ld.so then trying
yann@2438
     6
	to make the stack executable due to some libraries not containing the
yann@2438
     7
	PT_GNU_STACK section.  Bug #32960.  <azarah@gentoo.org> (12 Nov 2003).
yann@2438
     8
yann@2438
     9
	Patch also NPTL. Bug #116086. <kevquinn@gentoo.org> (20 Dec 2005).
yann@2438
    10
yann@2438
    11
diff -durN glibc-2.13.orig/nptl/allocatestack.c glibc-2.13/nptl/allocatestack.c
yann@2438
    12
--- glibc-2.13.orig/nptl/allocatestack.c	2009-01-29 21:34:16.000000000 +0100
yann@2438
    13
+++ glibc-2.13/nptl/allocatestack.c	2009-11-13 00:50:33.000000000 +0100
yann@2438
    14
@@ -329,7 +329,8 @@
yann@2438
    15
 # error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
yann@2438
    16
 #endif
yann@2438
    17
   if (mprotect (stack, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
yann@2438
    18
-    return errno;
yann@2438
    19
+    if (errno != EACCES) /* PAX is enabled */
yann@2438
    20
+    	return errno;
yann@2438
    21
 
yann@2438
    22
   return 0;
yann@2438
    23
 }
yann@2438
    24
diff -durN glibc-2.13.orig/sysdeps/unix/sysv/linux/dl-execstack.c glibc-2.13/sysdeps/unix/sysv/linux/dl-execstack.c
yann@2438
    25
--- glibc-2.13.orig/sysdeps/unix/sysv/linux/dl-execstack.c	2006-01-08 09:21:15.000000000 +0100
yann@2438
    26
+++ glibc-2.13/sysdeps/unix/sysv/linux/dl-execstack.c	2009-11-13 00:50:33.000000000 +0100
yann@2438
    27
@@ -63,7 +63,10 @@
yann@2438
    28
       else
yann@2438
    29
 # endif
yann@2438
    30
 	{
yann@2438
    31
-	  result = errno;
yann@2438
    32
+	  if (errno == EACCES)  /* PAX is enabled */
yann@2438
    33
+	    result = 0;
yann@2438
    34
+	  else
yann@2438
    35
+	    result = errno;
yann@2438
    36
 	  goto out;
yann@2438
    37
 	}
yann@2438
    38
     }
yann@2438
    39
@@ -89,7 +92,12 @@
yann@2438
    40
 	page -= size;
yann@2438
    41
       else
yann@2438
    42
 	{
yann@2438
    43
-	  if (errno != ENOMEM)	/* Unexpected failure mode.  */
yann@2438
    44
+	  if (errno == EACCES)		/* PAX is enabled */
yann@2438
    45
+	    {
yann@2438
    46
+	      result = 0;
yann@2438
    47
+	      goto out;
yann@2438
    48
+	    }
yann@2438
    49
+	  else if (errno != ENOMEM)	/* Unexpected failure mode.  */
yann@2438
    50
 	    {
yann@2438
    51
 	      result = errno;
yann@2438
    52
 	      goto out;
yann@2438
    53
@@ -115,7 +123,12 @@
yann@2438
    54
 	page += size;
yann@2438
    55
       else
yann@2438
    56
 	{
yann@2438
    57
-	  if (errno != ENOMEM)	/* Unexpected failure mode.  */
yann@2438
    58
+	  if (errno == EACCES)		/* PAX is enabled */
yann@2438
    59
+	    {
yann@2438
    60
+	      result = 0;
yann@2438
    61
+	      goto out;
yann@2438
    62
+	    }
yann@2438
    63
+	  else if (errno != ENOMEM)	/* Unexpected failure mode.  */
yann@2438
    64
 	    {
yann@2438
    65
 	      result = errno;
yann@2438
    66
 	      goto out;