1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/patches/glibc/ports-2.10.1/340-dl_execstack-PaX-support.patch Wed Feb 01 00:19:04 2012 +0100
1.3 @@ -0,0 +1,66 @@
1.4 + With latest versions of glibc, a lot of apps failed on a PaX enabled
1.5 + system with:
1.6 + cannot enable executable stack as shared object requires: Permission denied
1.7 +
1.8 + This is due to PaX 'exec-protecting' the stack, and ld.so then trying
1.9 + to make the stack executable due to some libraries not containing the
1.10 + PT_GNU_STACK section. Bug #32960. <azarah@gentoo.org> (12 Nov 2003).
1.11 +
1.12 + Patch also NPTL. Bug #116086. <kevquinn@gentoo.org> (20 Dec 2005).
1.13 +
1.14 +diff -durN glibc-2.10.1.orig/nptl/allocatestack.c glibc-2.10.1/nptl/allocatestack.c
1.15 +--- glibc-2.10.1.orig/nptl/allocatestack.c 2009-01-29 21:34:16.000000000 +0100
1.16 ++++ glibc-2.10.1/nptl/allocatestack.c 2009-11-13 00:50:33.000000000 +0100
1.17 +@@ -326,7 +326,8 @@
1.18 + # error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
1.19 + #endif
1.20 + if (mprotect (stack, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
1.21 +- return errno;
1.22 ++ if (errno != EACCES) /* PAX is enabled */
1.23 ++ return errno;
1.24 +
1.25 + return 0;
1.26 + }
1.27 +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
1.28 +--- glibc-2.10.1.orig/sysdeps/unix/sysv/linux/dl-execstack.c 2006-01-08 09:21:15.000000000 +0100
1.29 ++++ glibc-2.10.1/sysdeps/unix/sysv/linux/dl-execstack.c 2009-11-13 00:50:33.000000000 +0100
1.30 +@@ -63,7 +63,10 @@
1.31 + else
1.32 + # endif
1.33 + {
1.34 +- result = errno;
1.35 ++ if (errno == EACCES) /* PAX is enabled */
1.36 ++ result = 0;
1.37 ++ else
1.38 ++ result = errno;
1.39 + goto out;
1.40 + }
1.41 + }
1.42 +@@ -89,7 +92,12 @@
1.43 + page -= size;
1.44 + else
1.45 + {
1.46 +- if (errno != ENOMEM) /* Unexpected failure mode. */
1.47 ++ if (errno == EACCES) /* PAX is enabled */
1.48 ++ {
1.49 ++ result = 0;
1.50 ++ goto out;
1.51 ++ }
1.52 ++ else if (errno != ENOMEM) /* Unexpected failure mode. */
1.53 + {
1.54 + result = errno;
1.55 + goto out;
1.56 +@@ -115,7 +123,12 @@
1.57 + page += size;
1.58 + else
1.59 + {
1.60 +- if (errno != ENOMEM) /* Unexpected failure mode. */
1.61 ++ if (errno == EACCES) /* PAX is enabled */
1.62 ++ {
1.63 ++ result = 0;
1.64 ++ goto out;
1.65 ++ }
1.66 ++ else if (errno != ENOMEM) /* Unexpected failure mode. */
1.67 + {
1.68 + result = errno;
1.69 + goto out;