From 6fa36901c6b19330d2bbfd231ebef4b5171f3e50 Mon Sep 17 00:00:00 2001
From: msizanoen <msizanoen@qtmlabs.xyz>
Date: Wed, 30 Aug 2023 20:11:42 +0700
Subject: [PATCH] journal: Don't write to journal files without the new boot ID
 update behavior guarantee

With the old boot ID update behavior there's no way to compare the boot
ID of a new entry to be written with the boot ID of the last entry in
the journal in a performant manner, and therefore no way to determine if
monotonic clock value consistency checking is needed. Refuse to open
journal files without the new boot ID update behavior guarantee to
simplify consistency checking.

(cherry picked from commit 2f766aca1e1398288e01b26a69eb02a7b831ab00)
---
 src/libsystemd/sd-journal/journal-file.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
index 3af463eb04..2ac1a5bad8 100644
--- a/src/libsystemd/sd-journal/journal-file.c
+++ b/src/libsystemd/sd-journal/journal-file.c
@@ -572,6 +572,10 @@ static int journal_file_verify_header(JournalFile *f) {
         if (journal_file_writable(f) && header_size != sizeof(Header))
                 return -EPROTONOSUPPORT;
 
+        /* Don't write to journal files without the new boot ID update behavior guarantee. */
+        if (journal_file_writable(f) && !JOURNAL_HEADER_TAIL_ENTRY_BOOT_ID(f->header))
+                return -EPROTONOSUPPORT;
+
         if (JOURNAL_HEADER_SEALED(f->header) && !JOURNAL_HEADER_CONTAINS(f->header, n_entry_arrays))
                 return -EBADMSG;
 
-- 
GitLab