Bug 2092274

Summary: /boot/grub2/grubenv's timestamp is getting modified continuously due to "boot_success" implementation
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: grub2Assignee: Bootloader engineering team <bootloader-eng-team>
Status: CLOSED MIGRATED QA Contact: Release Test Team <release-test-team-automation>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.6CC: dapospis, mlewando, sbarcomb
Target Milestone: rcKeywords: MigratedToJIRA, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-16 13:27:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2022-06-01 08:40:52 UTC
This bug was initially created as a copy of Bug #2092273

I am copying this bug because: 

Also applies

Description of problem:

We have a customer noticing that the /boot/grub2/grubenv file is getting modified continuously, which raises an alert when executing aide monitoring tool (https://aide.github.io/).
This happens because every time a user logs in and has a session living for more than 2 minutes, the user's grub-boot-success.timer elapses, causing grub-boot-success.service unit to write "boot_success=1" into /boot/grub2/grubenv.

I have several concerns about this feature and the current implementation.

Regarding the feature itself, I understand the idea behind this is to automatically boot on the previous kernel if the newer kernel fails to boot several times in a row.
On RHEL, this doesn't work for many reason:
1. usually the latest kernel fails to boot because the initramfs is broken, which leads to a kernel panic and system sitting there
2. assuming kernel and initramfs boot fine, if the system fails after switch root, it's expected to fail whatever the booted kernel is
3. the feature is not enabled by default since its implementation inside grub.cfg relies on a "boot_counter" variable which isn't set
4. the implementation inside grub.cfg assumes the second menu entry will boot better, which is far from being true: on customer systems it's not rare that kernel updates are performed but no reboot is made in-between, waiting for a "reboot window"
5. it's unclear when a RHEL system should be considered as "booted fine": many systems are acting as services only (e.g. database server) with no user except root connecting to the system

Regarding the implementaion (the grub-boot-success.timer/grub-boot-success.service units) itself, it doesn't work on RHEL in many cases:
1. when there is only a root user accessing the system (because "ConditionUser=!@system" doesn't evaluate to true when uid is 0)
2. if other users are not using the "systemd --user" service, which is usually what we recommend and will be the default in some future for non-graphical installations
3. when users use "lingering" (i.e. starting "systemd --user" service at boot without actually logging into the system): the "boot_success=1" flag will be automatically set after 2 minutes even if users cannot effectively log in
4. there may be a race if 2 users log in concurrently: after 2 minutes, both grub-boot-success.service units will execute concurrently, which may break the grubenv file content if no proper locking is performed (I didn't check the code to confirm/infirm this)

For all these reasons and many more, I think this functionality is not wished on RHEL at all, it may bring more trouble than what it tries to solve.
For sure, if we decide to continue with this, the implementation needs to be enhanced.

Version-Release number of selected component (if applicable):

grub2-tools-minimal since RHEL8

How reproducible:

N/A

Comment 1 Marta Lewandowska 2023-03-20 10:06:45 UTC
Switching component to aide based on https://bugzilla.redhat.com/show_bug.cgi?id=2092273#c1

Comment 2 Radovan Sroka 2023-08-30 09:31:09 UTC
I'm switching component to grub2 based on https://bugzilla.redhat.com/show_bug.cgi?id=2092273#c9 .

Comment 3 RHEL Program Management 2023-09-16 13:24:41 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 4 RHEL Program Management 2023-09-16 13:27:48 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.