!264 [sync] PR-261: systemd: solve that rsyslog reads journal's object of size 0

From: @openeuler-sync-bot 
Reviewed-by: @overweight 
Signed-off-by: @overweight
This commit is contained in:
openeuler-ci-bot 2022-04-12 07:46:14 +00:00 committed by Gitee
commit 17da2fbd2a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 71 additions and 1 deletions

View File

@ -0,0 +1,66 @@
From 6aa35d7d911b6895043f222293703ef7cf60aca1 Mon Sep 17 00:00:00 2001
From: yefei25 <yefei25@huawei.com>
Date: Thu, 5 Mar 2020 21:45:36 +0800
Subject: [PATCH] systemd: solve that rsyslog reads journal's object of
size 0
Signed-off-by: yefei25 <yefei25@huawei.com>
---
src/libsystemd/sd-journal/journal-file.c | 3 ++-
src/libsystemd/sd-journal/sd-journal.c | 9 +++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
index 220717d..221f8c4 100644
--- a/src/libsystemd/sd-journal/journal-file.c
+++ b/src/libsystemd/sd-journal/journal-file.c
@@ -895,8 +895,9 @@ static int journal_file_check_object(JournalFile *f, uint64_t offset, Object *o)
le64toh(o->tag.epoch), offset);
break;
+ default:
+ return -EBADMSG;
}
-
return 0;
}
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index d08b51e..489144b 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -127,6 +127,10 @@ static void init_location(Location *l, LocationType type, JournalFile *f, Object
assert(IN_SET(type, LOCATION_DISCRETE, LOCATION_SEEK));
assert(f);
+ if(o->object.type != OBJECT_ENTRY || o->object.size == 0){
+ return;
+ }
+
*l = (Location) {
.type = type,
.seqnum = le64toh(o->entry.seqnum),
@@ -856,7 +860,8 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
return r;
set_location(j, new_file, o);
-
+ if(o->object.size == 0)
+ return -EBADMSG;
return 1;
}
@@ -2300,7 +2305,7 @@ static int return_data(sd_journal *j, JournalFile *f, Object *o, const void **da
assert(f);
l = le64toh(READ_NOW(o->object.size));
- if (l < offsetof(Object, data.payload))
+ if (l == 0 || o->object.type == 0 || l < offsetof(Object, data.payload))
return -EBADMSG;
l -= offsetof(Object, data.payload);
--
2.19.1

View File

@ -20,7 +20,7 @@
Name: systemd
Url: https://www.freedesktop.org/wiki/Software/systemd
Version: 249
Release: 21
Release: 22
License: MIT and LGPLv2+ and GPLv2+
Summary: System and Service Manager
@ -70,6 +70,7 @@ Patch0021: 0021-activation-service-must-be-restarted-when-reactivated.patch
Patch0022: 0022-systemd-core-fix-problem-of-dbus-service-can-not-be-started.patch
Patch0023: 0023-delay-to-restart-when-a-service-can-not-be-auto-restarted.patch
Patch0024: 0024-disable-initialize_clock.patch
Patch0025: 0025-systemd-solve-that-rsyslog-reads-journal-s-object-of.patch
#backport
Patch6000: backport-core-fix-free-undefined-pointer-when-strdup-failed-i.patch
@ -1501,6 +1502,9 @@ fi
%{_libdir}/security/pam_systemd.so
%changelog
* Mon Apr 11 2022 xujing <xujing99@huawei.com> - 249-22
- solve that rsyslog reads journal's object of size 0
* Mon Apr 11 2022 xujing <xujing99@huawei.com> - 249-21
- disable initialize_clock