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

Subscribers

People subscribed via source and target branches