summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-core/systemd/systemd/0025-journald-set-a-limit-on-the-number-of-fields-1k.patch56
-rw-r--r--meta/recipes-core/systemd/systemd/0026-journal-remote-set-a-limit-on-the-number-of-fields-i.patch84
-rw-r--r--meta/recipes-core/systemd/systemd_239.bb2
3 files changed, 142 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0025-journald-set-a-limit-on-the-number-of-fields-1k.patch b/meta/recipes-core/systemd/systemd/0025-journald-set-a-limit-on-the-number-of-fields-1k.patch
new file mode 100644
index 0000000000..50a01efe8f
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0025-journald-set-a-limit-on-the-number-of-fields-1k.patch
@@ -0,0 +1,56 @@
1From 4566aaf97f5b4143b930d75628f3abc905249dcd Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
3Date: Wed, 5 Dec 2018 22:45:02 +0100
4Subject: [PATCH] journald: set a limit on the number of fields (1k)
5
6We allocate a iovec entry for each field, so with many short entries,
7our memory usage and processing time can be large, even with a relatively
8small message size. Let's refuse overly long entries.
9
10CVE-2018-16865
11https://bugzilla.redhat.com/show_bug.cgi?id=1653861
12
13What from I can see, the problem is not from an alloca, despite what the CVE
14description says, but from the attack multiplication that comes from creating
15many very small iovecs: (void* + size_t) for each three bytes of input message.
16
17Patch backported from systemd master at
18052c57f132f04a3cf4148f87561618da1a6908b4.
19---
20 src/basic/journal-importer.h | 3 +++
21 src/journal/journald-native.c | 5 +++++
22 2 files changed, 8 insertions(+)
23
24diff --git a/src/basic/journal-importer.h b/src/basic/journal-importer.h
25index f49ce734a1..c4ae45d32d 100644
26--- a/src/basic/journal-importer.h
27+++ b/src/basic/journal-importer.h
28@@ -16,6 +16,9 @@
29 #define DATA_SIZE_MAX (1024*1024*768u)
30 #define LINE_CHUNK 8*1024u
31
32+/* The maximum number of fields in an entry */
33+#define ENTRY_FIELD_COUNT_MAX 1024
34+
35 struct iovec_wrapper {
36 struct iovec *iovec;
37 size_t size_bytes;
38diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
39index 5ff22a10af..951d092053 100644
40--- a/src/journal/journald-native.c
41+++ b/src/journal/journald-native.c
42@@ -140,6 +140,11 @@ static int server_process_entry(
43 }
44
45 /* A property follows */
46+ if (n > ENTRY_FIELD_COUNT_MAX) {
47+ log_debug("Received an entry that has more than " STRINGIFY(ENTRY_FIELD_COUNT_MAX) " fields, ignoring entry.");
48+ r = 1;
49+ goto finish;
50+ }
51
52 /* n existing properties, 1 new, +1 for _TRANSPORT */
53 if (!GREEDY_REALLOC(iovec, m,
54--
552.11.0
56
diff --git a/meta/recipes-core/systemd/systemd/0026-journal-remote-set-a-limit-on-the-number-of-fields-i.patch b/meta/recipes-core/systemd/systemd/0026-journal-remote-set-a-limit-on-the-number-of-fields-i.patch
new file mode 100644
index 0000000000..104945cc25
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0026-journal-remote-set-a-limit-on-the-number-of-fields-i.patch
@@ -0,0 +1,84 @@
1From 4183ec3a135663128834ca8b35d50a60999343a7 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
3Date: Fri, 7 Dec 2018 10:48:10 +0100
4Subject: [PATCH] journal-remote: set a limit on the number of fields in a
5 message
6
7Existing use of E2BIG is replaced with ENOBUFS (entry too long), and E2BIG is
8reused for the new error condition (too many fields).
9
10This matches the change done for systemd-journald, hence forming the second
11part of the fix for CVE-2018-16865
12(https://bugzilla.redhat.com/show_bug.cgi?id=1653861).
13
14Patch backported from systemd master at
15ef4d6abe7c7fab6cbff975b32e76b09feee56074.
16---
17 src/basic/journal-importer.c | 5 ++++-
18 src/journal-remote/journal-remote-main.c | 10 ++++++----
19 src/journal-remote/journal-remote.c | 5 ++++-
20 3 files changed, 14 insertions(+), 6 deletions(-)
21
22diff --git a/src/basic/journal-importer.c b/src/basic/journal-importer.c
23index ca203bbbfc..3ac55a66d9 100644
24--- a/src/basic/journal-importer.c
25+++ b/src/basic/journal-importer.c
26@@ -23,6 +23,9 @@ enum {
27 };
28
29 static int iovw_put(struct iovec_wrapper *iovw, void* data, size_t len) {
30+ if (iovw->count >= ENTRY_FIELD_COUNT_MAX)
31+ return -E2BIG;
32+
33 if (!GREEDY_REALLOC(iovw->iovec, iovw->size_bytes, iovw->count + 1))
34 return log_oom();
35
36@@ -98,7 +101,7 @@ static int get_line(JournalImporter *imp, char **line, size_t *size) {
37 imp->scanned = imp->filled;
38 if (imp->scanned >= DATA_SIZE_MAX) {
39 log_error("Entry is bigger than %u bytes.", DATA_SIZE_MAX);
40- return -E2BIG;
41+ return -ENOBUFS;
42 }
43
44 if (imp->passive_fd)
45diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
46index 8fda9d1499..f52618fb7b 100644
47--- a/src/journal-remote/journal-remote-main.c
48+++ b/src/journal-remote/journal-remote-main.c
49@@ -212,10 +212,12 @@ static int process_http_upload(
50 break;
51 else if (r < 0) {
52 log_warning("Failed to process data for connection %p", connection);
53- if (r == -E2BIG)
54- return mhd_respondf(connection,
55- r, MHD_HTTP_PAYLOAD_TOO_LARGE,
56- "Entry is too large, maximum is " STRINGIFY(DATA_SIZE_MAX) " bytes.");
57+ if (r == -ENOBUFS)
58+ log_warning_errno(r, "Entry is above the maximum of %u, aborting connection %p.",
59+ DATA_SIZE_MAX, connection);
60+ else if (r == -E2BIG)
61+ log_warning_errno(r, "Entry with more fields than the maximum of %u, aborting connection %p.",
62+ ENTRY_FIELD_COUNT_MAX, connection);
63 else
64 return mhd_respondf(connection,
65 r, MHD_HTTP_UNPROCESSABLE_ENTITY,
66diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
67index beb75a1cb4..67e3a70c06 100644
68--- a/src/journal-remote/journal-remote.c
69+++ b/src/journal-remote/journal-remote.c
70@@ -408,7 +408,10 @@ int journal_remote_handle_raw_source(
71 log_debug("%zu active sources remaining", s->active);
72 return 0;
73 } else if (r == -E2BIG) {
74- log_notice_errno(E2BIG, "Entry too big, skipped");
75+ log_notice("Entry with too many fields, skipped");
76+ return 1;
77+ } else if (r == -ENOBUFS) {
78+ log_notice("Entry too big, skipped");
79 return 1;
80 } else if (r == -EAGAIN) {
81 return 0;
82--
832.11.0
84
diff --git a/meta/recipes-core/systemd/systemd_239.bb b/meta/recipes-core/systemd/systemd_239.bb
index 034ed0b563..54f14d2805 100644
--- a/meta/recipes-core/systemd/systemd_239.bb
+++ b/meta/recipes-core/systemd/systemd_239.bb
@@ -39,6 +39,8 @@ SRC_URI += "file://touchscreen.rules \
39 file://0002-core-Fix-use-after-free-case-in-load_from_path.patch \ 39 file://0002-core-Fix-use-after-free-case-in-load_from_path.patch \
40 file://0001-meson-rename-Ddebug-to-Ddebug-extra.patch \ 40 file://0001-meson-rename-Ddebug-to-Ddebug-extra.patch \
41 file://0024-journald-do-not-store-the-iovec-entry-for-process-co.patch \ 41 file://0024-journald-do-not-store-the-iovec-entry-for-process-co.patch \
42 file://0025-journald-set-a-limit-on-the-number-of-fields-1k.patch \
43 file://0026-journal-remote-set-a-limit-on-the-number-of-fields-i.patch \
42 " 44 "
43 45
44# patches made for musl are only applied on TCLIBC is musl 46# patches made for musl are only applied on TCLIBC is musl