diff -Nru systemd-245.4/debian/changelog systemd-245.4/debian/changelog --- systemd-245.4/debian/changelog 2023-03-27 17:54:06.000000000 +0000 +++ systemd-245.4/debian/changelog 2023-06-26 20:20:43.000000000 +0000 @@ -1,3 +1,10 @@ +systemd (245.4-4ubuntu3.23) focal; urgency=medium + + * Fix mount failures for "mounting" state (LP: #1837227): + - d/p/lp1837227-core-mount-adjust-deserialized-state-based-on-proc-s.patch + + -- Heitor Alves de Siqueira Mon, 26 Jun 2023 20:20:43 +0000 + systemd (245.4-4ubuntu3.22) focal; urgency=medium * resolve: fix potential memleak and use-after-free (LP: #2012943) diff -Nru systemd-245.4/debian/patches/lp1837227-core-mount-adjust-deserialized-state-based-on-proc-s.patch systemd-245.4/debian/patches/lp1837227-core-mount-adjust-deserialized-state-based-on-proc-s.patch --- systemd-245.4/debian/patches/lp1837227-core-mount-adjust-deserialized-state-based-on-proc-s.patch 1970-01-01 00:00:00.000000000 +0000 +++ systemd-245.4/debian/patches/lp1837227-core-mount-adjust-deserialized-state-based-on-proc-s.patch 2023-06-26 20:20:43.000000000 +0000 @@ -0,0 +1,123 @@ +From b7216f1c96542cb6e032f42202848b9c1bdbd993 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 6 Jul 2022 15:15:09 +0900 +Subject: [PATCH] core/mount: adjust deserialized state based on + /proc/self/mountinfo + +Fixes #23796. +Replaces #23803 and #23851. + +Origin: upstream, https://github.com/systemd/systemd/commit/01400460ae16 +Bug: https://github.com/systemd/systemd/issues/23796 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1837227 +Last-Update: 2023-06-26 +--- + src/core/mount.c | 55 +++++++++++++++++++++++++++++++++++++++--------- + 1 file changed, 45 insertions(+), 10 deletions(-) + +diff --git a/src/core/mount.c b/src/core/mount.c +index dbfadc8f1690..229abbd77f53 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -51,6 +51,9 @@ static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = { + + static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata); + static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata); ++static void mount_enter_dead(Mount *m, MountResult f); ++static void mount_enter_mounted(Mount *m, MountResult f); ++static void mount_cycle_clear(Mount *m); + static int mount_process_proc_self_mountinfo(Manager *m); + + static bool MOUNT_STATE_WITH_PROCESS(MountState state) { +@@ -691,23 +694,17 @@ static void mount_set_state(Mount *m, MountState state) { + + static int mount_coldplug(Unit *u) { + Mount *m = MOUNT(u); +- MountState new_state = MOUNT_DEAD; + int r; + + assert(m); + assert(m->state == MOUNT_DEAD); + +- if (m->deserialized_state != m->state) +- new_state = m->deserialized_state; +- else if (m->from_proc_self_mountinfo) +- new_state = MOUNT_MOUNTED; +- +- if (new_state == m->state) ++ if (m->deserialized_state == m->state) + return 0; + + if (m->control_pid > 0 && + pid_is_unwaited(m->control_pid) && +- MOUNT_STATE_WITH_PROCESS(new_state)) { ++ MOUNT_STATE_WITH_PROCESS(m->deserialized_state)) { + + r = unit_watch_pid(UNIT(m), m->control_pid, false); + if (r < 0) +@@ -718,15 +715,52 @@ static int mount_coldplug(Unit *u) { + return r; + } + +- if (!IN_SET(new_state, MOUNT_DEAD, MOUNT_FAILED)) { ++ if (!IN_SET(m->deserialized_state, MOUNT_DEAD, MOUNT_FAILED)) { + (void) unit_setup_dynamic_creds(u); + (void) unit_setup_exec_runtime(u); + } + +- mount_set_state(m, new_state); ++ mount_set_state(m, m->deserialized_state); + return 0; + } + ++static void mount_catchup(Unit *u) { ++ Mount *m = MOUNT(u); ++ ++ assert(m); ++ ++ /* Adjust the deserialized state. See comments in mount_process_proc_self_mountinfo(). */ ++ if (m->from_proc_self_mountinfo) ++ switch (m->state) { ++ case MOUNT_DEAD: ++ case MOUNT_FAILED: ++ assert(m->control_pid == 0); ++ unit_acquire_invocation_id(u); ++ mount_cycle_clear(m); ++ mount_enter_mounted(m, MOUNT_SUCCESS); ++ break; ++ case MOUNT_MOUNTING: ++ assert(m->control_pid > 0); ++ mount_set_state(m, MOUNT_MOUNTING_DONE); ++ break; ++ default: ++ break; ++ } ++ else ++ switch (m->state) { ++ case MOUNT_MOUNTING_DONE: ++ assert(m->control_pid > 0); ++ mount_set_state(m, MOUNT_MOUNTING); ++ break; ++ case MOUNT_MOUNTED: ++ assert(m->control_pid == 0); ++ mount_enter_dead(m, MOUNT_SUCCESS); ++ break; ++ default: ++ break; ++ } ++} ++ + static void mount_dump(Unit *u, FILE *f, const char *prefix) { + char buf[FORMAT_TIMESPAN_MAX]; + Mount *m = MOUNT(u); +@@ -2092,6 +2126,7 @@ const UnitVTable mount_vtable = { + .done = mount_done, + + .coldplug = mount_coldplug, ++ .catchup = mount_catchup, + + .dump = mount_dump, + +-- +2.41.0 + diff -Nru systemd-245.4/debian/patches/series systemd-245.4/debian/patches/series --- systemd-245.4/debian/patches/series 2023-03-27 17:54:06.000000000 +0000 +++ systemd-245.4/debian/patches/series 2023-06-26 20:20:43.000000000 +0000 @@ -194,3 +194,4 @@ lp2002445-udev-attempt-device-rename-even-if-interface-is-up.patch lp1933090-test-seccomp-accept-ENOSYS-from-sysctl-2-too.patch lp2012943-resolve-fix-potential-memleak-and-use-after-free.patch +lp1837227-core-mount-adjust-deserialized-state-based-on-proc-s.patch