diff options
author | Luca Boccassi <luca.boccassi@microsoft.com> | 2019-10-28 14:58:21 +0000 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2019-10-28 15:26:42 -0700 |
commit | c12bca1e7aefbb5d16ecf32de1c519becd5cf877 (patch) | |
tree | 55a55786abcabe28bd5728122602891e7d86da47 /meta-oe | |
parent | 65cf98b5a4e6026acafebdc9bc0a86e039773418 (diff) | |
download | meta-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')
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 @@ | |||
1 | From f42d5e38859c65a186acd0da94bbeeca12faf7a2 Mon Sep 17 00:00:00 2001 | ||
2 | From: David Rheinsberg <david.rheinsberg@gmail.com> | ||
3 | Date: Thu, 2 May 2019 17:33:34 +0200 | ||
4 | Subject: [PATCH] launch: improve error handling for opendir() | ||
5 | |||
6 | This improves the error-handling of opendir() by always printing | ||
7 | diagnostics. Furthermore, it aligns the behavior with dbus-deamon and | ||
8 | ignores EACCES. | ||
9 | |||
10 | Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com> | ||
11 | Upstream-Status: dbus-broker@f42d5e38859c65a186acd0da94bbeeca12faf7a2 | ||
12 | --- | ||
13 | src/launch/launcher.c | 17 +++++++++++++++-- | ||
14 | 1 file changed, 15 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/src/launch/launcher.c b/src/launch/launcher.c | ||
17 | index 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 | -- | ||
47 | 2.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 @@ | |||
1 | From 3570b3e9ba367f10718b56336ce32d5254f66575 Mon Sep 17 00:00:00 2001 | ||
2 | From: Tom Gundersen <teg@jklm.no> | ||
3 | Date: Thu, 9 May 2019 13:00:37 +0200 | ||
4 | Subject: [PATCH] metrics: change the constant used for invalid timestamps | ||
5 | |||
6 | Use (uint64_t)-1 rather than 0 to indicate an invalid timestamp. It | ||
7 | should not be possible for the kernel to return 0 from | ||
8 | clock_gettime(), but we have received some reports of our asserts | ||
9 | triggering, so avoid the issue entirely by using -1 instead (which | ||
10 | really can never be returned). | ||
11 | |||
12 | See https://retrace.fedoraproject.org/faf/reports/2539484/ | ||
13 | |||
14 | Signed-off-by: Tom Gundersen <teg@jklm.no> | ||
15 | Upstream-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 | |||
21 | diff --git a/src/util/metrics.c b/src/util/metrics.c | ||
22 | index 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 | /** | ||
57 | diff --git a/src/util/metrics.h b/src/util/metrics.h | ||
58 | index 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 | -- | ||
85 | 2.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 @@ | |||
1 | From 520c47c53deeb893e03194fefaf3c5b9223ede27 Mon Sep 17 00:00:00 2001 | ||
2 | From: David Rheinsberg <david.rheinsberg@gmail.com> | ||
3 | Date: Fri, 10 May 2019 10:58:06 +0200 | ||
4 | Subject: [PATCH] dbus/socket: treat MSG_CTRUNC gracefully | ||
5 | |||
6 | As it turns out, LSMs allow clients to trigger a MSG_CTRUNC on the | ||
7 | remote side of a unix socket. Whenever LSMs reject the transmission of | ||
8 | an FD, they will simply drop the FD and set MSG_CTRUNC, without any | ||
9 | other error notification. | ||
10 | |||
11 | Therefore, we must assume any occurance of MSG_CTRUNC is trigger by a | ||
12 | client. This makes it impossible to consider MSG_CTRUNC for any other | ||
13 | error handling, and as such we are left to disconnecting the client and | ||
14 | ignoring the flag. | ||
15 | |||
16 | Luckily, MSG_CTRUNC is expected for any other event, so we only used it | ||
17 | for diagnostics so far. | ||
18 | |||
19 | Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com> | ||
20 | Upstream-Status: dbus-broker@520c47c53deeb893e03194fefaf3c5b9223ede27 | ||
21 | --- | ||
22 | src/dbus/socket.c | 44 +++++++++++++++++++++++++++++++++----------- | ||
23 | 1 file changed, 33 insertions(+), 11 deletions(-) | ||
24 | |||
25 | diff --git a/src/dbus/socket.c b/src/dbus/socket.c | ||
26 | index 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 | -- | ||
82 | 2.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" | |||
7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=7b486c2338d225a1405d979ed2c15ce8" | 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=7b486c2338d225a1405d979ed2c15ce8" |
8 | 8 | ||
9 | SRC_URI = "https://github.com/bus1/dbus-broker/releases/download/v${PV}/dbus-broker-${PV}.tar.xz" | 9 | SRC_URI = "https://github.com/bus1/dbus-broker/releases/download/v${PV}/dbus-broker-${PV}.tar.xz" |
10 | SRC_URI += " file://0001-launch-improve-error-handling-for-opendir.patch" | ||
11 | SRC_URI += " file://0002-metrics-change-the-constant-used-for-invalid-timesta.patch" | ||
12 | SRC_URI += " file://0003-dbus-socket-treat-MSG_CTRUNC-gracefully.patch" | ||
10 | SRC_URI[md5sum] = "a17886a92ab1e0bc2e4b1a274339e388" | 13 | SRC_URI[md5sum] = "a17886a92ab1e0bc2e4b1a274339e388" |
11 | SRC_URI[sha256sum] = "6fff9a831a514659e2c7d704e76867ce31ebcf43e8d7a62e080c6656f64cd39e" | 14 | SRC_URI[sha256sum] = "6fff9a831a514659e2c7d704e76867ce31ebcf43e8d7a62e080c6656f64cd39e" |
12 | 15 | ||