From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2321 invoked by alias); 29 Apr 2013 21:45:41 -0000 Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org Received: (qmail 2312 invoked by uid 89); 29 Apr 2013 21:45:40 -0000 X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.1 Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 29 Apr 2013 21:45:39 +0000 Received: from laptop1.gw.ume.nu (ip1-67.bon.riksnet.se [77.110.8.67]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: zorry) by smtp.gentoo.org (Postfix) with ESMTPSA id D21C033DFEF for ; Mon, 29 Apr 2013 21:45:37 +0000 (UTC) From: Magnus Granberg 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 Message-ID: <1853145.Z13BOjesii@laptop1.gw.ume.nu> User-Agent: KMail/4.10 (Linux/3.8.0-hardened; KDE/4.10.0; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart3693290.qLDgI0sHzv" Content-Transfer-Encoding: 7Bit X-Virus-Found: No X-SW-Source: 2013/txt/msg00130.txt.bz2 This is a multi-part message in MIME format. --nextPart3693290.qLDgI0sHzv Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Content-length: 286 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 * src/cloures.c (emutramp_enabled_check): Check /proc/self/status for PaX status. --nextPart3693290.qLDgI0sHzv Content-Disposition: attachment; filename="libffi-3.0.13-emutramp_pax_log.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="libffi-3.0.13-emutramp_pax_log.patch" Content-length: 791 --- 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 \ --nextPart3693290.qLDgI0sHzv--