diff --git a/backport-Use-correct-poll.h-include.patch b/backport-Use-correct-poll.h-include.patch new file mode 100644 index 0000000..c93cc63 --- /dev/null +++ b/backport-Use-correct-poll.h-include.patch @@ -0,0 +1,43 @@ +From 99236971acc52455df51226996fbe71ecedc2f6f Mon Sep 17 00:00:00 2001 +From: David Seifert +Date: Mon, 2 Aug 2021 16:09:10 +0200 +Subject: [PATCH] Use correct `` include + +* `` is not specified in POSIX + +(cherry picked from commit 2b6c0bb2a341c95223ce672249e43c743b03d78c) +(cherry picked from commit fba9fd963bb3b5fafdb123788b3fabe6ed0830c9) + +Reference: https://github.com/systemd/systemd-stable/commit/99236971acc52455df51226996fbe71ecedc2f6f +Conflict: adapt context +--- + src/shared/nscd-flush.c | 2 +- + src/shared/varlink.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/shared/nscd-flush.c b/src/shared/nscd-flush.c +index dfc47c4234..19e16d9345 100644 +--- a/src/shared/nscd-flush.c ++++ b/src/shared/nscd-flush.c +@@ -1,5 +1,5 @@ + /* SPDX-License-Identifier: LGPL-2.1+ */ +-#include ++#include + + #include "fd-util.h" + #include "io-util.h" +diff --git a/src/shared/varlink.c b/src/shared/varlink.c +index b9da917310..b887cb1ba4 100644 +--- a/src/shared/varlink.c ++++ b/src/shared/varlink.c +@@ -1,6 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1+ */ + +-#include ++#include + + #include "alloc-util.h" + #include "errno-util.h" +-- +2.27.0 + diff --git a/backport-core-do-not-serialize-mounts-and-automounts-for-swit.patch b/backport-core-do-not-serialize-mounts-and-automounts-for-swit.patch new file mode 100644 index 0000000..511123c --- /dev/null +++ b/backport-core-do-not-serialize-mounts-and-automounts-for-swit.patch @@ -0,0 +1,136 @@ +From 0dc4f1b0910d7b96ea9743493db7fd2d841164da Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Thu, 3 Jun 2021 19:40:01 +0200 +Subject: [PATCH] core: do not serialize mounts and automounts for switch-root + +When e.g. tmp.mount is present in the initrd, and we serialize it, switch root, +and deserialize, the new systemd is confused because it thinks /tmp is mounted. +In general, it doesn't make sense to serialize anything that refers to paths in +the old root file system. + +This fixes two errors for me: + +1. tmp.mount was not mounted properly before local-fs.target. It would be +mounted as some point (I guess when we re-read /proc/self/mountinfo for some +other reason). In effect systemd-tmpfiles-setup.service would see one fs, and +some other units started later a different one. In particular gdm.service would +fail because the pre-created /tmp/.X11-unix with proper permissions would not +exist at time it was started. + +2. # systemd[1]: proc-sys-fs-binfmt_misc.automount: Got hangup/error on autofs pipe from kernel. Likely our automount point has been unmounted by someone or something else? + # systemd[1]: proc-sys-fs-binfmt_misc.automount: Failed with result 'unmounted'. + # systemd[1]: Mounting proc-sys-fs-binfmt_misc.mount... + # systemd[1]: Mounted proc-sys-fs-binfmt_misc.mount. + # systemd[1]: Starting systemd-binfmt.service... + # systemd[1]: Finished systemd-binfmt.service. + # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start. + # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount. + # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start. + # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount. + # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start. + # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount. + # systemd[1]: Stopping systemd-binfmt.service... + # systemd[1]: systemd-binfmt.service: Deactivated successfully. + # systemd[1]: Stopped systemd-binfmt.service. + +I couldn't understand the error here, but in retrospect the first line is entirely +correct: "someone or something else" was the old systemd unmounting the old root. + +(cherry picked from commit 755021d43448011ef169f20ec3a08d4e92c824af) + +Reference: https://github.com/systemd/systemd-stable/commit/0dc4f1b0910d7b96ea9743493db7fd2d841164da +Conflict: adapt context +--- + src/core/manager.c | 6 +----- + src/core/mount.c | 1 + + src/core/unit.c | 16 ++++++++++++++-- + src/core/unit.h | 3 +++ + 4 files changed, 19 insertions(+), 7 deletions(-) + +diff --git a/src/core/manager.c b/src/core/manager.c +index cfeaca6..722e4e6 100644 +--- a/src/core/manager.c ++++ b/src/core/manager.c +@@ -3255,11 +3255,7 @@ int manager_serialize( + if (u->id != t) + continue; + +- /* Start marker */ +- fputs(u->id, f); +- fputc('\n', f); +- +- r = unit_serialize(u, f, fds, !switching_root); ++ r = unit_serialize(u, f, fds, switching_root); + if (r < 0) + return r; + } +diff --git a/src/core/mount.c b/src/core/mount.c +index 1b64011..3a6c220 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -1981,6 +1981,7 @@ const UnitVTable mount_vtable = { + "Mount\0" + "Install\0", + .private_section = "Mount", ++ .exclude_from_switch_root_serialization = true, + + .init = mount_init, + .load = mount_load, +diff --git a/src/core/unit.c b/src/core/unit.c +index c8cf9ee..fa8489c 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -3376,7 +3376,7 @@ static const char *const io_accounting_metric_field_last[_CGROUP_IO_ACCOUNTING_M + [CGROUP_IO_WRITE_OPERATIONS] = "io-accounting-write-operations-last", + }; + +-int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) { ++int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool switching_root) { + CGroupIPAccountingMetric m; + int r; + +@@ -3384,6 +3384,18 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) { + assert(f); + assert(fds); + ++ if (switching_root && UNIT_VTABLE(u)->exclude_from_switch_root_serialization) { ++ /* In the new root, paths for mounts and automounts will be different, so it doesn't make ++ * much sense to serialize things. API file systems will be moved to the new root, but we ++ * don't have mount units for those. */ ++ log_unit_debug(u, "not serializing before switch-root"); ++ return 0; ++ } ++ ++ /* Start marker */ ++ fputs(u->id, f); ++ fputc('\n', f); ++ + if (unit_can_serialize(u)) { + r = UNIT_VTABLE(u)->serialize(u, f, fds); + if (r < 0) +@@ -3455,7 +3467,7 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) { + (void) serialize_item_format(f, ip_accounting_metric_field[m], "%" PRIu64, v); + } + +- if (serialize_jobs) { ++ if (!switching_root) { + if (u->job) { + fputs("job\n", f); + job_serialize(u->job, f); +diff --git a/src/core/unit.h b/src/core/unit.h +index bb5e782..cb70325 100644 +--- a/src/core/unit.h ++++ b/src/core/unit.h +@@ -602,6 +602,9 @@ typedef struct UnitVTable { + /* True if units of this type shall be startable only once and then never again */ + bool once_only:1; + ++ /* Do not serialize this unit when preparing for root switch */ ++ bool exclude_from_switch_root_serialization; ++ + /* True if queued jobs of this type should be GC'ed if no other job needs them anymore */ + bool gc_jobs:1; + } UnitVTable; +-- +2.27.0 + diff --git a/backport-journal-add-some-careful-overflow-checking.patch b/backport-journal-add-some-careful-overflow-checking.patch new file mode 100644 index 0000000..2b7d27e --- /dev/null +++ b/backport-journal-add-some-careful-overflow-checking.patch @@ -0,0 +1,57 @@ +From 84e1819ec104a168f7904134b6212669133c955f Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 8 Jun 2021 22:14:40 +0200 +Subject: [PATCH] journal: add some careful overflow checking + +(cherry picked from commit d8671b1c6f036ce270b9631973314e7de24e74b1) + +Reference: https://github.com/systemd/systemd-stable/commit/84e1819ec104a168f7904134b6212669133c955f +Conflict: adapt context +--- + src/journal/sd-journal.c | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c +index 02ac260..244ea91 100644 +--- a/src/journal/sd-journal.c ++++ b/src/journal/sd-journal.c +@@ -2761,25 +2761,33 @@ void journal_print_header(sd_journal *j) { + } + } + +-_public_ int sd_journal_get_usage(sd_journal *j, uint64_t *bytes) { ++_public_ int sd_journal_get_usage(sd_journal *j, uint64_t *ret) { + Iterator i; + JournalFile *f; + uint64_t sum = 0; + + assert_return(j, -EINVAL); + assert_return(!journal_pid_changed(j), -ECHILD); +- assert_return(bytes, -EINVAL); ++ assert_return(ret, -EINVAL); + + ORDERED_HASHMAP_FOREACH(f, j->files, i) { + struct stat st; ++ uint64_t b; + + if (fstat(f->fd, &st) < 0) + return -errno; + +- sum += (uint64_t) st.st_blocks * 512ULL; ++ b = (uint64_t) st.st_blocks; ++ if (b > UINT64_MAX / 512) ++ return -EOVERFLOW; ++ b *= 512; ++ ++ if (sum > UINT64_MAX - b) ++ return -EOVERFLOW; ++ sum += b; + } + +- *bytes = sum; ++ *ret = sum; + return 0; + } + +-- +2.27.0 diff --git a/backport-network-fix-an-infinite-loop.patch b/backport-network-fix-an-infinite-loop.patch new file mode 100644 index 0000000..01841b8 --- /dev/null +++ b/backport-network-fix-an-infinite-loop.patch @@ -0,0 +1,35 @@ +From b234ee7859de556c272c36fc691cee4cb08f7230 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Thu, 20 May 2021 16:14:17 +0900 +Subject: [PATCH] network: fix an infinite loop + +Fixes #19467. + +(cherry picked from commit e8f99f4e249916e12c09ee5cc9a108cba6a2b5c0) + +Reference: https://github.com/systemd/systemd-stable/commit/b234ee7859de556c272c36fc691cee4cb08f7230 +Conflict: adapt context +--- + src/network/networkd-link.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c +index 8219d95b0d..c781dd58d7 100644 +--- a/src/network/networkd-link.c ++++ b/src/network/networkd-link.c +@@ -157,6 +157,12 @@ static void link_update_master_operstate(Link *link, NetDev *netdev) { + if (!netdev) + return; + ++ /* If an interface is self-mentioned in Bridge= or friends, then it introduces an infinite loop. ++ * FIXME: there still exits a possibility of an infinite loop when two or more interfaces ++ * mention each other in Bridge= or so. We need to detect such a loop. */ ++ if (link->ifindex == netdev->ifindex) ++ return; ++ + if (link_get(link->manager, netdev->ifindex, &master) < 0) + return; + +-- +2.27.0 + diff --git a/backport-sd-device-use-right-type-for-usec_initialized.patch b/backport-sd-device-use-right-type-for-usec_initialized.patch new file mode 100644 index 0000000..d182492 --- /dev/null +++ b/backport-sd-device-use-right-type-for-usec_initialized.patch @@ -0,0 +1,29 @@ +From d6b0efcdd83a937363267ed751fd9a1085505394 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 20 Apr 2021 17:06:21 +0200 +Subject: [PATCH] sd-device: use right type for usec_initialized + +(cherry picked from commit a156eb89c827206ee5b51d53016ba63be0c90449) + +Reference: https://github.com/systemd/systemd-stable/commit/d6b0efcdd83a937363267ed751fd9a1085505394 +Conflict: NA +--- + src/libsystemd/sd-device/device-internal.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/libsystemd/sd-device/device-internal.h b/src/libsystemd/sd-device/device-internal.h +index c1a81e3b41..c7f9b59087 100644 +--- a/src/libsystemd/sd-device/device-internal.h ++++ b/src/libsystemd/sd-device/device-internal.h +@@ -69,7 +69,7 @@ struct sd_device { + + char *id_filename; + +- uint64_t usec_initialized; ++ usec_t usec_initialized; + + mode_t devmode; + uid_t devuid; +-- +2.27.0 + diff --git a/systemd.spec b/systemd.spec index e981e59..ca6e1b4 100644 --- a/systemd.spec +++ b/systemd.spec @@ -16,7 +16,7 @@ Name: systemd Url: https://www.freedesktop.org/wiki/Software/systemd Version: 243 -Release: 57 +Release: 58 License: MIT and LGPLv2+ and GPLv2+ Summary: System and Service Manager @@ -181,6 +181,11 @@ Patch0133: backport-udev-re-assign-ID_NET_DRIVER-ID_NET_LINK_FILE-ID_NET.pa Patch0134: backport-udev-allow-to-match-OriginalName-with-renamed-interf.patch Patch0135: backport-udev-do-not-update-return-value-on-failure.patch Patch0136: backport-test-add-test-for-device-renaming-issue-16967.patch +Patch0137: backport-Use-correct-poll.h-include.patch +Patch0138: backport-core-do-not-serialize-mounts-and-automounts-for-swit.patch +Patch0139: backport-journal-add-some-careful-overflow-checking.patch +Patch0140: backport-network-fix-an-infinite-loop.patch +Patch0141: backport-sd-device-use-right-type-for-usec_initialized.patch #openEuler @@ -1589,6 +1594,9 @@ fi %exclude /usr/share/man/man3/* %changelog +* Tue Oct 18 2022 yangmingtai - 243-58 +- DESC:sync community patches + * Wed Sep 7 2022 yangmingtai - 243-57 - delete rpath