]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: lower the maximum entry size limit to ½ for non-sealed fds
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 Dec 2018 21:52:53 +0000 (22:52 +0100)
committerLukáš Nykrýn <lnykryn@redhat.com>
Mon, 11 Feb 2019 09:51:14 +0000 (10:51 +0100)
We immediately read the whole contents into memory, making thigs much more
expensive. Sealed fds should be used instead since they are more efficient
on our side.

(cherry-picked from commit 6670c9de196c8e2d5e84a8890cbb68f70c4db6e3)

Related: #1664977

src/journal/journald-native.c

index 110ab3641cdcef95fa5ec404a26f8973fe5833e2..da62448ca610b3941c0da838344c2d681806473a 100644 (file)
@@ -380,8 +380,10 @@ void server_process_native_file(
         if (st.st_size <= 0)
                 return;
 
-        if (st.st_size > ENTRY_SIZE_MAX) {
-                log_error("File passed too large. Ignoring.");
+        /* When !sealed, set a lower memory limit. We have to read the file,
+         * effectively doubling memory use. */
+        if (st.st_size > ENTRY_SIZE_MAX / (sealed ? 1 : 2)) {
+                log_error("File passed too large (%"PRIu64" bytes). Ignoring.", (uint64_t) st.st_size);
                 return;
         }