patches/glibc/ports-2.10.1/340-dl_execstack-PaX-support.patch
author Arnaud Lacombe <lacombar@gmail.com>
Tue Aug 03 06:17:51 2010 +0200 (2010-08-03)
changeset 2064 f5ebe8c429dc
permissions -rw-r--r--
libc/uClibc: add uClibc 0.9.30.3

This version has been released a couple of month ago, but it never reached
crosstool-ng tree. This may be linked to the fact that the current 0.9.30.2,
once patched, has nothing much different from 0.9.30.3, released.

I'm not including any patch with this upgrade, on purpose.

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