Skip to content

Commit

Permalink
core: fix unnecessary fallback to the rescue mode caused by initrd-sw…
Browse files Browse the repository at this point in the history
…itch-root.service's exit status judgment error

commit 1f0958f ("core: when determining whether a process exit
status is clean, consider whether it is a command or a daemon")
introduces a side effect that causes system falls into rescure mode
due initrd-switch-root.service entered failed state, detailed
information should refer to the redhat's doc, as follows:
https://access.redhat.com/solutions/4973191
https://bugzilla.redhat.com/show_bug.cgi?id=1414904

As we know that in the cloud computing scenarios, some very critical
services may run on the server, and the server may run continuously for
several years without restarting.The initramfske may still maintain the
original state many years ago without any changes. In addition, this
server may have been installed a lot of user mode programs and kernel
mode drivers due to various operations and maintenance over the years.

If the initramfs is regenerated because of upgrading systemd, the user-mode
programs or drivers previously installed may be inserted into the initramfs,
introducing unknown risks, and may even cause the system to fail to start.
So we hope that this patch may avoid the above issues.

Resolves: #1825232
  • Loading branch information
w-simon authored and systemd-rhel-bot committed Sep 30, 2020
1 parent 20fb522 commit ec8955e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/service.c
Expand Up @@ -2644,6 +2644,15 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
else
assert_not_reached("Unknown code");

/* Here's a special hack: avoid a timing issue caused by switching
* root when the initramfs contains an old systemd binary.
*
* https://bugzilla.redhat.com/show_bug.cgi?id=1855149
* https://bugzilla.redhat.com/show_bug.cgi?id=1825232 */
if (f != SERVICE_SUCCESS && status == SIGTERM &&
unit_has_name(UNIT(s), SPECIAL_INITRD_SWITCH_ROOT_SERVICE))
f = SERVICE_SUCCESS;

if (s->main_pid == pid) {
/* Forking services may occasionally move to a new PID.
* As long as they update the PID file before exiting the old
Expand Down
1 change: 1 addition & 0 deletions src/shared/special.h
Expand Up @@ -96,6 +96,7 @@
#define SPECIAL_QUOTACHECK_SERVICE "systemd-quotacheck.service"
#define SPECIAL_QUOTAON_SERVICE "quotaon.service"
#define SPECIAL_REMOUNT_FS_SERVICE "systemd-remount-fs.service"
#define SPECIAL_INITRD_SWITCH_ROOT_SERVICE "initrd-switch-root.service"

/* Services systemd relies on */
#define SPECIAL_DBUS_SERVICE "dbus.service"
Expand Down

0 comments on commit ec8955e

Please sign in to comment.