diff options
Diffstat (limited to 'recipes-security/selinux/libselinux/libselinux-make-O_CLOEXEC-optional.patch')
-rw-r--r-- | recipes-security/selinux/libselinux/libselinux-make-O_CLOEXEC-optional.patch | 99 |
1 files changed, 0 insertions, 99 deletions
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 @@ | |||
1 | From 802d224953294463fa9bc793e46f664ecfea057a Mon Sep 17 00:00:00 2001 | ||
2 | From: Joe MacDonald <joe.macdonald@windriver.com> | ||
3 | Date: Fri, 11 Oct 2013 09:56:25 -0400 | ||
4 | Subject: [PATCH] libselinux: make O_CLOEXEC optional | ||
5 | |||
6 | Various commits in the selinux tree in the current release added O_CLOEXEC | ||
7 | to open() calls in an attempt to address file descriptor leaks as | ||
8 | described: | ||
9 | |||
10 | http://danwalsh.livejournal.com/53603.html | ||
11 | |||
12 | However O_CLOEXEC isn't available on all platforms, so make it a | ||
13 | compile-time option and generate a warning when it is not available. The | ||
14 | actual impact of leaking these file descriptors is minimal, though it does | ||
15 | produce curious AVC Denied messages. | ||
16 | |||
17 | Upstream-Status: Inappropriate [O_CLOEXEC has been in Linux since 2007 and POSIX since 2008] | ||
18 | |||
19 | Signed-off-by: Joe MacDonald <joe.macdonald@windriver.com> | ||
20 | Signed-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 | |||
28 | diff --git a/src/procattr.c b/src/procattr.c | ||
29 | index 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; | ||
62 | diff --git a/src/sestatus.c b/src/sestatus.c | ||
63 | index 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 | |||
81 | diff --git a/src/stringrep.c b/src/stringrep.c | ||
82 | index 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 | |||