summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYi Zhao <yi.zhao@windriver.com>2021-03-13 13:50:31 +0800
committerJoe MacDonald <joe@deserted.net>2021-03-17 09:39:50 -0400
commitb78b413a24cf97f5ebda73bcf36fcb15ffbe1abf (patch)
treea94331d8e45daadf00799dabee73a0c6f6ce2c66
parentd10900fc87b7ac7758b15b275659b8a6e1042397 (diff)
downloadmeta-selinux-b78b413a24cf97f5ebda73bcf36fcb15ffbe1abf.tar.gz
libselinux: update to 3.2
* Merge inc file into bb file. * Drop obsolete patches: 0001-libselinux-do-not-define-gettid-for-musl.patch libselinux-define-FD_CLOEXEC-as-necessary.patch libselinux-make-O_CLOEXEC-optional.patch libselinux-make-SOCK_CLOEXEC-optional.patch Signed-off-by: Yi Zhao <yi.zhao@windriver.com> Signed-off-by: Joe MacDonald <joe@deserted.net>
-rw-r--r--recipes-security/selinux/libselinux/0001-libselinux-do-not-define-gettid-for-musl.patch47
-rw-r--r--recipes-security/selinux/libselinux/libselinux-define-FD_CLOEXEC-as-necessary.patch33
-rw-r--r--recipes-security/selinux/libselinux/libselinux-make-O_CLOEXEC-optional.patch99
-rw-r--r--recipes-security/selinux/libselinux/libselinux-make-SOCK_CLOEXEC-optional.patch38
-rw-r--r--recipes-security/selinux/libselinux_3.1.bb17
-rw-r--r--recipes-security/selinux/libselinux_3.2.bb (renamed from recipes-security/selinux/libselinux.inc)7
6 files changed, 6 insertions, 235 deletions
diff --git a/recipes-security/selinux/libselinux/0001-libselinux-do-not-define-gettid-for-musl.patch b/recipes-security/selinux/libselinux/0001-libselinux-do-not-define-gettid-for-musl.patch
deleted file mode 100644
index 5d6e409..0000000
--- a/recipes-security/selinux/libselinux/0001-libselinux-do-not-define-gettid-for-musl.patch
+++ /dev/null
@@ -1,47 +0,0 @@
1From 5f6f4a095bc82b29c3871d4d8a15d9c16cef39ef Mon Sep 17 00:00:00 2001
2From: Yi Zhao <yi.zhao@windriver.com>
3Date: Wed, 6 Jan 2021 10:42:11 +0800
4Subject: [PATCH] libselinux: do not define gettid() for musl
5
6The musl has implemented gettid() function:
7http://git.musl-libc.org/cgit/musl/commit/?id=d49cf07541bb54a5ac7aec1feec8514db33db8ea
8
9Fixes:
10procattr.c:38:14: error: static declaration of 'gettid' follows non-static declaration
11 38 | static pid_t gettid(void)
12 | ^~~~~~
13In file included from procattr.c:2:
14/build/tmp/work/core2-32-poky-linux-musl/libselinux/3.1-r0/recipe-sysroot/usr/include/unistd.h:194:7:
15note: previous declaration of 'gettid' was here
16 194 | pid_t gettid(void);
17 | ^~~~~~
18
19Upstream-Status: Pending
20
21Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
22---
23 src/procattr.c | 8 +-------
24 1 file changed, 1 insertion(+), 7 deletions(-)
25
26diff --git a/src/procattr.c b/src/procattr.c
27index 926ee54..519e515 100644
28--- a/src/procattr.c
29+++ b/src/procattr.c
30@@ -24,13 +24,7 @@ static __thread char destructor_initialized;
31
32 /* Bionic and glibc >= 2.30 declare gettid() system call wrapper in unistd.h and
33 * has a definition for it */
34-#ifdef __BIONIC__
35- #define OVERRIDE_GETTID 0
36-#elif !defined(__GLIBC_PREREQ)
37- #define OVERRIDE_GETTID 1
38-#elif !__GLIBC_PREREQ(2,30)
39- #define OVERRIDE_GETTID 1
40-#else
41+#if !defined(__GLIBC_)
42 #define OVERRIDE_GETTID 0
43 #endif
44
45--
462.17.1
47
diff --git a/recipes-security/selinux/libselinux/libselinux-define-FD_CLOEXEC-as-necessary.patch b/recipes-security/selinux/libselinux/libselinux-define-FD_CLOEXEC-as-necessary.patch
deleted file mode 100644
index 25d4b24..0000000
--- a/recipes-security/selinux/libselinux/libselinux-define-FD_CLOEXEC-as-necessary.patch
+++ /dev/null
@@ -1,33 +0,0 @@
1From d0aaf391ab30b253aa22ef6547a039bcac840fc6 Mon Sep 17 00:00:00 2001
2From: Joe MacDonald <joe.macdonald@windriver.com>
3Date: Tue, 15 Oct 2013 10:14:41 -0400
4Subject: [PATCH] libselinux: define FD_CLOEXEC as necessary
5
6In truly old systems, even FD_CLOEXEC may not be defined. Produce a
7warning and duplicate the #define for FD_CLOEXEC found in
8asm-generic/fcntl.h on more modern platforms.
9
10Upstream-Status: Inappropriate
11
12Signed-off-by: Joe MacDonald <joe.macdonald@windriver.com>
13
14---
15 src/setrans_client.c | 5 +++++
16 1 file changed, 5 insertions(+)
17
18diff --git a/src/setrans_client.c b/src/setrans_client.c
19index fa188a8..a94f02c 100644
20--- a/src/setrans_client.c
21+++ b/src/setrans_client.c
22@@ -39,6 +39,11 @@ static pthread_key_t destructor_key;
23 static int destructor_key_initialized = 0;
24 static __thread char destructor_initialized;
25
26+#ifndef FD_CLOEXEC
27+#warning FD_CLOEXEC undefined on this platform, this may leak file descriptors
28+#define FD_CLOEXEC 1
29+#endif
30+
31 /*
32 * setransd_open
33 *
diff --git a/recipes-security/selinux/libselinux/libselinux-make-O_CLOEXEC-optional.patch b/recipes-security/selinux/libselinux/libselinux-make-O_CLOEXEC-optional.patch
deleted file mode 100644
index 1d6f3a7..0000000
--- a/recipes-security/selinux/libselinux/libselinux-make-O_CLOEXEC-optional.patch
+++ /dev/null
@@ -1,99 +0,0 @@
1From 802d224953294463fa9bc793e46f664ecfea057a Mon Sep 17 00:00:00 2001
2From: Joe MacDonald <joe.macdonald@windriver.com>
3Date: Fri, 11 Oct 2013 09:56:25 -0400
4Subject: [PATCH] libselinux: make O_CLOEXEC optional
5
6Various commits in the selinux tree in the current release added O_CLOEXEC
7to open() calls in an attempt to address file descriptor leaks as
8described:
9
10 http://danwalsh.livejournal.com/53603.html
11
12However O_CLOEXEC isn't available on all platforms, so make it a
13compile-time option and generate a warning when it is not available. The
14actual impact of leaking these file descriptors is minimal, though it does
15produce curious AVC Denied messages.
16
17Upstream-Status: Inappropriate [O_CLOEXEC has been in Linux since 2007 and POSIX since 2008]
18
19Signed-off-by: Joe MacDonald <joe.macdonald@windriver.com>
20Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
21
22---
23 src/procattr.c | 16 ++++++++++++++--
24 src/sestatus.c | 8 +++++++-
25 src/stringrep.c | 8 +++++++-
26 3 files changed, 28 insertions(+), 4 deletions(-)
27
28diff --git a/src/procattr.c b/src/procattr.c
29index 48dd8af..8bf8432 100644
30--- a/src/procattr.c
31+++ b/src/procattr.c
32@@ -79,7 +79,13 @@ static int openattr(pid_t pid, const char *attr, int flags)
33 rc = asprintf(&path, "/proc/thread-self/attr/%s", attr);
34 if (rc < 0)
35 return -1;
36- fd = open(path, flags | O_CLOEXEC);
37+ fd = open(path, flags
38+#ifdef O_CLOEXEC
39+ | O_CLOEXEC
40+#else
41+#warning O_CLOEXEC undefined on this platform, this may leak file descriptors
42+#endif
43+ );
44 if (fd >= 0 || errno != ENOENT)
45 goto out;
46 free(path);
47@@ -92,7 +98,13 @@ static int openattr(pid_t pid, const char *attr, int flags)
48 if (rc < 0)
49 return -1;
50
51- fd = open(path, flags | O_CLOEXEC);
52+ fd = open(path, flags
53+#ifdef O_CLOEXEC
54+ | O_CLOEXEC
55+#else
56+#warning O_CLOEXEC undefined on this platform, this may leak file descriptors
57+#endif
58+ );
59 out:
60 free(path);
61 return fd;
62diff --git a/src/sestatus.c b/src/sestatus.c
63index ed29dc5..0cb15b6 100644
64--- a/src/sestatus.c
65+++ b/src/sestatus.c
66@@ -268,7 +268,13 @@ int selinux_status_open(int fallback)
67 return -1;
68
69 snprintf(path, sizeof(path), "%s/status", selinux_mnt);
70- fd = open(path, O_RDONLY | O_CLOEXEC);
71+ fd = open(path, O_RDONLY
72+#ifdef O_CLOEXEC
73+ | O_CLOEXEC
74+#else
75+#warning O_CLOEXEC undefined on this platform, this may leak file descriptors
76+#endif
77+ );
78 if (fd < 0)
79 goto error;
80
81diff --git a/src/stringrep.c b/src/stringrep.c
82index 2d83f96..17e9232 100644
83--- a/src/stringrep.c
84+++ b/src/stringrep.c
85@@ -105,7 +105,13 @@ static struct discover_class_node * discover_class(const char *s)
86 struct stat m;
87
88 snprintf(path, sizeof path, "%s/class/%s/perms/%s", selinux_mnt,s,dentry->d_name);
89- fd = open(path, O_RDONLY | O_CLOEXEC);
90+ fd = open(path, O_RDONLY
91+#ifdef O_CLOEXEC
92+ | O_CLOEXEC
93+#else
94+#warning O_CLOEXEC undefined on this platform, this may leak file descriptors
95+#endif
96+ );
97 if (fd < 0)
98 goto err4;
99
diff --git a/recipes-security/selinux/libselinux/libselinux-make-SOCK_CLOEXEC-optional.patch b/recipes-security/selinux/libselinux/libselinux-make-SOCK_CLOEXEC-optional.patch
deleted file mode 100644
index 77a9136..0000000
--- a/recipes-security/selinux/libselinux/libselinux-make-SOCK_CLOEXEC-optional.patch
+++ /dev/null
@@ -1,38 +0,0 @@
1From e630805d15a3b8d09330353f87a7e4a9fcc9998a Mon Sep 17 00:00:00 2001
2From: Joe MacDonald <joe.macdonald@windriver.com>
3Date: Tue, 15 Oct 2013 10:07:43 -0400
4Subject: [PATCH] libselinux: make SOCK_CLOEXEC optional
5
6libselinux/src/setrans_client.c checks for the existence of SOCK_CLOEXEC
7before using it, however libselinux/src/avc_internal.c does not. Since
8SOCK_CLOEXEC suffers the same problem as O_CLOEXEC on some older
9platforms, we need to ensure we protect the references it it in the same
10way.
11
12Upstream-Status: Inappropriate
13
14Signed-off-by: Joe MacDonald <joe.macdonald@windriver.com>
15
16---
17 src/avc_internal.c | 8 +++++++-
18 1 file changed, 7 insertions(+), 1 deletion(-)
19
20diff --git a/src/avc_internal.c b/src/avc_internal.c
21index 49cecc9..148cc83 100644
22--- a/src/avc_internal.c
23+++ b/src/avc_internal.c
24@@ -60,7 +60,13 @@ int avc_netlink_open(int blocking)
25 int len, rc = 0;
26 struct sockaddr_nl addr;
27
28- fd = socket(PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_SELINUX);
29+ fd = socket(PF_NETLINK, SOCK_RAW
30+#ifdef SOCK_CLOEXEC
31+ | SOCK_CLOEXEC
32+#else
33+#warning SOCK_CLOEXEC undefined on this platform, this may leak file descriptors
34+#endif
35+ , NETLINK_SELINUX);
36 if (fd < 0) {
37 rc = fd;
38 goto out;
diff --git a/recipes-security/selinux/libselinux_3.1.bb b/recipes-security/selinux/libselinux_3.1.bb
deleted file mode 100644
index 9d1cda5..0000000
--- a/recipes-security/selinux/libselinux_3.1.bb
+++ /dev/null
@@ -1,17 +0,0 @@
1require selinux_20200710.inc
2require ${BPN}.inc
3
4LIC_FILES_CHKSUM = "file://LICENSE;md5=84b4d2c6ef954a2d4081e775a270d0d0"
5
6SRC_URI[md5sum] = "693680c021feb69a4b258b0370021461"
7SRC_URI[sha256sum] = "ea5dcbb4d859e3f999c26a13c630da2f16dff9462e3cc8cb7b458ac157d112e7"
8
9SRC_URI += "\
10 file://libselinux-make-O_CLOEXEC-optional.patch \
11 file://libselinux-make-SOCK_CLOEXEC-optional.patch \
12 file://libselinux-define-FD_CLOEXEC-as-necessary.patch \
13 "
14
15SRC_URI_append_libc-musl = " \
16 file://0001-libselinux-do-not-define-gettid-for-musl.patch \
17 "
diff --git a/recipes-security/selinux/libselinux.inc b/recipes-security/selinux/libselinux_3.2.bb
index fe8c087..5acd576 100644
--- a/recipes-security/selinux/libselinux.inc
+++ b/recipes-security/selinux/libselinux_3.2.bb
@@ -4,20 +4,25 @@ process and file security contexts and to obtain security policy \
4decisions. Required for any applications that use the SELinux API." 4decisions. Required for any applications that use the SELinux API."
5SECTION = "base" 5SECTION = "base"
6LICENSE = "PD" 6LICENSE = "PD"
7LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=84b4d2c6ef954a2d4081e775a270d0d0"
8
9require selinux_common.inc
7 10
8inherit lib_package python3native 11inherit lib_package python3native
9 12
10DEPENDS += "libsepol libpcre" 13DEPENDS += "libsepol libpcre"
11DEPENDS_append_libc-musl = " fts" 14DEPENDS_append_libc-musl = " fts"
12 15
16S = "${WORKDIR}/git/libselinux"
17
13def get_policyconfigarch(d): 18def get_policyconfigarch(d):
14 import re 19 import re
15 target = d.getVar('TARGET_ARCH') 20 target = d.getVar('TARGET_ARCH')
16 p = re.compile('i.86') 21 p = re.compile('i.86')
17 target = p.sub('i386',target) 22 target = p.sub('i386',target)
18 return "ARCH=%s" % (target) 23 return "ARCH=%s" % (target)
19EXTRA_OEMAKE += "${@get_policyconfigarch(d)}"
20 24
25EXTRA_OEMAKE += "${@get_policyconfigarch(d)}"
21EXTRA_OEMAKE += "LDFLAGS='${LDFLAGS} -lpcre' LIBSEPOLA='${STAGING_LIBDIR}/libsepol.a'" 26EXTRA_OEMAKE += "LDFLAGS='${LDFLAGS} -lpcre' LIBSEPOLA='${STAGING_LIBDIR}/libsepol.a'"
22EXTRA_OEMAKE_append_libc-musl = " FTS_LDLIBS=-lfts" 27EXTRA_OEMAKE_append_libc-musl = " FTS_LDLIBS=-lfts"
23 28