public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* [Patch] Updated version of emutramp_enabled_check() for PaX kernels
@ 2013-04-29 21:45 Magnus Granberg
  2013-05-13 17:53 ` Magnus Granberg
  2013-05-22 11:50 ` Anthony Green
  0 siblings, 2 replies; 6+ messages in thread
From: Magnus Granberg @ 2013-04-29 21:45 UTC (permalink / raw)
  To: libffi-discuss

[-- Attachment #1: Type: text/plain, Size: 286 bytes --]

Hi
This patch check the PaX status in /proc/self/status
and it will return true or fales depend on the status of
emulate trampolines in Pax.

/Magnus

2013-04-29  Magnus Granberg <zorry@gentoo.org>

	* src/cloures.c (emutramp_enabled_check): Check /proc/self/status for PaX 	
	status.


[-- Attachment #2: libffi-3.0.13-emutramp_pax_log.patch --]
[-- Type: text/x-patch, Size: 791 bytes --]

--- a/src/closures.c	2013-03-17 23:27:11.000000000 +0100
+++ b/src/closures.c	2013-04-29 23:26:02.279022022 +0200
@@ -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 \

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [Patch] Updated version of emutramp_enabled_check() for PaX kernels
@ 2014-03-27 18:15 Magnus Granberg
  2014-03-28 15:43 ` Anthony Green
  0 siblings, 1 reply; 6+ messages in thread
From: Magnus Granberg @ 2014-03-27 18:15 UTC (permalink / raw)
  To: libffi-discuss

>Hi 
>Magnus, Reading /proc/self/status is a little more heavy weight than checking 
an environment variable. Do we really have to do this every time we call 
dlmmap(), or can we do it once and cache the result? 
>Thanks, 
>AG

The selinux check read /proc/mount for selinux stuff and even check if it have 
the selinux dir. I think the selinux check have the same heavy weight as the 
pax check and then the selinux need to make a temp file in some dir the app
have acces to make file in. For me is fine to read /proc/... on every time.

/Magnus

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-28 15:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-29 21:45 [Patch] Updated version of emutramp_enabled_check() for PaX kernels Magnus Granberg
2013-05-13 17:53 ` Magnus Granberg
2013-05-22 11:50 ` Anthony Green
2013-05-22 15:16   ` Magnus Granberg
2014-03-27 18:15 Magnus Granberg
2014-03-28 15:43 ` Anthony Green

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).