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