Merge ~mustafakemalgilor/ubuntu/+source/systemd:systemd-fix-lp1978079-efi-pstore-not-cleared-jammy into ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-jammy

Proposed by Mustafa Kemal Gilor
Status: Merged
Merge reported by: Lukas Märdian
Merged at revision: 0569b1422bf26d157e4c120794f542ee032a347c
Proposed branch: ~mustafakemalgilor/ubuntu/+source/systemd:systemd-fix-lp1978079-efi-pstore-not-cleared-jammy
Merge into: ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-jammy
Diff against target: 72 lines (+50/-0)
3 files modified
debian/changelog (+8/-0)
debian/patches/lp1978079-efi-pstore-not-cleared-on-boot.patch (+41/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Lukas Märdian Approve
Canonical Server Core Reviewers Pending
Canonical Server Pending
Review via email: mp+425082@code.launchpad.net

Description of the change

Backported a fix from upstream to jammy for the LP issue #1978079:

      * d/p/lp1978079-efi-pstore-not-cleared-on-boot.patch: pstore: Run
        after
        modules are loaded. Thanks to Alexander Graf <email address hidden>.
        LP: #1978079)

Please tag & sponsor.

(See backport merge request for focal: https://code.launchpad.net/~mustafakemalgilor/ubuntu/+source/systemd/+git/systemd/+merge/424938)

Steps to reproduce/test:

# In order to be able to reproduce this issue, the system must have EFI-backed pstore.
# To check which kind of backend that pstore, use `cat /sys/module/pstore/parameters/backend`
# If it says `efi`, the steps below are applicable. Otherwise, find an environment that has
# EFI backed pstore.

# Enable the pstore service. This service is supposed to move the data in /sys/fs/pstore
# to the `/var/lib/systemd/pstore` path on boot.
systemctl enable systemd-pstore.service # (or can be vendor enabled)

# Crash the kernel
echo 1 > /proc/sys/kernel/sysrq
echo 1 > /proc/sys/kernel/panic # this is usually set to zero, causing kernel to loop over the panic and freeze
echo "c" > /proc/sysrq-trigger

# The system will reboot itself. Check `/sys/fs/pstore` path first:
ls /sys/fs/pstore # The path should not be empty, which means the systemd-pstore has failed to do its' job
ls /var/lib/systemd/pstore # The path should be empty.

# Apply the fix
sudo add-apt-repository ppa:mustafakemalgilor/lp-1978079-1
sudo apt upgrade

# Crash the kernel
echo 1 > /proc/sys/kernel/sysrq
echo 1 > /proc/sys/kernel/panic # this is usually set to zero, causing kernel to loop over the panic and freeze
echo "c" > /proc/sysrq-trigger

# The system will reboot itself. Check `/sys/fs/pstore` path first:
ls /sys/fs/pstore # The path should be empty
ls /var/lib/systemd/pstore # The path should not be empty

Package Test Results:

autopkgtest [15:49:45]: test systemd-fsckd: [-----------------------
SKIP: root file system is being checked by initramfs already
autopkgtest [15:49:45]: test systemd-fsckd: -----------------------]
systemd-fsckd SKIP exit status 77 and marked as skippable
autopkgtest [15:49:46]: test systemd-fsckd: - - - - - - - - - - results - - - - - - - - - -
autopkgtest [15:49:46]: @@@@@@@@@@@@@@@@@@@@ summary
timedated PASS
hostnamed PASS
localed-locale PASS
localed-x11-keymap PASS
logind PASS
unit-config PASS
storage PASS
networkd-test.py PASS
build-login PASS
boot-and-services PASS
udev PASS
unit-tests PASS
tests-in-lxd PASS
upstream-1 PASS
upstream-2 PASS
boot-smoke PASS
systemd-fsckd SKIP exit status 77 and marked as skippable
qemu-system-x86_64: terminating on signal 15 from pid 474221 (/usr/bin/python3)

To post a comment you must log in.
63e3800... by Mustafa Kemal Gilor

* d/p/lp1978079-efi-pstore-not-cleared-on-boot.patch: pstore: Run after
  modules are loaded. Thanks to Alexander Graf <email address hidden>.
  (LP: #1978079)

0569b14... by Mustafa Kemal Gilor

updated changelog

Revision history for this message
Robie Basak (racb) wrote :

Hi,

Normally the Foundations team reviews systemd changes. Is there a particular reason you requested reviews from the Server Team please?

Revision history for this message
Lukas Märdian (slyon) wrote (last edit ):

Thank you very much! This is quality work and LGTM.

Good work on the detailed reproducer/testcase and thanks for executing autopkgtest ahead of time!

I will probably re-write the d/changelog file a bit, to bring it in line with our "gbp dch" (git-buildpackage) workflow. Other than that, I'll merge it as is.

review: Approve
Revision history for this message
Mustafa Kemal Gilor (mustafakemalgilor) wrote :

Thanks for the feedback!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index f9df438..10bce92 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+systemd (249.11-0ubuntu3.4) jammy; urgency=medium
7+
8+ * d/p/lp1978079-efi-pstore-not-cleared-on-boot.patch: pstore: Run after
9+ modules are loaded. Thanks to Alexander Graf <graf@amazon.com>.
10+ (LP: #1978079)
11+
12+ -- Mustafa Kemal GILOR <mustafa.gilor@canonical.com> Mon, 20 Jun 2022 17:14:13 +0300
13+
14 systemd (249.11-0ubuntu3.3) jammy; urgency=medium
15
16 [ Lukas Märdian ]
17diff --git a/debian/patches/lp1978079-efi-pstore-not-cleared-on-boot.patch b/debian/patches/lp1978079-efi-pstore-not-cleared-on-boot.patch
18new file mode 100644
19index 0000000..2b282d0
20--- /dev/null
21+++ b/debian/patches/lp1978079-efi-pstore-not-cleared-on-boot.patch
22@@ -0,0 +1,41 @@
23+From 4dec0b605b378b1a3d54bd738130cc45ff745673 Mon Sep 17 00:00:00 2001
24+From: Alexander Graf <graf@amazon.com>
25+Date: Thu, 9 Jun 2022 16:20:43 +0200
26+Subject: [PATCH] pstore: Run after modules are loaded
27+
28+The systemd-pstore service takes pstore files on boot and transfers them
29+to disk. It only does it once on boot and only if it finds any. The typical
30+location of the pstore on modern systems is the UEFI variable store.
31+
32+Most distributions ship with CONFIG_EFI_VARS_PSTORE=m. That means, the
33+UEFI variable store is only available on boot after the respective module
34+is loaded.
35+
36+In most situations, the pstore service gets loaded before the UEFI pstore,
37+so we don't get to transfer logs. Instead, they accumulate, filling up the
38+pstore over time, potentially breaking the UEFI variable store.
39+
40+Let's add a service dependency on any kernel module that can provide a
41+pstore to ensure we only scan for pstate after we can actually see pstate.
42+
43+I have seen live occurences of systems breaking because we did not erase
44+the pstates and ran out of UEFI nvram space.
45+
46+Fixes https://github.com/systemd/systemd/issues/18540
47+---
48+ units/systemd-pstore.service.in | 2 ++
49+ 1 file changed, 2 insertions(+)
50+
51+diff --git a/units/systemd-pstore.service.in b/units/systemd-pstore.service.in
52+index 848e311e9642..86de30ad4a72 100644
53+--- a/units/systemd-pstore.service.in
54++++ b/units/systemd-pstore.service.in
55+@@ -15,6 +15,8 @@ ConditionVirtualization=!container
56+ DefaultDependencies=no
57+ Conflicts=shutdown.target
58+ Before=sysinit.target shutdown.target
59++After=modprobe@efi_pstore.service modprobe@mtdpstore.service modprobe@chromeos_pstore.service modprobe@ramoops.service modprobe@pstore_zone.service modprobe@pstore_blk.service
60++Wants=modprobe@efi_pstore.service modprobe@mtdpstore.service modprobe@chromeos_pstore.service modprobe@ramoops.service modprobe@pstore_zone.service modprobe@pstore_blk.service
61+
62+ [Service]
63+ Type=oneshot
64diff --git a/debian/patches/series b/debian/patches/series
65index 3ba6f06..8dbcd40 100644
66--- a/debian/patches/series
67+++ b/debian/patches/series
68@@ -88,3 +88,4 @@ lp1966381-oomd-calculate-used-memory-with-MemAvailable-instead-of-M.patch
69 lp1926860-hwdb-remove-the-tablet-pad-entry-for-the-UC-Logic-1060N.patch
70 hwdb-Add-mic-mute-key-mapping-for-HP-Elite-x360.patch
71 lp1964494-network-do-not-enable-IPv4-ACD-for-IPv4-link-local-a.patch
72+lp1978079-efi-pstore-not-cleared-on-boot.patch

Subscribers

People subscribed via source and target branches