diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0026-journal-remote-set-a-limit-on-the-number-of-fields-i.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0026-journal-remote-set-a-limit-on-the-number-of-fields-i.patch | 84 |
1 files changed, 84 insertions, 0 deletions
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 @@ | |||
1 | From 4183ec3a135663128834ca8b35d50a60999343a7 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl> | ||
3 | Date: Fri, 7 Dec 2018 10:48:10 +0100 | ||
4 | Subject: [PATCH] journal-remote: set a limit on the number of fields in a | ||
5 | message | ||
6 | |||
7 | Existing use of E2BIG is replaced with ENOBUFS (entry too long), and E2BIG is | ||
8 | reused for the new error condition (too many fields). | ||
9 | |||
10 | This matches the change done for systemd-journald, hence forming the second | ||
11 | part of the fix for CVE-2018-16865 | ||
12 | (https://bugzilla.redhat.com/show_bug.cgi?id=1653861). | ||
13 | |||
14 | Patch backported from systemd master at | ||
15 | ef4d6abe7c7fab6cbff975b32e76b09feee56074. | ||
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 | |||
22 | diff --git a/src/basic/journal-importer.c b/src/basic/journal-importer.c | ||
23 | index 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) | ||
45 | diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c | ||
46 | index 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, | ||
66 | diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c | ||
67 | index 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 | -- | ||
83 | 2.11.0 | ||
84 | |||