daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
ff6046
From a4d1779b5ee28b1c27c509a1baebf881943cad1b Mon Sep 17 00:00:00 2001
ff6046
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
ff6046
Date: Wed, 5 Dec 2018 22:52:53 +0100
ff6046
Subject: [PATCH] =?UTF-8?q?journald:=20lower=20the=20maximum=20entry=20siz?=
ff6046
 =?UTF-8?q?e=20limit=20to=20=C2=BD=20for=20non-sealed=20fds?=
ff6046
MIME-Version: 1.0
ff6046
Content-Type: text/plain; charset=UTF-8
ff6046
Content-Transfer-Encoding: 8bit
ff6046
ff6046
We immediately read the whole contents into memory, making thigs much more
ff6046
expensive. Sealed fds should be used instead since they are more efficient
ff6046
on our side.
ff6046
ff6046
(cherry-picked from commit 6670c9de196c8e2d5e84a8890cbb68f70c4db6e3)
ff6046
ff6046
Related: #1664977
ff6046
---
ff6046
 src/journal/journald-native.c | 6 ++++--
ff6046
 1 file changed, 4 insertions(+), 2 deletions(-)
ff6046
ff6046
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
ff6046
index 110ab3641c..da62448ca6 100644
ff6046
--- a/src/journal/journald-native.c
ff6046
+++ b/src/journal/journald-native.c
ff6046
@@ -380,8 +380,10 @@ void server_process_native_file(
ff6046
         if (st.st_size <= 0)
ff6046
                 return;
ff6046
 
ff6046
-        if (st.st_size > ENTRY_SIZE_MAX) {
ff6046
-                log_error("File passed too large. Ignoring.");
ff6046
+        /* When !sealed, set a lower memory limit. We have to read the file,
ff6046
+         * effectively doubling memory use. */
ff6046
+        if (st.st_size > ENTRY_SIZE_MAX / (sealed ? 1 : 2)) {
ff6046
+                log_error("File passed too large (%"PRIu64" bytes). Ignoring.", (uint64_t) st.st_size);
ff6046
                 return;
ff6046
         }
ff6046