Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From b0b4622a8917cf86bcbee881b8b68aeea166ecbb Mon Sep 17 00:00:00 2001
From: Dominique Martinet <asmadeus@codewreck.org>
Date: Wed, 24 Nov 2021 22:27:22 +0900
Subject: [PATCH] unit_is_bound_by_inactive: fix return pointer check

*ret_culprit should be set if ret_culprit has been passed a non-null value,
checking the previous *ret_culprit value does not make sense.

This would cause the culprit to not properly be assigned, leading to
pid1 crash when a unit could not be stopped.

Fixes: #21476
(cherry picked from commit 3da361064bf550d1818c7cd800a514326058e5f2)
---
src/core/unit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/core/unit.c b/src/core/unit.c
index 69ed43578e34..b0a8e7bc3d1d 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2125,7 +2125,7 @@ bool unit_is_bound_by_inactive(Unit *u, Unit **ret_culprit) {
continue;

if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) {
- if (*ret_culprit)
+ if (ret_culprit)
*ret_culprit = other;

return true;
--
2.31.1

4 changes: 4 additions & 0 deletions pkgs/os-specific/linux/systemd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ stdenv.mkDerivation {
# systemd-stable
./0020-sd-boot-Unify-error-handling.patch
./0021-sd-boot-Rework-console-input-handling.patch

# Fix pid1 segfault encountered on nixos-rebuild switch
# https://github.com/systemd/systemd/issues/21476
./0022-unit_is_bound_by_inactive-fix-return-pointer-check.patch
] ++ lib.optional stdenv.hostPlatform.isMusl (let
oe-core = fetchzip {
url = "https://git.openembedded.org/openembedded-core/snapshot/openembedded-core-14c6e5a4b72d0e4665279158a0740dd1dc21f72f.tar.bz2";
Expand Down