RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2030966 - [BZ] [RHEL 8.X] Bash scripts for remediations on grub2_slub_debug and poisoning doesn't work on RHEL 8 as expected.
Summary: [BZ] [RHEL 8.X] Bash scripts for remediations on grub2_slub_debug and poisoni...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: scap-security-guide
Version: 8.5
Hardware: All
OS: Linux
unspecified
urgent
Target Milestone: rc
: ---
Assignee: Matěj Týč
QA Contact: Milan Lysonek
Khushbu Borole
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-12-10 06:12 UTC by Parikshit Khedekar
Modified: 2022-05-10 14:43 UTC (History)
6 users (show)

Fixed In Version: scap-security-guide-0.1.60-3.el8
Doc Type: Bug Fix
Doc Text:
.Remediations of GRUB2 arguments are now persistent Previously, the remediations for GRUB2 rules that set kernel arguments were using incorrect procedures and the configuration changes were not persistent across kernel upgrades. As a consequence, the remediations had to be reapplied with every kernel upgrade. With this update, remediations use the `grubby` tool that configures GRUB2 in a persistent way.
Clone Of:
Environment:
Last Closed: 2022-05-10 14:15:29 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-105325 0 None None None 2021-12-10 06:17:19 UTC
Red Hat Product Errata RHBA-2022:1900 0 None None None 2022-05-10 14:15:52 UTC

Description Parikshit Khedekar 2021-12-10 06:12:43 UTC
Description of problem:

Bash scripts for remediations on grub2_slub_debug and poisoning doesn't work on RHEL 8 as expected.


The finding ID's tell to so things as,

    V-230277

"Configure RHEL 8 to enable page poisoning with the following commands:
$ sudo grubby --update-kernel=ALL --args=""page_poison=1""
Add or modify the following line in ""/etc/default/grub"" to ensure the configuration survives kernel updates:
GRUB_CMDLINE_LINUX=""page_poison=1"""

    V-230279

"Configure RHEL 8 to enable poisoning of SLUB/SLAB objects with the following commands:
$ sudo grubby --update-kernel=ALL --args=""slub_debug=P""
Add or modify the following line in ""/etc/default/grub"" to ensure the configuration survives kernel updates:
GRUB_CMDLINE_LINUX=""slub_debug=P"""

What I see the scripts are doing,

# rpm -qf /usr/share/scap-security-guide/bash/rhel8-script-stig.sh 
scap-security-guide-0.1.48-7.el8.noarch

In file /usr/share/scap-security-guide/bash/rhel8-script-stig.sh we see

###############################################################################
# BEGIN fix (160 / 217) for 'grub2_slub_debug_argument'
###############################################################################
(>&2 echo "Remediating rule 160/217: 'grub2_slub_debug_argument'")


#in later versions of rhel grub2-editenv is used
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) slub_debug=P"

# END fix for 'grub2_slub_debug_argument'

###############################################################################
# BEGIN fix (161 / 217) for 'grub2_page_poison_argument'
###############################################################################
(>&2 echo "Remediating rule 161/217: 'grub2_page_poison_argument'")


#in later versions of rhel grub2-editenv is used
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) page_poison=1"

# END fix for 'grub2_page_poison_argument'

So here I don't see they (remediations) are bothering about doing changes to actual config files of grub
to maintain persistent nature and just dealing with kernelopts in current grubenv.
If we install a new kernel the parameters will not be inherited and while using BLS even the current kernel
will not reflect them as the above script do not update the bootloader entries for BLS loader from where it
fetches the defaults for kernelopts!

Overall this isn't working on RHEL 8 as expected with BLS and even without BLS if we install a new kernel.
Version-Release number of selected component (if applicable):


How reproducible:

Always using STIG 


Steps to Reproduce:

   1. Install a RHEL 8 system ( default it will have BLS )
   2. Apply the things as below or how you prefer!

# oscap xccdf eval --profile stig --results /root/$(hostname)-RHEL-scap-report-pre.xml --remediate --cpe /usr/share/xml/scap/ssg/content/ssg-rhel8-cpe-dictionary.xml /usr/share/xml/scap/ssg/content/ssg-rhel8-xccdf.xml > /root/fix_report_RHEL.txt
 
# oscap xccdf generate fix --profile stig --output /root/stig_fix_script_RHEL.sh /usr/share/xml/scap/ssg/content/ssg-rhel8-xccdf.xml 

Looking at the /root/stig_fix_script_RHEL.sh fix script, it is using grub2-editenv to modify the /boot/grub2/grubenv file but the /etc/default/grub file is not getting modified.

Actual results:

It just adds the things to kernelopts which is temporary and this doesn't work to reflect with BLS loader or if a latest kernel is installed.

Expected results:

Shall work fine by making changes to the actual config files with BLS.

Additional info:

This works fine with RHEL 7 as they target actual config files,
https://static.open-scap.org/ssg-guides/ssg-rhel7-guide-ospp.html#xccdf_org.ssgproject.content_rule_grub2_slub_debug_argument

Filed for being specific on upstream as,
https://github.com/ComplianceAsCode/content/issues/7980

Got to know there is already a pull request to have grubby migrated for rest RHEL releases

https://github.com/ComplianceAsCode/content/pull/7931

Comment 2 Watson Yuuma Sato 2022-02-14 17:58:02 UTC
https://github.com/ComplianceAsCode/content/pull/8180

Comment 11 errata-xmlrpc 2022-05-10 14:15:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (scap-security-guide bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:1900


Note You need to log in before you can comment on or make changes to this bug.