public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Magnus Granberg <zorry@gentoo.org>
To: libffi-discuss@sourceware.org
Subject: [Patch] Updated version of emutramp_enabled_check() for PaX kernels
Date: Mon, 29 Apr 2013 21:45:00 -0000	[thread overview]
Message-ID: <1853145.Z13BOjesii@laptop1.gw.ume.nu> (raw)

[-- 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 \

             reply	other threads:[~2013-04-29 21:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-29 21:45 Magnus Granberg [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1853145.Z13BOjesii@laptop1.gw.ume.nu \
    --to=zorry@gentoo.org \
    --cc=libffi-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).