on WSL systemd status fails output

Bug #2067922 reported by Jean-Baptiste Lallement
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Fix Committed
Undecided
Unassigned
Noble
Fix Released
Critical
Unassigned

Bug Description

[Impact]

WSL 24.04 / systemd 255.4-1ubuntu8

* Upstream report: https://github.com/microsoft/WSL/issues/8879
* Upstream PR: https://github.com/systemd/systemd/pull/32534
* Upstream commit: https://github.com/systemd/systemd-stable/commit/8e57759d6d80ef772d8e17a4559a6797e09af93a.patch

In WSL, the cgroup.procs PID list for some reason contain a ton of zeros everywhere from unmapped PIDs.
Whenever cg_read_pid encounters such a zero, it throws an error. This makes systemd near unusable inside of WSL.

[Test Plan]

On WSL running Ubuntu 24.04, run systemctl status. On an affected system, there will be an error saying "Failed to dump process list [...]". On a patched system, the command should work as expected.

[Where problems could occur]

This patch adds a flags parameter to cg_read_pid(), and adds a new flag, CGROUP_DONT_SKIP_UNMAPPED. The new default behavior of cg_read_pid() is that unmapped pids *will* be skipped. When this flag is set in a call to cg_read_pid(), encountering an unmapped pid will leave the caller to deal with it.

There are several places where cg_read_pid() is called in systemd, so there are several places where this would come up. If we did see problems, it would likely because a caller is skipping the unmapped pids when it should not be. For callers that do not skip (i.e. pass CGROUP_DONT_SKIP_UNMAPPED), they either handle it cleanly, or propagate a different error to signal this case.

[Original Description]

WSL 24.04 / systemd 255.4-1ubuntu8

* Upstream report: https://github.com/microsoft/WSL/issues/8879
* Upstream PR: https://github.com/systemd/systemd/pull/32534
* Upstream commit: https://github.com/systemd/systemd-stable/commit/8e57759d6d80ef772d8e17a4559a6797e09af93a.patch

In WSL, the cgroup.procs PID list for some reason contain a ton of zeros everywhere from unmapped PIDs.
Whenever cg_read_pid encounters such a zero, it throws an error. This makes systemd near unusable inside of WSL.

# Test Case
install Ubuntu WSL 24.04 from the MS STore. This version has systemd already enabled.

## Expected Behavior
systemctl status command to work

## Actual Behavior
toor@XPS:~$ systemctl status
Failed to dump process list for 'XPS', ignoring: Input/output error
● XPS
    State: degraded
    Units: 318 loaded (incl. loaded aliases)
     Jobs: 0 queued
   Failed: 1 units
    Since: Sat 2022-09-24 08:43:15 PDT; 14min ago
  systemd: 251.4-1ubuntu6
  Tainted: cgroupsv1
   CGroup: /

Nick Rosbrook (enr0n)
tags: added: systemd-sru-next
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

upstream patch

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

debdiff with patch applied

Changed in systemd (Ubuntu Noble):
importance: Undecided → Critical
status: New → Triaged
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "8e57759d6d80ef772d8e17a4559a6797e09af93a.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Nick Rosbrook (enr0n) wrote :

The fix for this is included in v256, which is currently in oracular-proposed. So we just need to upload the fix to noble.

Changed in systemd (Ubuntu):
status: New → Fix Committed
Revision history for this message
Nick Rosbrook (enr0n) wrote :

@jibel - thanks for the patch. I already had it prepped in git, so I will upload that version.

Nick Rosbrook (enr0n)
description: updated
Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Jean-Baptiste, or anyone else affected,

Accepted systemd into noble-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/systemd/255.4-1ubuntu8.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-noble to verification-done-noble. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-noble. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in systemd (Ubuntu Noble):
status: Triaged → Fix Committed
tags: added: verification-needed verification-needed-noble
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

I've been able to reproduce the problem on Ubuntu WSL 24.04 with systemd 255.4-1ubuntu8.1.
I verified that version 255.4-1ubuntu8.2 fixes it.

u@drenec:~$ systemctl status
● drenec
    State: running
    Units: 359 loaded (incl. loaded aliases)
     Jobs: 0 queued
   Failed: 0 units
    Since: Mon 2024-07-08 09:41:07 CEST; 1h 1min ago
  systemd: 255.4-1ubuntu8.2
  Tainted: cgroupsv1
   CGroup: /
           ├─init.scope
           │ ├─ 1 /sbin/init
           │ ├─ 2 /init
           │ ├─ 6 plan9 --control-socket 6 --log-level 4 --server-fd 7 --pipe-fd 9 --log-truncate
           │ ├─325 /init
           │ ├─326 /init
           │ ├─327 -bash
           │ ├─546 systemctl status
           │ └─547 less

Marking as verification-done.

tags: added: verification-done verification-done-noble
removed: verification-needed verification-needed-noble
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package systemd - 255.4-1ubuntu8.2

---------------
systemd (255.4-1ubuntu8.2) noble; urgency=medium

  * mountpoint-util: Deal with kernel API breakage in "norecovery" mount option.
    Also include fixup commit
    055b465a3f ("shared/mountpoint-util: for old kernels, assume "norecovery" is supported by btrfs").
    (LP: #2067907)
  * cgroup-util: allow cg_read_pid() to skip unmapped (zero) pids (LP: #2067922)
  * debian/extra: ship nice.conf for journald, not logind (LP: #2067927)

 -- Nick Rosbrook <email address hidden> Fri, 14 Jun 2024 17:03:19 -0400

Changed in systemd (Ubuntu Noble):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for systemd has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.