summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2019-02-25 10:37:06 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-03-24 16:49:54 +0000
commitd5400f11dd1f8f5f7ad29faaabda80185270fe5b (patch)
treea50825672b53c8c29fcfbea6f14a24f996f8023b /meta
parent0b554def186a9cb875173dd7eb94f08a28a66e50 (diff)
downloadpoky-d5400f11dd1f8f5f7ad29faaabda80185270fe5b.tar.gz
systemd: fix CVE-2018-15686
Backport patch to fix the following CVE. CVE: CVE-2018-15686 (From OE-Core rev: 06bf145cee24b677ab076498fe8399126971bc43) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Cherry-picked from thud 0ef70603bc983315eb0e8a97958d995a31198c35 Signed-off-by: George McCollister <george.mccollister@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-core/systemd/systemd/0001-core-when-deserializing-state-always-use-read_line-L.patch250
-rw-r--r--meta/recipes-core/systemd/systemd_237.bb1
2 files changed, 251 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0001-core-when-deserializing-state-always-use-read_line-L.patch b/meta/recipes-core/systemd/systemd/0001-core-when-deserializing-state-always-use-read_line-L.patch
new file mode 100644
index 0000000000..405300148a
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0001-core-when-deserializing-state-always-use-read_line-L.patch
@@ -0,0 +1,250 @@
1From 56f77f7fcceea2fbb3b4efb8e307dd7784c63115 Mon Sep 17 00:00:00 2001
2From: Lennart Poettering <lennart@poettering.net>
3Date: Wed, 17 Oct 2018 18:36:24 +0200
4Subject: [PATCH] =?UTF-8?q?=3D=3FUTF-8=3Fq=3Fcore:=3D20when=3D20deserializ?=
5 =?UTF-8?q?ing=3D20state=3D20always=3F=3D?=
6
7 =?UTF-8?q?=20use=20read=5Fline(=E2=80=A6,=20LONG=5FLINE=5FMAX,=20?=
8 =?UTF-8?q?=E2=80=A6)?=
9MIME-Version: 1.0
10Content-Type: text/plain; charset=UTF-8
11Content-Transfer-Encoding: 8bit
12
13This should be much better than fgets(), as we can read substantially
14longer lines and overly long lines result in proper errors.
15
16Fixes a vulnerability discovered by Jann Horn at Google.
17
18CVE-2018-15686
19LP: #1796402
20https://bugzilla.redhat.com/show_bug.cgi?id=1639071
21
22(cherry picked from commit 8948b3415d762245ebf5e19d80b97d4d8cc208c1)
23
24CVE: CVE-2018-15686
25Upstream-Status: Backport
26
27Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
28
29---
30 src/core/job.c | 19 +++++++++++--------
31 src/core/manager.c | 44 ++++++++++++++++++++------------------------
32 src/core/unit.c | 34 ++++++++++++++++++----------------
33 src/core/unit.h | 2 +-
34 4 files changed, 50 insertions(+), 49 deletions(-)
35
36diff --git a/src/core/job.c b/src/core/job.c
37index c6de8d27e..e0f9cee2f 100644
38--- a/src/core/job.c
39+++ b/src/core/job.c
40@@ -28,6 +28,7 @@
41 #include "dbus-job.h"
42 #include "dbus.h"
43 #include "escape.h"
44+#include "fileio.h"
45 #include "job.h"
46 #include "log.h"
47 #include "macro.h"
48@@ -1067,24 +1068,26 @@ int job_serialize(Job *j, FILE *f) {
49 }
50
51 int job_deserialize(Job *j, FILE *f) {
52+ int r;
53+
54 assert(j);
55 assert(f);
56
57 for (;;) {
58- char line[LINE_MAX], *l, *v;
59+ _cleanup_free_ char *line = NULL;
60+ char *l, *v;
61 size_t k;
62
63- if (!fgets(line, sizeof(line), f)) {
64- if (feof(f))
65- return 0;
66- return -errno;
67- }
68+ r = read_line(f, LONG_LINE_MAX, &line);
69+ if (r < 0)
70+ return log_error_errno(r, "Failed to read serialization line: %m");
71+ if (r == 0)
72+ return 0;
73
74- char_array_0(line);
75 l = strstrip(line);
76
77 /* End marker */
78- if (l[0] == 0)
79+ if (isempty(l))
80 return 0;
81
82 k = strcspn(l, "=");
83diff --git a/src/core/manager.c b/src/core/manager.c
84index e837a46f5..423f82c94 100644
85--- a/src/core/manager.c
86+++ b/src/core/manager.c
87@@ -2841,22 +2841,19 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
88 m->n_reloading++;
89
90 for (;;) {
91- char line[LINE_MAX];
92+ _cleanup_free_ char *line = NULL;
93 const char *val, *l;
94
95- if (!fgets(line, sizeof(line), f)) {
96- if (feof(f))
97- r = 0;
98- else
99- r = -errno;
100-
101+ r = read_line(f, LONG_LINE_MAX, &line);
102+ if (r < 0) {
103+ log_error_errno(r, "Failed to read serialization line: %m");
104 goto finish;
105 }
106+ if (r == 0)
107+ break;
108
109- char_array_0(line);
110 l = strstrip(line);
111-
112- if (l[0] == 0)
113+ if (isempty(l)) /* end marker */
114 break;
115
116 if ((val = startswith(l, "current-job-id="))) {
117@@ -3003,29 +3000,31 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
118 }
119
120 for (;;) {
121- Unit *u;
122- char name[UNIT_NAME_MAX+2];
123+ _cleanup_free_ char *line = NULL;
124 const char* unit_name;
125+ Unit *u;
126
127 /* Start marker */
128- if (!fgets(name, sizeof(name), f)) {
129- if (feof(f))
130- r = 0;
131- else
132- r = -errno;
133-
134+ r = read_line(f, LONG_LINE_MAX, &line);
135+ if (r < 0) {
136+ log_error_errno(r, "Failed to read serialization line: %m");
137 goto finish;
138 }
139+ if (r == 0)
140+ break;
141
142- char_array_0(name);
143- unit_name = strstrip(name);
144+ unit_name = strstrip(line);
145
146 r = manager_load_unit(m, unit_name, NULL, NULL, &u);
147 if (r < 0) {
148 log_notice_errno(r, "Failed to load unit \"%s\", skipping deserialization: %m", unit_name);
149 if (r == -ENOMEM)
150 goto finish;
151- unit_deserialize_skip(f);
152+
153+ r = unit_deserialize_skip(f);
154+ if (r < 0)
155+ goto finish;
156+
157 continue;
158 }
159
160@@ -3038,9 +3037,6 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
161 }
162
163 finish:
164- if (ferror(f))
165- r = -EIO;
166-
167 assert(m->n_reloading > 0);
168 m->n_reloading--;
169
170diff --git a/src/core/unit.c b/src/core/unit.c
171index 932f05baa..4c3aa8e96 100644
172--- a/src/core/unit.c
173+++ b/src/core/unit.c
174@@ -3346,21 +3346,19 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
175 rt = (ExecRuntime**) ((uint8_t*) u + offset);
176
177 for (;;) {
178- char line[LINE_MAX], *l, *v;
179+ _cleanup_free_ char *line = NULL;
180 CGroupIPAccountingMetric m;
181+ char *l, *v;
182 size_t k;
183
184- if (!fgets(line, sizeof(line), f)) {
185- if (feof(f))
186- return 0;
187- return -errno;
188- }
189+ r = read_line(f, LONG_LINE_MAX, &line);
190+ if (r < 0)
191+ return log_error_errno(r, "Failed to read serialization line: %m");
192+ if (r == 0) /* eof */
193+ break;
194
195- char_array_0(line);
196 l = strstrip(line);
197-
198- /* End marker */
199- if (isempty(l))
200+ if (isempty(l)) /* End marker */
201 break;
202
203 k = strcspn(l, "=");
204@@ -3637,23 +3635,27 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
205 return 0;
206 }
207
208-void unit_deserialize_skip(FILE *f) {
209+int unit_deserialize_skip(FILE *f) {
210+ int r;
211 assert(f);
212
213 /* Skip serialized data for this unit. We don't know what it is. */
214
215 for (;;) {
216- char line[LINE_MAX], *l;
217+ _cleanup_free_ char *line = NULL;
218+ char *l;
219
220- if (!fgets(line, sizeof line, f))
221- return;
222+ r = read_line(f, LONG_LINE_MAX, &line);
223+ if (r < 0)
224+ return log_error_errno(r, "Failed to read serialization line: %m");
225+ if (r == 0)
226+ return 0;
227
228- char_array_0(line);
229 l = strstrip(line);
230
231 /* End marker */
232 if (isempty(l))
233- return;
234+ return 1;
235 }
236 }
237
238diff --git a/src/core/unit.h b/src/core/unit.h
239index 8c79d4ed2..08ad1c652 100644
240--- a/src/core/unit.h
241+++ b/src/core/unit.h
242@@ -689,7 +689,7 @@ bool unit_can_serialize(Unit *u) _pure_;
243
244 int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs);
245 int unit_deserialize(Unit *u, FILE *f, FDSet *fds);
246-void unit_deserialize_skip(FILE *f);
247+int unit_deserialize_skip(FILE *f);
248
249 int unit_serialize_item(Unit *u, FILE *f, const char *key, const char *value);
250 int unit_serialize_item_escaped(Unit *u, FILE *f, const char *key, const char *value);
diff --git a/meta/recipes-core/systemd/systemd_237.bb b/meta/recipes-core/systemd/systemd_237.bb
index 36f00af6d2..a75fae2e15 100644
--- a/meta/recipes-core/systemd/systemd_237.bb
+++ b/meta/recipes-core/systemd/systemd_237.bb
@@ -54,6 +54,7 @@ SRC_URI += "file://touchscreen.rules \
54 file://libmount.patch \ 54 file://libmount.patch \
55 file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch \ 55 file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch \
56 file://0035-Define-glibc-compatible-basename-for-non-glibc-syste.patch \ 56 file://0035-Define-glibc-compatible-basename-for-non-glibc-syste.patch \
57 file://0001-core-when-deserializing-state-always-use-read_line-L.patch \
57 " 58 "
58SRC_URI_append_qemuall = " file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch" 59SRC_URI_append_qemuall = " file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch"
59 60