summaryrefslogtreecommitdiff
blob: 9d839fc7b3e3b832444dc60c65d1ef9f4e5f3ecd (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
From 6d011f0865dc99d9306b5768ccd1eaa0355d994e Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyfox@gentoo.org>
Date: Sat, 5 Feb 2011 11:53:33 +0200
Subject: [PATCH] libffi: backport incorrect detection of selinux

This patch unbreaks ghci on GRSEC kernels hardened with
TPE (Trusted Path Execution) protection.

TPE forbids mmap('rwx') files opened for writes:
    fd = open (a_file_in_tmp, O_RDWR);
    mmap (...,               PROT_READ | PROT_WRITE | PROT_EXEC, fd);

while allows anonymous RWX mappings:
    mmap (...MAP_ANONYMOUS , PROT_READ | PROT_WRITE | PROT_EXEC, -1);

Thanks to klondike for finding it out.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
---
 libffi/ghc.mk                               |    2 ++
 libffi/libffi.selinux-detection-3.0.8.patch |   15 +++++++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
 create mode 100644 libffi/libffi.selinux-detection-3.0.8.patch

diff --git a/libffi/ghc.mk b/libffi/ghc.mk
index 1b1b118..a40f23c 100644
--- a/libffi/ghc.mk
+++ b/libffi/ghc.mk
@@ -117,6 +117,8 @@ $(libffi_STAMP_CONFIGURE):
 	# This patch is just the resulting delta from running
 	# automake && autoreconf && libtoolize --force --copy
 	cd libffi/build && "$(PATCH)" -p1 < ../libffi.autotools-update-3.0.8.patch
+	# don't report nonselinux systems as selinux
+	cd libffi/build && "$(PATCH)" -p0 < ../libffi.selinux-detection-3.0.8.patch
 
 # Because -Werror may be in SRC_CC_OPTS/SRC_LD_OPTS, we need to turn
 # warnings off or the compilation of libffi might fail due to warnings
diff --git a/libffi/libffi.selinux-detection-3.0.8.patch b/libffi/libffi.selinux-detection-3.0.8.patch
new file mode 100644
index 0000000..a919f28
--- /dev/null
+++ b/libffi/libffi.selinux-detection-3.0.8.patch
@@ -0,0 +1,15 @@
+src/closures.c (selinux_enabled_check): Fix strncmp usage bug.
+
+http://github.com/atgreen/libffi/commit/eaf444eabc4c78703c0f98ac0197b1619c1b1bef
+
+--- src/closures.c
++++ src/closures.c
+@@ -146,7 +146,7 @@
+       p = strchr (p + 1, ' ');
+       if (p == NULL)
+         break;
+-      if (strncmp (p + 1, "selinuxfs ", 10) != 0)
++      if (strncmp (p + 1, "selinuxfs ", 10) == 0)
+         {
+           free (buf);
+           fclose (f);
-- 
1.7.3.4