summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-core
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2019-10-28 14:58:21 +0000
committerKhem Raj <raj.khem@gmail.com>2019-10-28 15:26:42 -0700
commitc12bca1e7aefbb5d16ecf32de1c519becd5cf877 (patch)
tree55a55786abcabe28bd5728122602891e7d86da47 /meta-oe/recipes-core
parent65cf98b5a4e6026acafebdc9bc0a86e039773418 (diff)
downloadmeta-openembedded-c12bca1e7aefbb5d16ecf32de1c519becd5cf877.tar.gz
dbus-broker: backport patches from master
These patches fix issues found in Fedora 30, which switched from dbus-daemon to dbus-broker. These backports align meta-oe to Fedora 30. Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe/recipes-core')
-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_21.bb3
4 files changed, 220 insertions, 0 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
new file mode 100644
index 000000000..ccc175bb8
--- /dev/null
+++ b/meta-oe/recipes-core/dbus/dbus-broker/0001-launch-improve-error-handling-for-opendir.patch
@@ -0,0 +1,48 @@
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
new file mode 100644
index 000000000..67a2dc46f
--- /dev/null
+++ b/meta-oe/recipes-core/dbus/dbus-broker/0002-metrics-change-the-constant-used-for-invalid-timesta.patch
@@ -0,0 +1,86 @@
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
new file mode 100644
index 000000000..53f9e71aa
--- /dev/null
+++ b/meta-oe/recipes-core/dbus/dbus-broker/0003-dbus-socket-treat-MSG_CTRUNC-gracefully.patch
@@ -0,0 +1,83 @@
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_21.bb b/meta-oe/recipes-core/dbus/dbus-broker_21.bb
index 9cb59e336..b1633e16b 100644
--- a/meta-oe/recipes-core/dbus/dbus-broker_21.bb
+++ b/meta-oe/recipes-core/dbus/dbus-broker_21.bb
@@ -7,6 +7,9 @@ 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"
11SRC_URI += " file://0002-metrics-change-the-constant-used-for-invalid-timesta.patch"
12SRC_URI += " file://0003-dbus-socket-treat-MSG_CTRUNC-gracefully.patch"
10SRC_URI[md5sum] = "a17886a92ab1e0bc2e4b1a274339e388" 13SRC_URI[md5sum] = "a17886a92ab1e0bc2e4b1a274339e388"
11SRC_URI[sha256sum] = "6fff9a831a514659e2c7d704e76867ce31ebcf43e8d7a62e080c6656f64cd39e" 14SRC_URI[sha256sum] = "6fff9a831a514659e2c7d704e76867ce31ebcf43e8d7a62e080c6656f64cd39e"
12 15