]> git.ipfire.org Git - thirdparty/systemd.git/commit
journal-file: let's make journal_file_copy_entry() robust against concurrent writing... 37732/head
authorLennart Poettering <lennart@poettering.net>
Wed, 4 Jun 2025 15:00:29 +0000 (17:00 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 4 Jun 2025 16:05:58 +0000 (18:05 +0200)
commit9151a60a4e0c36bcf06463a78ad3e81b9bcbf47c
treebc510936a91c8fccaa66afe77d063d449a845639
parente74c1e1cac587fb5832ab46d709913c0f3792ff0
journal-file: let's make journal_file_copy_entry() robust against concurrent writing of the source

As usual, we need to protect ourselves against concurrent modification
of journal files. We a pretty good at that these days when reading
journal files. But journal_file_copy_entry() so far wasn't too good with
that. journal_file_append_data() so far returned EINVAL when you pass
invalid data to it. Since we pass the source data as-is in there, it's
going to fail if the journal source file is slightly invalid due to a
concurrent update.

Hence, we need to validate data gracefully here that we think comes from
a safe place, because actually it doesn't, it's directly copied from an
unsafe journal file.

Hence, let's introduce a clear error code here, and look for it in
journal_file_copy_entry(), and handle it gracefully.

Pretty sure this fixes #33372, but it's a race, so I don't know for
sure. If this remains reproducible we need to look at this again.

Fixes: #33372
src/libsystemd/sd-journal/journal-file.c