summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-core/dbus/dbus-broker/0001-launch-improve-error-handling-for-opendir.patch48
-rw-r--r--meta-oe/recipes-core/dbus/dbus-broker/0002-metrics-change-the-constant-used-for-invalid-timesta.patch86
-rw-r--r--meta-oe/recipes-core/dbus/dbus-broker/0003-dbus-socket-treat-MSG_CTRUNC-gracefully.patch83
-rw-r--r--meta-oe/recipes-core/dbus/dbus-broker/0004-launcher-fix-build-with-musl-libc.patch38
-rw-r--r--meta-oe/recipes-core/dbus/dbus-broker/0005-launch-policy-fix-crash-when-importing-selinux.patch50
-rw-r--r--meta-oe/recipes-core/dbus/dbus-broker/0006-launch-policy-fix-crash-when-exporting-selinux.patch59
-rw-r--r--meta-oe/recipes-core/dbus/dbus-broker_22.bb (renamed from meta-oe/recipes-core/dbus/dbus-broker_21.bb)10
7 files changed, 2 insertions, 372 deletions
diff --git a/meta-oe/recipes-core/dbus/dbus-broker/0001-launch-improve-error-handling-for-opendir.patch b/meta-oe/recipes-core/dbus/dbus-broker/0001-launch-improve-error-handling-for-opendir.patch
deleted file mode 100644
index ccc175bb80..0000000000
--- a/meta-oe/recipes-core/dbus/dbus-broker/0001-launch-improve-error-handling-for-opendir.patch
+++ /dev/null
@@ -1,48 +0,0 @@
1From f42d5e38859c65a186acd0da94bbeeca12faf7a2 Mon Sep 17 00:00:00 2001
2From: David Rheinsberg <david.rheinsberg@gmail.com>
3Date: Thu, 2 May 2019 17:33:34 +0200
4Subject: [PATCH] launch: improve error handling for opendir()
5
6This improves the error-handling of opendir() by always printing
7diagnostics. Furthermore, it aligns the behavior with dbus-deamon and
8ignores EACCES.
9
10Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
11Upstream-Status: dbus-broker@f42d5e38859c65a186acd0da94bbeeca12faf7a2
12---
13 src/launch/launcher.c | 17 +++++++++++++++--
14 1 file changed, 15 insertions(+), 2 deletions(-)
15
16diff --git a/src/launch/launcher.c b/src/launch/launcher.c
17index 31a5364..2ec4bda 100644
18--- a/src/launch/launcher.c
19+++ b/src/launch/launcher.c
20@@ -749,10 +749,23 @@ static int launcher_load_service_dir(Launcher *launcher, const char *dirpath, NS
21
22 dir = opendir(dirpath);
23 if (!dir) {
24- if (errno == ENOENT || errno == ENOTDIR)
25+ if (errno == ENOENT || errno == ENOTDIR) {
26 return 0;
27- else
28+ } else if (errno == EACCES) {
29+ log_append_here(&launcher->log, LOG_ERR, 0, NULL);
30+ r = log_commitf(&launcher->log, "Access denied to service directory '%s'\n", dirpath);
31+ if (r)
32+ return error_fold(r);
33+
34+ return 0;
35+ } else {
36+ log_append_here(&launcher->log, LOG_ERR, errno, NULL);
37+ r = log_commitf(&launcher->log, "Unable to open service directory '%s': %m\n", dirpath);
38+ if (r)
39+ return error_fold(r);
40+
41 return error_origin(-errno);
42+ }
43 }
44
45 r = dirwatch_add(launcher->dirwatch, dirpath);
46--
472.20.1
48
diff --git a/meta-oe/recipes-core/dbus/dbus-broker/0002-metrics-change-the-constant-used-for-invalid-timesta.patch b/meta-oe/recipes-core/dbus/dbus-broker/0002-metrics-change-the-constant-used-for-invalid-timesta.patch
deleted file mode 100644
index 67a2dc46f1..0000000000
--- a/meta-oe/recipes-core/dbus/dbus-broker/0002-metrics-change-the-constant-used-for-invalid-timesta.patch
+++ /dev/null
@@ -1,86 +0,0 @@
1From 3570b3e9ba367f10718b56336ce32d5254f66575 Mon Sep 17 00:00:00 2001
2From: Tom Gundersen <teg@jklm.no>
3Date: Thu, 9 May 2019 13:00:37 +0200
4Subject: [PATCH] metrics: change the constant used for invalid timestamps
5
6Use (uint64_t)-1 rather than 0 to indicate an invalid timestamp. It
7should not be possible for the kernel to return 0 from
8clock_gettime(), but we have received some reports of our asserts
9triggering, so avoid the issue entirely by using -1 instead (which
10really can never be returned).
11
12See https://retrace.fedoraproject.org/faf/reports/2539484/
13
14Signed-off-by: Tom Gundersen <teg@jklm.no>
15Upstream-Status: dbus-broker@3570b3e9ba367f10718b56336ce32d5254f66575
16---
17 src/util/metrics.c | 8 ++++----
18 src/util/metrics.h | 9 ++++++---
19 2 files changed, 10 insertions(+), 7 deletions(-)
20
21diff --git a/src/util/metrics.c b/src/util/metrics.c
22index b5a7182..eef94eb 100644
23--- a/src/util/metrics.c
24+++ b/src/util/metrics.c
25@@ -26,7 +26,7 @@ void metrics_init(Metrics *metrics, clockid_t id) {
26 }
27
28 void metrics_deinit(Metrics *metrics) {
29- c_assert(!metrics->timestamp);
30+ c_assert(metrics->timestamp == METRICS_TIMESTAMP_INVALID);
31 metrics_init(metrics, metrics->id);
32 }
33
34@@ -82,7 +82,7 @@ void metrics_sample_add(Metrics *metrics, uint64_t timestamp) {
35 * a sample is not currently running.
36 */
37 void metrics_sample_start(Metrics *metrics) {
38- c_assert(!metrics->timestamp);
39+ c_assert(metrics->timestamp == METRICS_TIMESTAMP_INVALID);
40 metrics->timestamp = metrics_get_time(metrics);
41 }
42
43@@ -93,11 +93,11 @@ void metrics_sample_start(Metrics *metrics) {
44 * End a currently running sample, and update the internal state.
45 */
46 void metrics_sample_end(Metrics *metrics) {
47- c_assert(metrics->timestamp);
48+ c_assert(metrics->timestamp != METRICS_TIMESTAMP_INVALID);
49
50 metrics_sample_add(metrics, metrics->timestamp);
51
52- metrics->timestamp = 0;
53+ metrics->timestamp = METRICS_TIMESTAMP_INVALID;
54 }
55
56 /**
57diff --git a/src/util/metrics.h b/src/util/metrics.h
58index a8ee915..b00dee6 100644
59--- a/src/util/metrics.h
60+++ b/src/util/metrics.h
61@@ -8,6 +8,8 @@
62 #include <stdlib.h>
63 #include <time.h>
64
65+#define METRICS_TIMESTAMP_INVALID ((uint64_t) -1)
66+
67 typedef struct Metrics Metrics;
68
69 struct Metrics {
70@@ -23,9 +25,10 @@ struct Metrics {
71 uint64_t sum_of_squares;
72 };
73
74-#define METRICS_INIT(_id) { \
75- .minimum = (uint64_t) -1, \
76- .id = (_id), \
77+#define METRICS_INIT(_id) { \
78+ .minimum = (uint64_t) -1, \
79+ .id = (_id), \
80+ .timestamp = METRICS_TIMESTAMP_INVALID, \
81 }
82
83 void metrics_init(Metrics *metrics, clockid_t id);
84--
852.21.0
86
diff --git a/meta-oe/recipes-core/dbus/dbus-broker/0003-dbus-socket-treat-MSG_CTRUNC-gracefully.patch b/meta-oe/recipes-core/dbus/dbus-broker/0003-dbus-socket-treat-MSG_CTRUNC-gracefully.patch
deleted file mode 100644
index 53f9e71aab..0000000000
--- a/meta-oe/recipes-core/dbus/dbus-broker/0003-dbus-socket-treat-MSG_CTRUNC-gracefully.patch
+++ /dev/null
@@ -1,83 +0,0 @@
1From 520c47c53deeb893e03194fefaf3c5b9223ede27 Mon Sep 17 00:00:00 2001
2From: David Rheinsberg <david.rheinsberg@gmail.com>
3Date: Fri, 10 May 2019 10:58:06 +0200
4Subject: [PATCH] dbus/socket: treat MSG_CTRUNC gracefully
5
6As it turns out, LSMs allow clients to trigger a MSG_CTRUNC on the
7remote side of a unix socket. Whenever LSMs reject the transmission of
8an FD, they will simply drop the FD and set MSG_CTRUNC, without any
9other error notification.
10
11Therefore, we must assume any occurance of MSG_CTRUNC is trigger by a
12client. This makes it impossible to consider MSG_CTRUNC for any other
13error handling, and as such we are left to disconnecting the client and
14ignoring the flag.
15
16Luckily, MSG_CTRUNC is expected for any other event, so we only used it
17for diagnostics so far.
18
19Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
20Upstream-Status: dbus-broker@520c47c53deeb893e03194fefaf3c5b9223ede27
21---
22 src/dbus/socket.c | 44 +++++++++++++++++++++++++++++++++-----------
23 1 file changed, 33 insertions(+), 11 deletions(-)
24
25diff --git a/src/dbus/socket.c b/src/dbus/socket.c
26index cacdff2..6e6ba10 100644
27--- a/src/dbus/socket.c
28+++ b/src/dbus/socket.c
29@@ -593,18 +593,40 @@ static int socket_recvmsg(Socket *socket,
30
31 if (msg.msg_flags & MSG_CTRUNC) {
32 /*
33- * This flag means the control-buffer was too small to retrieve
34- * all data. If this can be triggered remotely, it means a peer
35- * can cause us to miss FDs. Hence, we really must protect
36- * against this.
37- * We do provide suitably sized buffers to be prepared for any
38- * possible scenario. So if this happens, something is fishy
39- * and we better report it.
40- * Note that this is also reported by the kernel if we exceeded
41- * our NOFILE limit. Since this implies resource
42- * misconfiguration as well, we treat it the same way.
43+ * Our control-buffer-size is carefully calculated to be big
44+ * enough for any possible ancillary data we expect. Therefore,
45+ * the kernel should never be required to truncate it, and thus
46+ * MSG_CTRUNC will never be set. This is also foward compatible
47+ * to future extensions to the ancillary data, since these must
48+ * be enabled explicitly before the kernel considers forwarding
49+ * them.
50+ *
51+ * Unfortunately, the SCM_RIGHTS implementation might set this
52+ * flag as well. In particular, if not all FDs can be returned
53+ * to user-space, MSG_CTRUNC will be set (signalling that the
54+ * FD-set is non-complete). No other error is returned or
55+ * signalled, though. There are several reasons why the FD
56+ * transmission can fail. Most importantly, if we exhaust our
57+ * FD limit, further FDs will simply be discarded. We are
58+ * protected against this by our accounting-quotas, but we
59+ * would still like to catch this condition and warn loudly.
60+ * However, FDs are also dropped if the security layer refused
61+ * the transmission of the FD in question. This means, if an
62+ * LSM refuses the D-Bus client to send us an FD, the FD is
63+ * just dropped and MSG_CTRUNC will be set. This can be
64+ * triggered by clients.
65+ *
66+ * To summarize: In an ideal world, we would expect this flag
67+ * to never be set, and we would just use
68+ * `error_origin(-ENOTRECOVERABLE)` to provide diagnostics.
69+ * Unfortunately, the gross misuse of this flag for LSM
70+ * security enforcements means we have to assume any occurence
71+ * of MSG_CTRUNC means the client was refused to send a
72+ * specific message. Our only possible way to deal with this is
73+ * to disconnect the client.
74 */
75- r = error_origin(-ENOTRECOVERABLE);
76+ socket_close(socket);
77+ r = SOCKET_E_LOST_INTEREST;
78 goto error;
79 }
80
81--
822.21.0
83
diff --git a/meta-oe/recipes-core/dbus/dbus-broker/0004-launcher-fix-build-with-musl-libc.patch b/meta-oe/recipes-core/dbus/dbus-broker/0004-launcher-fix-build-with-musl-libc.patch
deleted file mode 100644
index 0348d97225..0000000000
--- a/meta-oe/recipes-core/dbus/dbus-broker/0004-launcher-fix-build-with-musl-libc.patch
+++ /dev/null
@@ -1,38 +0,0 @@
1From fc1d26dd08c48c04fc9883b36a94c219aba2091c Mon Sep 17 00:00:00 2001
2From: Luca Boccassi <luca.boccassi@microsoft.com>
3Date: Mon, 28 Oct 2019 14:31:38 +0000
4Subject: [PATCH] launcher: fix build with musl libc
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9../src/launch/launcher.c: In function ‘launcher_fork’:
10../src/launch/launcher.c:378:60: error: ‘WEXITED’ undeclared (first use in this function); did you mean ‘WIFEXITED’?
11 r = sd_event_add_child(launcher->event, NULL, pid, WEXITED, launcher_on_child_exit, launcher);
12 ^~~~~~~
13 WIFEXITED
14
15Include sys/wait.h which defines it.
16
17Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
18Suggested-by: Khem Raj <raj.khem@gmail.com>
19Upstream-Status: pending https://github.com/bus1/dbus-broker/pull/214
20---
21 src/launch/launcher.c | 1 +
22 1 file changed, 1 insertion(+)
23
24diff --git a/src/launch/launcher.c b/src/launch/launcher.c
25index 2ec4bda..1f38fcf 100644
26--- a/src/launch/launcher.c
27+++ b/src/launch/launcher.c
28@@ -10,6 +10,7 @@
29 #include <stdlib.h>
30 #include <sys/prctl.h>
31 #include <sys/un.h>
32+#include <sys/wait.h>
33 #include <systemd/sd-bus.h>
34 #include <systemd/sd-daemon.h>
35 #include <systemd/sd-event.h>
36--
372.20.1
38
diff --git a/meta-oe/recipes-core/dbus/dbus-broker/0005-launch-policy-fix-crash-when-importing-selinux.patch b/meta-oe/recipes-core/dbus/dbus-broker/0005-launch-policy-fix-crash-when-importing-selinux.patch
deleted file mode 100644
index c5f3092ee9..0000000000
--- a/meta-oe/recipes-core/dbus/dbus-broker/0005-launch-policy-fix-crash-when-importing-selinux.patch
+++ /dev/null
@@ -1,50 +0,0 @@
1From d28e59c451375e8b08fa431b1d64cb3ce9f078ee Mon Sep 17 00:00:00 2001
2From: Luca Boccassi <luca.boccassi@microsoft.com>
3Date: Fri, 25 Oct 2019 21:04:36 +0100
4Subject: [PATCH 1/2] launch/policy: fix crash when importing <selinux>
5
6If a policy contains a <selinux> element, dbus-broker-launch crashes:
7
8Oct 22 12:02:51 localhost dbus-broker-launch[885]: dbus-broker-launch: ../dbus-broker-19/src/launch/policy.c:232: policy_import_verdict: Assertion `cnode->parent->type == CONFIG_NODE_POLICY' failed.
9
10Minimal config to reproduce:
11
12<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
13 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
14<busconfig>
15 <selinux>
16 <associate own="com.example1" context="system_u:object_r:example1_t" />
17 <associate own="com.example2" context="system_u:object_r:example2_t" />
18 </selinux>
19</busconfig>
20
21policy_import_verdict is being called on an associate element,
22but not only it cannot work as that function checks that the
23parent is a policy node (but it's a selinux node in this case),
24it is also not necessary as the selinux node only defines ownership,
25it does not have allow/deny.
26
27Fixes #212
28
29Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
30Upstream-Status: merged https://github.com/bus1/dbus-broker/pull/213
31---
32 src/launch/policy.c | 2 --
33 1 file changed, 2 deletions(-)
34
35diff --git a/src/launch/policy.c b/src/launch/policy.c
36index a8ba8e7..466e4bd 100644
37--- a/src/launch/policy.c
38+++ b/src/launch/policy.c
39@@ -613,8 +613,6 @@ static int policy_import_selinux(Policy *policy, ConfigNode *cnode) {
40 if (r)
41 return error_trace(r);
42
43- policy_import_verdict(policy, record, cnode);
44-
45 record->selinux.name = cnode->associate.own;
46 record->selinux.context = cnode->associate.context;
47
48--
492.20.1
50
diff --git a/meta-oe/recipes-core/dbus/dbus-broker/0006-launch-policy-fix-crash-when-exporting-selinux.patch b/meta-oe/recipes-core/dbus/dbus-broker/0006-launch-policy-fix-crash-when-exporting-selinux.patch
deleted file mode 100644
index 51f45361b7..0000000000
--- a/meta-oe/recipes-core/dbus/dbus-broker/0006-launch-policy-fix-crash-when-exporting-selinux.patch
+++ /dev/null
@@ -1,59 +0,0 @@
1From f1cdef4d98ddbfeeb4a688712d54b3adc89bfe26 Mon Sep 17 00:00:00 2001
2From: Luca Boccassi <luca.boccassi@microsoft.com>
3Date: Fri, 25 Oct 2019 21:05:43 +0100
4Subject: [PATCH 2/2] launch/policy: fix crash when exporting <selinux>
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9If a policy contains a <selinux> element, dbus-broker-launch crashes:
10
11[ 30.048705] dbus-broker-launch[221]: ERROR policy_export @ ../dbus-broker-21/src/launch/policy.c +1142: Return code 1
12[ 30.050963] dbus-broker-launch[221]: launcher_add_listener @ ../dbus-broker-21/src/launch/launcher.c +1130
13[ 30.079620] dbus-broker[228]: Dispatched 0 messages @ 0(±0)μs / message.
14[ 30.082613] dbus-broker-launch[221]: launcher_run @ ../dbus-broker-21/src/launch/launcher.c +1389
15[ 30.084426] dbus-broker-launch[221]: run @ ../dbus-broker-21/src/launch/main.c +153
16[ 30.085797] dbus-broker-launch[221]: main @ ../dbus-broker-21/src/launch/main.c +181
17[ 30.087208] dbus-broker-launch[221]: Exiting due to fatal error: -131
18
19Minimal config to reproduce:
20
21<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
22 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
23<busconfig>
24 <selinux>
25 <associate own="com.example1" context="system_u:object_r:example1_t" />
26 <associate own="com.example2" context="system_u:object_r:example2_t" />
27 </selinux>
28</busconfig>
29
30As per the libsystemd API, sd_bus_message_append can return an int
31greater than 0 on success, which for example happens when processing
32vectors.
33The export function is treating every non-zero result as an error,
34which causes dbus-broker-launch to terminate.
35
36Fixes #212
37
38Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
39Upstream-Status: merged https://github.com/bus1/dbus-broker/pull/213
40---
41 src/launch/policy.c | 2 +-
42 1 file changed, 1 insertion(+), 1 deletion(-)
43
44diff --git a/src/launch/policy.c b/src/launch/policy.c
45index 466e4bd..f91f11b 100644
46--- a/src/launch/policy.c
47+++ b/src/launch/policy.c
48@@ -1138,7 +1138,7 @@ int policy_export(Policy *policy, sd_bus_message *m, uint32_t *at_console_uids,
49 r = sd_bus_message_append(m, "(ss)",
50 i_record->selinux.name,
51 i_record->selinux.context);
52- if (r)
53+ if (r < 0)
54 return error_origin(r);
55 }
56
57--
582.20.1
59
diff --git a/meta-oe/recipes-core/dbus/dbus-broker_21.bb b/meta-oe/recipes-core/dbus/dbus-broker_22.bb
index 67b515d07c..c0b6f7f882 100644
--- a/meta-oe/recipes-core/dbus/dbus-broker_21.bb
+++ b/meta-oe/recipes-core/dbus/dbus-broker_22.bb
@@ -7,14 +7,8 @@ LICENSE = "Apache-2.0"
7LIC_FILES_CHKSUM = "file://LICENSE;md5=7b486c2338d225a1405d979ed2c15ce8" 7LIC_FILES_CHKSUM = "file://LICENSE;md5=7b486c2338d225a1405d979ed2c15ce8"
8 8
9SRC_URI = "https://github.com/bus1/dbus-broker/releases/download/v${PV}/dbus-broker-${PV}.tar.xz" 9SRC_URI = "https://github.com/bus1/dbus-broker/releases/download/v${PV}/dbus-broker-${PV}.tar.xz"
10SRC_URI += " file://0001-launch-improve-error-handling-for-opendir.patch" 10SRC_URI[md5sum] = "03c4730f2110b5492e1212c81af325dc"
11SRC_URI += " file://0002-metrics-change-the-constant-used-for-invalid-timesta.patch" 11SRC_URI[sha256sum] = "32f30700cefc997c479d75fcc42f3177940f1ebbee9c5a60c1e3ee39b90a9783"
12SRC_URI += " file://0003-dbus-socket-treat-MSG_CTRUNC-gracefully.patch"
13SRC_URI += " file://0004-launcher-fix-build-with-musl-libc.patch"
14SRC_URI += " file://0005-launch-policy-fix-crash-when-importing-selinux.patch"
15SRC_URI += " file://0006-launch-policy-fix-crash-when-exporting-selinux.patch"
16SRC_URI[md5sum] = "a17886a92ab1e0bc2e4b1a274339e388"
17SRC_URI[sha256sum] = "6fff9a831a514659e2c7d704e76867ce31ebcf43e8d7a62e080c6656f64cd39e"
18 12
19UPSTREAM_CHECK_URI = "https://github.com/bus1/${BPN}/releases" 13UPSTREAM_CHECK_URI = "https://github.com/bus1/${BPN}/releases"
20 14