summaryrefslogtreecommitdiff
path: root/packages/glibc/2.16.0/0020-dl_execstack-PaX-support.patch
blob: cd60905f8f91aed19aadbd3f2fce1c9dc476f444 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
	With latest versions of glibc, a lot of apps failed on a PaX enabled
	system with:
		 cannot enable executable stack as shared object requires: Permission denied
	
	This is due to PaX 'exec-protecting' the stack, and ld.so then trying
	to make the stack executable due to some libraries not containing the
	PT_GNU_STACK section.  Bug #32960.  <azarah@gentoo.org> (12 Nov 2003).

	Patch also NPTL. Bug #116086. <kevquinn@gentoo.org> (20 Dec 2005).

---
 nptl/allocatestack.c                   |    3 ++-
 sysdeps/unix/sysv/linux/dl-execstack.c |   19 ++++++++++++++++---
 2 files changed, 18 insertions(+), 4 deletions(-)

--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -334,7 +334,8 @@
 # error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
 #endif
   if (mprotect (stack, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
-    return errno;
+    if (errno != EACCES) /* PAX is enabled */
+    	return errno;
 
   return 0;
 }
--- a/sysdeps/unix/sysv/linux/dl-execstack.c
+++ b/sysdeps/unix/sysv/linux/dl-execstack.c
@@ -62,7 +62,10 @@
       else
 # endif
 	{
-	  result = errno;
+	  if (errno == EACCES)  /* PAX is enabled */
+	    result = 0;
+	  else
+	    result = errno;
 	  goto out;
 	}
     }
@@ -88,7 +91,12 @@
 	page -= size;
       else
 	{
-	  if (errno != ENOMEM)	/* Unexpected failure mode.  */
+	  if (errno == EACCES)		/* PAX is enabled */
+	    {
+	      result = 0;
+	      goto out;
+	    }
+	  else if (errno != ENOMEM)	/* Unexpected failure mode.  */
 	    {
 	      result = errno;
 	      goto out;
@@ -114,7 +122,12 @@
 	page += size;
       else
 	{
-	  if (errno != ENOMEM)	/* Unexpected failure mode.  */
+	  if (errno == EACCES)		/* PAX is enabled */
+	    {
+	      result = 0;
+	      goto out;
+	    }
+	  else if (errno != ENOMEM)	/* Unexpected failure mode.  */
 	    {
 	      result = errno;
 	      goto out;