Bug#1040149: systemd: services considered running after mainpid has exited

Tomas Janousek tomi at nomi.cz
Sun Jul 2 16:22:03 BST 2023


Package: systemd
Version: 253.5-1
Severity: important
Tags: upstream
X-Debbugs-Cc: tomi at nomi.cz

Since https://github.com/systemd/systemd-stable/commit/ae83e97a51519ca33e70d7ba142cb3ed24212825, 
services with ExitType=main (the default) and KillMode=process (not the 
default, but used in e.g. libvirtd.service) are considered active even 
after the main process has exited.

This is clearly a bug, reported multiple times to systemd: [1], [2] that 
has since been fixed upstream [3] and many distros (Fedora, Arch, 
openSUSE, NixOS) are carrying the patch even before a systemd-stable 
release [4] because it's quite a serious bug that breaks libvirtd socket 
activation among other things.

[1]: https://github.com/systemd/systemd/issues/28030
[2]: https://github.com/systemd/systemd/issues/27953
[3]: https://github.com/systemd/systemd/pull/28000
[4]: https://github.com/systemd/systemd-stable/issues/302

Minimal reproducer:

    systemd-run --quiet --collect --wait --property=KillMode=process -- sh -c 'sleep 20 &'

This should not return immediately, but instead blocks for 30 seconds in 
the affected versions of systemd.

Less minimal reproducer:

1. install libvirt-daemon, libvirt-clients
2. make sure the default network is up (which it wouldn't be if you're 
   trying to do this inside another libvirt VM due to IP range conflict)
3. wait until the `/usr/sbin/libvirtd --timeout 120` process terminates
4. `systemctl status libvirtd.service` still says "active (running)"
5. `virsh connect` hangs indefinitely

Can we please get the fix [3] added to Debian as well?

(Also, I believe Luca is a maintainer of v252-stable, where the fix also 
needs to be backported. v252.11 currently in Debian testing and 
stable-proposed-updates is affected as well. I tried to highlight this 
issue a week ago [5] but I understand GitHub notifications are easy to 
miss.)

[5]: https://github.com/systemd/systemd/pull/28000#issuecomment-1608296400


-- Package-specific info:

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.3.0-1-amd64 (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages systemd depends on:
ii  libacl1            2.3.1-3
ii  libaudit1          1:3.0.9-1
ii  libblkid1          2.38.1-5+b1
ii  libc6              2.37-3
ii  libcap2            1:2.66-4
ii  libcryptsetup12    2:2.6.1-4
ii  libfdisk1          2.38.1-5+b1
ii  libgcrypt20        1.10.2-2
ii  libkmod2           30+20230519-1
ii  liblz4-1           1.9.4-1
ii  liblzma5           5.4.1-0.2
ii  libmount1          2.38.1-5+b1
ii  libp11-kit0        0.24.1-2
ii  libseccomp2        2.5.4-1+b3
ii  libselinux1        3.4-1+b6
ii  libssl3            3.0.9-1
ii  libsystemd-shared  253.5-1
ii  libsystemd0        253.5-1
ii  libzstd1           1.5.5+dfsg2-1
ii  mount              2.38.1-5+b1
ii  systemd-dev        253.5-1

Versions of packages systemd recommends:
ii  dbus [default-dbus-system-bus]   1.14.8-1
ii  systemd-timesyncd [time-daemon]  253.5-1

Versions of packages systemd suggests:
ii  libfido2-1            1.13.0-1
pn  libqrencode4          <none>
pn  libtss2-esys-3.0.2-0  <none>
pn  libtss2-mu0           <none>
pn  libtss2-rc0           <none>
ii  polkitd               122-4
pn  systemd-boot          <none>
pn  systemd-container     <none>
pn  systemd-homed         <none>
ii  systemd-resolved      253.5-1
pn  systemd-userdbd       <none>

Versions of packages systemd is related to:
pn  dbus-user-session  <none>
pn  dracut             <none>
ii  initramfs-tools    0.142
pn  libnss-systemd     <none>
ii  libpam-systemd     253.5-1
ii  udev               253.5-1

-- no debconf information

-- 
Tomáš "liskin" ("Pivník") Janoušek, https://lisk.in/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20230702/c1ebe925/attachment.htm>


More information about the Pkg-systemd-maintainers mailing list