summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Granberg <zorry@gentoo.org>2014-05-11 09:55:28 -0400
committerAnthony Green <green@moxielogic.com>2014-05-11 09:55:28 -0400
commit52b3457093ed19b2a7c5fcf243c4014c90ce6225 (patch)
treeb717bab4ad2f74052d6babb19b45481cc42eccdc
parent7ba4c5d72aa440a4b21fb57e999e67c5957761da (diff)
downloadlibffi-52b3457093ed19b2a7c5fcf243c4014c90ce6225.tar.gz
Check /proc/self/status for PaX status.
-rw-r--r--src/closures.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/closures.c b/src/closures.c
index 98f00f9..c7863f3 100644
--- a/src/closures.c
+++ b/src/closures.c
@@ -181,10 +181,26 @@ static int emutramp_enabled = -1;
static int
emutramp_enabled_check (void)
{
- if (getenv ("FFI_DISABLE_EMUTRAMP") == NULL)
- return 1;
- else
+ char *buf = NULL;
+ size_t len = 0;
+ FILE *f;
+ int ret;
+ f = fopen ("/proc/self/status", "r");
+ if (f == NULL)
return 0;
+ ret = 0;
+
+ while (getline (&buf, &len, f) != -1)
+ if (!strncmp (buf, "PaX:", 4))
+ {
+ char emutramp;
+ if (sscanf (buf, "%*s %*c%c", &emutramp) == 1)
+ ret = (emutramp == 'E');
+ break;
+ }
+ free (buf);
+ fclose (f);
+ return ret;
}
#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \