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

Proposed by Mustafa Kemal Gilor
Status: Merged
Merge reported by: Lukas Märdian
Merged at revision: c42c169c32da5c76bf9abdf51f274c39e9525636
Proposed branch: ~mustafakemalgilor/ubuntu/+source/systemd:systemd-fix-lp1978079-efi-pstore-not-cleared-focal
Merge into: ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-focal
Diff against target: 79 lines (+48/-0)
3 files modified
debian/changelog (+6/-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 Pending
Canonical Server Core Reviewers Pending
Review via email: mp+425083@code.launchpad.net

Description of the change

Backported a fix from upstream to focal 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 jammy:
https://code.launchpad.net/~mustafakemalgilor/ubuntu/+source/systemd/+git/systemd/+merge/424958)

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 [13:08:54]: test systemd-fsckd: [-----------------------
SKIP: root file system is being checked by initramfs already
autopkgtest [13:08:55]: test systemd-fsckd: -----------------------]
systemd-fsckd SKIP exit status 77 and marked as skippable
autopkgtest [13:08:56]: test systemd-fsckd: - - - - - - - - - - results - - - - - - - - - -
autopkgtest [13:08:56]: @@@@@@@@@@@@@@@@@@@@ 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
root-unittests PASS
upstream PASS
boot-smoke PASS
systemd-fsckd SKIP exit status 77 and marked as skippable

To post a comment you must log in.
af8e899... 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)

c42c169... by Mustafa Kemal Gilor

updated changelog

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

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
Mustafa Kemal Gilor (mustafakemalgilor) wrote :

There is no particular reason. This is my first merge proposal and I've followed the Ubuntu Maintainer's Handbook (https://github.com/canonical/ubuntu-maintainers-handbook/blob/main/MergeProposal.md) for structuring my MP. It seems like either I've missed something, or the handbook is outdated.

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

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
Robie Basak (racb) wrote :

> There is no particular reason. This is my first merge proposal and I've followed the Ubuntu Maintainer's Handbook (https://github.com/canonical/ubuntu-maintainers-handbook/blob/main/MergeProposal.md) for structuring my MP. It seems like either I've missed something, or the handbook is outdated.

Ah OK, thanks for the feedback. The handbook was written by the server team with the idea that it'd also be useful to others. So some parts are currently server-specific, such as "how to find a reviewer", on the assumption that it's a package that the server team looks after.

I'm separately working on processes to help widen the usefulness of this, such as to integrate with the general sponsorship queue. So I'll carry on with that and update the docs when done.

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

> Ah OK, thanks for the feedback. The handbook was written by the server team with the idea that it'd also be useful to others. So some parts are currently server-specific, such as "how to find a reviewer", on the assumption that it's a package that the server team looks after.

Ah, I had no idea :)

> I'm separately working on processes to help widen the usefulness of this, such as to integrate with the general sponsorship queue. So I'll carry on with that and update the docs when done.

Thanks for considering that; it would be super helpful for the newcomers. Even in the current state, the handbook is pretty solid, and I'd say that I have learned a great deal about the SRU process by following it. The SRU process has many details, and it is *very* easy to get lost. Having such a guide helps a lot.

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 c1b9069..ba53e27 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,5 +1,6 @@
6 systemd (245.4-4ubuntu3.18) UNRELEASED; urgency=medium
7
8+ [ Nick Rosbrook ]
9 * core: make sure we don't get confused when setting TERM for a tty fd
10 (LP: #1959475)
11 File: debian/patches/lp1959475-core-make-sure-we-don-t-get-confused-when-setting-TERM-fo.patch
12@@ -9,6 +10,11 @@ systemd (245.4-4ubuntu3.18) UNRELEASED; urgency=medium
13 File: debian/patches/lp1966800-shared-calendarspec-when-mktime-moves-us-backwards-jump-f.patch
14 https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=1f063541e44f6ff1a6904676d4264a2e49a09594
15
16+ [ Mustafa Kemal GILOR ]
17+ * d/p/lp1978079-efi-pstore-not-cleared-on-boot.patch: pstore: Run after
18+ modules are loaded. Thanks to Alexander Graf <graf@amazon.com>.
19+ (LP: #1978079)
20+
21 -- Nick Rosbrook <nick.rosbrook@canonical.com> Fri, 29 Apr 2022 15:03:31 -0400
22
23 systemd (245.4-4ubuntu3.17) focal; urgency=medium
24diff --git a/debian/patches/lp1978079-efi-pstore-not-cleared-on-boot.patch b/debian/patches/lp1978079-efi-pstore-not-cleared-on-boot.patch
25new file mode 100644
26index 0000000..2b282d0
27--- /dev/null
28+++ b/debian/patches/lp1978079-efi-pstore-not-cleared-on-boot.patch
29@@ -0,0 +1,41 @@
30+From 4dec0b605b378b1a3d54bd738130cc45ff745673 Mon Sep 17 00:00:00 2001
31+From: Alexander Graf <graf@amazon.com>
32+Date: Thu, 9 Jun 2022 16:20:43 +0200
33+Subject: [PATCH] pstore: Run after modules are loaded
34+
35+The systemd-pstore service takes pstore files on boot and transfers them
36+to disk. It only does it once on boot and only if it finds any. The typical
37+location of the pstore on modern systems is the UEFI variable store.
38+
39+Most distributions ship with CONFIG_EFI_VARS_PSTORE=m. That means, the
40+UEFI variable store is only available on boot after the respective module
41+is loaded.
42+
43+In most situations, the pstore service gets loaded before the UEFI pstore,
44+so we don't get to transfer logs. Instead, they accumulate, filling up the
45+pstore over time, potentially breaking the UEFI variable store.
46+
47+Let's add a service dependency on any kernel module that can provide a
48+pstore to ensure we only scan for pstate after we can actually see pstate.
49+
50+I have seen live occurences of systems breaking because we did not erase
51+the pstates and ran out of UEFI nvram space.
52+
53+Fixes https://github.com/systemd/systemd/issues/18540
54+---
55+ units/systemd-pstore.service.in | 2 ++
56+ 1 file changed, 2 insertions(+)
57+
58+diff --git a/units/systemd-pstore.service.in b/units/systemd-pstore.service.in
59+index 848e311e9642..86de30ad4a72 100644
60+--- a/units/systemd-pstore.service.in
61++++ b/units/systemd-pstore.service.in
62+@@ -15,6 +15,8 @@ ConditionVirtualization=!container
63+ DefaultDependencies=no
64+ Conflicts=shutdown.target
65+ Before=sysinit.target shutdown.target
66++After=modprobe@efi_pstore.service modprobe@mtdpstore.service modprobe@chromeos_pstore.service modprobe@ramoops.service modprobe@pstore_zone.service modprobe@pstore_blk.service
67++Wants=modprobe@efi_pstore.service modprobe@mtdpstore.service modprobe@chromeos_pstore.service modprobe@ramoops.service modprobe@pstore_zone.service modprobe@pstore_blk.service
68+
69+ [Service]
70+ Type=oneshot
71diff --git a/debian/patches/series b/debian/patches/series
72index 6441bb3..56ece03 100644
73--- a/debian/patches/series
74+++ b/debian/patches/series
75@@ -177,3 +177,4 @@ hwdb-Add-mic-mute-key-mapping-for-HP-Elite-x360.patch
76 lp1966179-add-more-hp-dmi-to-unblock-intel-hid-event.patch
77 lp1959475-core-make-sure-we-don-t-get-confused-when-setting-TERM-fo.patch
78 lp1966800-shared-calendarspec-when-mktime-moves-us-backwards-jump-f.patch
79+lp1978079-efi-pstore-not-cleared-on-boot.patch

Subscribers

People subscribed via source and target branches