Blame SOURCES/scap-security-guide-0.1.61-grub2_rule_desc_update-PR_8184.patch

07cb6b
From 51a826878ade2ebb564405991937ba0e2b2b7717 Mon Sep 17 00:00:00 2001
07cb6b
From: Vojtech Polasek <vpolasek@redhat.com>
07cb6b
Date: Wed, 2 Feb 2022 14:25:30 +0100
07cb6b
Subject: [PATCH 1/8] create two macros
07cb6b
07cb6b
one provides description for grub2_argument templated rules
07cb6b
the second provides ocil for those cases
07cb6b
---
07cb6b
 shared/macros.jinja | 56 +++++++++++++++++++++++++++++++++++++++++++++
07cb6b
 1 file changed, 56 insertions(+)
07cb6b
07cb6b
diff --git a/shared/macros.jinja b/shared/macros.jinja
07cb6b
index 00358e2f67c..3d41c998b0c 100644
07cb6b
--- a/shared/macros.jinja
07cb6b
+++ b/shared/macros.jinja
07cb6b
@@ -1620,3 +1620,59 @@ The audit daemon must be restarted for the changes to take effect.
07cb6b
 - no_ovirt
07cb6b
 {{%- endif %}}
07cb6b
 {{% endmacro %}}
07cb6b
+
07cb6b
+{{#
07cb6b
+    Describe how to configure Grub2 to add an argument to the default kernel command line.
07cb6b
+    The parameter should be in form `parameter=value`.
07cb6b
+#}}
07cb6b
+{{%- macro describe_grub2_argument(arg_name_value) -%}}
07cb6b
+{{%- if product in ["rhel7", "ol7", "rhel9"] or 'ubuntu' in product -%}}
07cb6b
+To ensure that <tt>{{{ arg_name_value }}}</tt> is added as a kernel command line
07cb6b
+argument to newly installed kernels, ad <tt>{{{ arg_name_value }}}</tt> to the
07cb6b
+default Grub2 command line for Linux operating systems.  Modify the line within
07cb6b
+<tt>/etc/default/grub</tt> as shown below:
07cb6b
+
GRUB_CMDLINE_LINUX="... {{{ arg_name_value }}} ..."
07cb6b
+Run the following command to update command line for already installed kernels:
07cb6b
+{{%- if 'ubuntu' in product -%}}
07cb6b
+
# update-grub
07cb6b
+{{%- else -%}}
07cb6b
+
# grubby --update-kernel=ALL --args="{{{ arg_name_value }}}"
07cb6b
+{{%- endif -%}}
07cb6b
+{{%- else -%}}
07cb6b
+Configure the default Grub2 kernel command line to contain {{{ arg_name_value }}} as follows:
07cb6b
+
# grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) {{{ arg_name_value }}}"
07cb6b
+{{%- endif -%}}
07cb6b
+{{%- endmacro -%}}
07cb6b
+
07cb6b
+{{#
07cb6b
+    Provide OCIL for checking if an argument for kernel command line is configured with Grub2.
07cb6b
+    The parameter should have form `parameter=value`.
07cb6b
+#}}
07cb6b
+{{%- macro ocil_grub2_argument(arg_name_value) -%}}
07cb6b
+{{%- if product in ["rhel7", "ol7", "rhel9"] or 'ubuntu' in product -%}}
07cb6b
+Inspect the form of default GRUB 2 command line for the Linux operating system
07cb6b
+in <tt>/etc/default/grub</tt>. If it includes <tt>{{{ arg_name_value }}}</tt>,
07cb6b
+then auditinng will be enabled for newly installed kernels.
07cb6b
+First check if the GRUB recovery is enabled:
07cb6b
+
$ grep 'GRUB_DISABLE_RECOVERY' /etc/default/grub
07cb6b
+If this option is set to true, then check that a line is output by the following command:
07cb6b
+
$ grep 'GRUB_CMDLINE_LINUX_DEFAULT.*{{{ arg_name_value }}}.*' /etc/default/grub
07cb6b
+If the recovery is disabled, check the line with
07cb6b
+
$ grep 'GRUB_CMDLINE_LINUX.*{{{ arg_name_value }}}.*' /etc/default/grub
.
07cb6b
+{{%- if 'ubuntu' in product -%}}
07cb6b
+Moreover, current Grub2 config file in <tt>/etc/grub2/grub.cfg</tt> must be checked.
07cb6b
+
# grep vmlinuz {{{ grub2_boot_path }}}/grub.cfg | grep -v '{{{ arg_name_value }}}'
07cb6b
+This command should not return any output.
07cb6b
+{{%- else -%}}
07cb6b
+Moreover, command line parameters for currently installed kernels should be checked as well.
07cb6b
+Run the following command:
07cb6b
+
# grubby --info=ALL | grep args | grep -v '{{{ arg_name_value }}}'
07cb6b
+The command should not return any output.
07cb6b
+{{%- endif -%}}
07cb6b
+{{%- else -%}}
07cb6b
+Inspect the form of default GRUB 2 command line for the Linux operating system
07cb6b
+in <tt>{{{ grub2_boot_path }}}/grubenv</tt>. If they include <tt>{{{ arg_name_value }}}</tt>, then auditing
07cb6b
+is enabled at boot time.
07cb6b
+
# grep 'kernelopts.*{{{ arg_name_value }}}.*' {{{ grub2_boot_path }}}/grubenv
07cb6b
+{{%- endif -%}}
07cb6b
+{{%- endmacro -%}}
07cb6b
07cb6b
From c8cb579db19bd55eebcb0bdc4b1432368a5c1b77 Mon Sep 17 00:00:00 2001
07cb6b
From: Vojtech Polasek <vpolasek@redhat.com>
07cb6b
Date: Wed, 2 Feb 2022 14:26:26 +0100
07cb6b
Subject: [PATCH 2/8] use new macros in grub2_audit_argument
07cb6b
07cb6b
---
07cb6b
 .../auditing/grub2_audit_argument/rule.yml    | 45 ++-----------------
07cb6b
 1 file changed, 3 insertions(+), 42 deletions(-)
07cb6b
07cb6b
diff --git a/linux_os/guide/system/auditing/grub2_audit_argument/rule.yml b/linux_os/guide/system/auditing/grub2_audit_argument/rule.yml
07cb6b
index 96dbe67699e..aff0521ee73 100644
07cb6b
--- a/linux_os/guide/system/auditing/grub2_audit_argument/rule.yml
07cb6b
+++ b/linux_os/guide/system/auditing/grub2_audit_argument/rule.yml
07cb6b
@@ -7,15 +7,8 @@ title: 'Enable Auditing for Processes Which Start Prior to the Audit Daemon'
07cb6b
 description: |-
07cb6b
     To ensure all processes can be audited, even those which start
07cb6b
     prior to the audit daemon, add the argument <tt>audit=1</tt> to the default
07cb6b
-    GRUB 2 command line for the Linux operating system in
07cb6b
-{{% if product in ["rhel7", "ol7"] %}}
07cb6b
-    <tt>/etc/default/grub</tt>, so that the line looks similar to
07cb6b
-    
GRUB_CMDLINE_LINUX="... audit=1 ..."
07cb6b
-    In case the <tt>GRUB_DISABLE_RECOVERY</tt> is set to true, then the parameter should be added to the <tt>GRUB_CMDLINE_LINUX_DEFAULT</tt> instead.
07cb6b
-{{% else %}}
07cb6b
-    <tt>{{{ grub2_boot_path }}}/grubenv</tt>, in the manner below:
07cb6b
-    
# grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) audit=1"
07cb6b
-{{% endif %}}
07cb6b
+    GRUB 2 command line for the Linux operating system.
07cb6b
+    {{{ describe_grub2_argument("audit=1") | indent(4) }}}
07cb6b
 
07cb6b
 rationale: |-
07cb6b
     Each process on the system carries an "auditable" flag which indicates whether
07cb6b
@@ -59,39 +52,7 @@ references:
07cb6b
 ocil_clause: 'auditing is not enabled at boot time'
07cb6b
 
07cb6b
 ocil: |-
07cb6b
-{{% if product in ["rhel7", "ol7", "sle12","sle15"] %}}
07cb6b
-    Inspect the form of default GRUB 2 command line for the Linux operating system
07cb6b
-    in <tt>/etc/default/grub</tt>. If it includes <tt>audit=1</tt>, then auditing
07cb6b
-    is enabled at boot time.
07cb6b
-    First check if the GRUB recovery is enabled:
07cb6b
-    
$ grep 'GRUB_DISABLE_RECOVERY' /etc/default/grub
07cb6b
-    If this option is set to true, then check that a line is output by the following command:
07cb6b
-    
$ grep 'GRUB_CMDLINE_LINUX_DEFAULT.*audit=1.*' /etc/default/grub
07cb6b
-    If the recovery is disabled, check the line with
07cb6b
-    
$ grep 'GRUB_CMDLINE_LINUX.*audit=1.*' /etc/default/grub
.
07cb6b
-    Moreover, current Grub2 config file in <tt>/etc/grub2/grub.cfg</tt> must be checked.
07cb6b
-    
# grep vmlinuz {{{ grub2_boot_path }}}/grub.cfg | grep -v 'audit=1'
07cb6b
-    This command should not return any output. If it does, update the configuration with
07cb6b
-    
# grub2-mkconfig -o {{{ grub2_boot_path }}}/grub.cfg
07cb6b
-    

07cb6b
-    Alternatively, to ensure <tt>audit=1</tt> is configured on all installed kernels, the
07cb6b
-    following command may be used:
07cb6b
-    
07cb6b
-    
$ sudo /sbin/grubby --update-kernel=ALL --args="audit=1"
07cb6b
-    
07cb6b
-{{% else %}}
07cb6b
-    Inspect the form of default GRUB 2 command line for the Linux operating system
07cb6b
-    in <tt>{{{ grub2_boot_path }}}/grubenv</tt>. If they include <tt>audit=1</tt>, then auditing
07cb6b
-    is enabled at boot time.
07cb6b
-    
# grep 'kernelopts.*audit=1.*' {{{ grub2_boot_path }}}/grubenv
07cb6b
-    

07cb6b
-    To ensure <tt>audit=1</tt> is configured on all installed kernels, the
07cb6b
-    following command may be used:
07cb6b
-    
07cb6b
-    
# grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) audit=1"
07cb6b
-    
07cb6b
-{{% endif %}}
07cb6b
-
07cb6b
+    {{{ ocil_grub2_argument("audit=1") | indent(4) }}}
07cb6b
 
07cb6b
 warnings:
07cb6b
     - management: |-
07cb6b
07cb6b
From 3ff2c245408d3fe892222eee8171e2f84868f705 Mon Sep 17 00:00:00 2001
07cb6b
From: Vojtech Polasek <vpolasek@redhat.com>
07cb6b
Date: Thu, 3 Feb 2022 14:25:34 +0100
07cb6b
Subject: [PATCH 3/8] fix omission  in ocil jinja macro
07cb6b
07cb6b
---
07cb6b
 shared/macros.jinja | 6 +++---
07cb6b
 1 file changed, 3 insertions(+), 3 deletions(-)
07cb6b
07cb6b
diff --git a/shared/macros.jinja b/shared/macros.jinja
07cb6b
index 3d41c998b0c..16a0404b668 100644
07cb6b
--- a/shared/macros.jinja
07cb6b
+++ b/shared/macros.jinja
07cb6b
@@ -1652,7 +1652,7 @@ Configure the default Grub2 kernel command line to contain {{{ arg_name_value }}
07cb6b
 {{%- if product in ["rhel7", "ol7", "rhel9"] or 'ubuntu' in product -%}}
07cb6b
 Inspect the form of default GRUB 2 command line for the Linux operating system
07cb6b
 in <tt>/etc/default/grub</tt>. If it includes <tt>{{{ arg_name_value }}}</tt>,
07cb6b
-then auditinng will be enabled for newly installed kernels.
07cb6b
+then the parameter will be configured for newly installed kernels.
07cb6b
 First check if the GRUB recovery is enabled:
07cb6b
 
$ grep 'GRUB_DISABLE_RECOVERY' /etc/default/grub
07cb6b
 If this option is set to true, then check that a line is output by the following command:
07cb6b
@@ -1671,8 +1671,8 @@ The command should not return any output.
07cb6b
 {{%- endif -%}}
07cb6b
 {{%- else -%}}
07cb6b
 Inspect the form of default GRUB 2 command line for the Linux operating system
07cb6b
-in <tt>{{{ grub2_boot_path }}}/grubenv</tt>. If they include <tt>{{{ arg_name_value }}}</tt>, then auditing
07cb6b
-is enabled at boot time.
07cb6b
+in <tt>{{{ grub2_boot_path }}}/grubenv</tt>. If they include <tt>{{{ arg_name_value }}}</tt>, then the parameter
07cb6b
+is configured at boot time.
07cb6b
 
# grep 'kernelopts.*{{{ arg_name_value }}}.*' {{{ grub2_boot_path }}}/grubenv
07cb6b
 {{%- endif -%}}
07cb6b
 {{%- endmacro -%}}
07cb6b
07cb6b
From 976da69681d03d9b9380fc57216c30c7b4891f50 Mon Sep 17 00:00:00 2001
07cb6b
From: Vojtech Polasek <vpolasek@redhat.com>
07cb6b
Date: Thu, 3 Feb 2022 14:26:33 +0100
07cb6b
Subject: [PATCH 4/8] use new jinja macros in all grub2 related rules
07cb6b
07cb6b
---
07cb6b
 .../rule.yml                                  | 15 ++-----
07cb6b
 .../grub2_enable_iommu_force/rule.yml         |  9 +++-
07cb6b
 .../grub2_init_on_alloc_argument/rule.yml     | 18 ++------
07cb6b
 .../grub2_kernel_trust_cpu_rng/rule.yml       | 11 ++---
07cb6b
 .../grub2_pti_argument/rule.yml               | 15 ++-----
07cb6b
 .../grub2_vsyscall_argument/rule.yml          | 15 ++-----
07cb6b
 .../grub2_ipv6_disable_argument/rule.yml      | 45 ++-----------------
07cb6b
 .../grub2_page_poison_argument/rule.yml       | 15 ++-----
07cb6b
 .../grub2_slub_debug_argument/rule.yml        | 15 ++-----
07cb6b
 9 files changed, 33 insertions(+), 125 deletions(-)
07cb6b
07cb6b
diff --git a/linux_os/guide/system/auditing/grub2_audit_backlog_limit_argument/rule.yml b/linux_os/guide/system/auditing/grub2_audit_backlog_limit_argument/rule.yml
07cb6b
index f94ddab2fe1..868d525014f 100644
07cb6b
--- a/linux_os/guide/system/auditing/grub2_audit_backlog_limit_argument/rule.yml
07cb6b
+++ b/linux_os/guide/system/auditing/grub2_audit_backlog_limit_argument/rule.yml
07cb6b
@@ -7,9 +7,8 @@ title: 'Extend Audit Backlog Limit for the Audit Daemon'
07cb6b
 description: |-
07cb6b
     To improve the kernel capacity to queue all log events, even those which occurred
07cb6b
     prior to the audit daemon, add the argument <tt>audit_backlog_limit=8192</tt> to the default
07cb6b
-    GRUB 2 command line for the Linux operating system in
07cb6b
-    <tt>/etc/default/grub</tt>, in the manner below:
07cb6b
-    
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=VolGroup/LogVol06 rd.lvm.lv=VolGroup/lv_swap rhgb quiet rd.shell=0 audit=1 audit_backlog_limit=8192"
07cb6b
+    GRUB 2 command line for the Linux operating system.
07cb6b
+    {{{ describe_grub2_argument("audit_backlog_limit=8192") | indent(4) }}}
07cb6b
 
07cb6b
 rationale: |-
07cb6b
     audit_backlog_limit sets the queue length for audit events awaiting transfer
07cb6b
@@ -40,15 +39,7 @@ references:
07cb6b
 ocil_clause: 'audit backlog limit is not configured'
07cb6b
 
07cb6b
 ocil: |-
07cb6b
-    Inspect the form of default GRUB 2 command line for the Linux operating system
07cb6b
-    in <tt>/etc/default/grub</tt>. If they include <tt>audit=1</tt>, then auditing
07cb6b
-    is enabled at boot time.
07cb6b
-    

07cb6b
-    To ensure <tt>audit_backlog_limit=8192</tt> is configured on all installed kernels, the
07cb6b
-    following command may be used:
07cb6b
-    
07cb6b
-    
$ sudo /sbin/grubby --update-kernel=ALL --args="audit_backlog_limit=8192"
07cb6b
-    
07cb6b
+    {{{ ocil_grub2_argument("audit_backlog_limit=8192") | indent(4) }}}
07cb6b
 
07cb6b
 warnings:
07cb6b
     - management: |-
07cb6b
diff --git a/linux_os/guide/system/bootloader-grub2/grub2_enable_iommu_force/rule.yml b/linux_os/guide/system/bootloader-grub2/grub2_enable_iommu_force/rule.yml
07cb6b
index 0a0d76aeb23..1ff5a4d5f26 100644
07cb6b
--- a/linux_os/guide/system/bootloader-grub2/grub2_enable_iommu_force/rule.yml
07cb6b
+++ b/linux_os/guide/system/bootloader-grub2/grub2_enable_iommu_force/rule.yml
07cb6b
@@ -5,9 +5,10 @@ title: 'IOMMU configuration directive'
07cb6b
 description: |-
07cb6b
     On x86 architecture supporting VT-d, the IOMMU manages the access control policy between the hardware devices and some
07cb6b
         of the system critical units such as the memory.
07cb6b
+    {{{ describe_grub2_argument("iommu=force") | indent(4) }}}
07cb6b
 
07cb6b
 rationale: |-
07cb6b
-    On x86 architectures, activating the I/OMMU prevents the system from arbritrary accesses potentially made by
07cb6b
+    On x86 architectures, activating the I/OMMU prevents the system from arbitrary accesses potentially made by
07cb6b
         hardware devices.
07cb6b
 
07cb6b
 severity: unknown
07cb6b
@@ -22,6 +23,12 @@ references:
07cb6b
 
07cb6b
 platform: machine
07cb6b
 
07cb6b
+ocil_clause: 'I/OMMU is not activated'
07cb6b
+
07cb6b
+ocil: |-
07cb6b
+    {{{ ocil_grub2_argument("iommu=force") | indent(4) }}}
07cb6b
+
07cb6b
+
07cb6b
 warnings:
07cb6b
   - functionality:
07cb6b
       Depending on the hardware, devices and operating system used, enabling IOMMU can cause hardware instabilities.
07cb6b
diff --git a/linux_os/guide/system/bootloader-grub2/grub2_init_on_alloc_argument/rule.yml b/linux_os/guide/system/bootloader-grub2/grub2_init_on_alloc_argument/rule.yml
07cb6b
index a9253c74cc6..3bb645dadb7 100644
07cb6b
--- a/linux_os/guide/system/bootloader-grub2/grub2_init_on_alloc_argument/rule.yml
07cb6b
+++ b/linux_os/guide/system/bootloader-grub2/grub2_init_on_alloc_argument/rule.yml
07cb6b
@@ -6,12 +6,8 @@ title: 'Configure kernel to zero out memory before allocation'
07cb6b
 
07cb6b
 description: |-
07cb6b
     To configure the kernel to zero out memory before allocating it, add the
07cb6b
-    <tt>init_on_alloc=1</tt> argument to the default GRUB 2 command line for
07cb6b
-    the Linux operating system in <tt>/etc/default/grub</tt>, in the manner
07cb6b
-    below:
07cb6b
-    
GRUB_CMDLINE_LINUX="crashkernel=auto quiet rd.shell=0 audit=1 audit_backlog_limit=8192 init_on_alloc=1"
07cb6b
-    Update the boot parameter for existing kernels by running the following command:
07cb6b
-    
# grubby --update-kernel=ALL --args="init_on_alloc=1"
07cb6b
+    <tt>init_on_alloc=1</tt> argument to the default GRUB 2 command line.
07cb6b
+    {{{ describe_grub2_argument("init_on_alloc=1") | indent(4) }}}
07cb6b
 
07cb6b
 rationale: |-
07cb6b
     When the kernel configuration option <tt>init_on_alloc</tt> is enabled,
07cb6b
@@ -27,15 +23,7 @@ identifiers:
07cb6b
 ocil_clause: 'the kernel is not configured to zero out memory before allocation'
07cb6b
 
07cb6b
 ocil: |-
07cb6b
-    Make sure that the kernel is configured to zero out memory before
07cb6b
-    allocation. Ensure that the parameter is configured in
07cb6b
-    <tt>/etc/default/grub</tt>:
07cb6b
-    
grep GRUB_CMDLINE_LINUX /etc/default/grub
07cb6b
-    The output should contain <tt>init_on_alloc=1</tt>.
07cb6b
-    Run the following command to display command line parameters of all
07cb6b
-    installed kernels:
07cb6b
-    
# grubby --info=ALL | grep args
07cb6b
-    Ensure that each line contains the <tt>init_on_alloc=1</tt> parameter.
07cb6b
+    {{{ ocil_grub2_argument("init_on_alloc=1") | indent(4) }}}
07cb6b
 
07cb6b
 platform: machine
07cb6b
 
07cb6b
diff --git a/linux_os/guide/system/bootloader-grub2/grub2_kernel_trust_cpu_rng/rule.yml b/linux_os/guide/system/bootloader-grub2/grub2_kernel_trust_cpu_rng/rule.yml
07cb6b
index 308ae9cb735..d6bfc02f345 100644
07cb6b
--- a/linux_os/guide/system/bootloader-grub2/grub2_kernel_trust_cpu_rng/rule.yml
07cb6b
+++ b/linux_os/guide/system/bootloader-grub2/grub2_kernel_trust_cpu_rng/rule.yml
07cb6b
@@ -11,8 +11,8 @@ description: |-
07cb6b
     <tt>Y</tt>, make sure that it is not overridden with the boot parameter.
07cb6b
     There must not exist the boot parameter <tt>random.trust_cpu=off</tt>. If
07cb6b
     the option is not compiled in, make sure that <tt>random.trust_cpu=on</tt>
07cb6b
-    is configured as a boot parameter by running the following command:
07cb6b
-    
sudo grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) random.trust_cpu=on"
07cb6b
+    is configured as a boot parameter.
07cb6b
+    {{{ describe_grub2_argument("random.trust_cpu=on") | indent(4) }}}
07cb6b
 
07cb6b
 rationale: |-
07cb6b
     The Linux kernel offers an option which signifies if the kernel should trust
07cb6b
@@ -44,11 +44,8 @@ ocil: |-
07cb6b
     option is not overridden through a boot parameter:
07cb6b
     
sudo grep 'kernelopts.*random\.trust_cpu=off.*' {{{ grub2_boot_path }}}/grubenv
07cb6b
     The command should not return any output. If the option is not compiled into
07cb6b
-    the kernel, check that the option is configured through boot parameter with
07cb6b
-    the following command:
07cb6b
-    
sudo grep 'kernelopts.*random\.trust_cpu=on.*' {{{ grub2_boot_path }}}/grubenv
07cb6b
-    If the command does not return any output, then the boot parameter is
07cb6b
-    missing.
07cb6b
+    the kernel, check that the option is configured through boot parameter.
07cb6b
+    {{{ ocil_grub2_argument("random.trust_cpu=on") | indent(4) }}}
07cb6b
 
07cb6b
 platform: machine
07cb6b
 
07cb6b
diff --git a/linux_os/guide/system/bootloader-grub2/grub2_pti_argument/rule.yml b/linux_os/guide/system/bootloader-grub2/grub2_pti_argument/rule.yml
07cb6b
index f4f3fa39510..51b0a284746 100644
07cb6b
--- a/linux_os/guide/system/bootloader-grub2/grub2_pti_argument/rule.yml
07cb6b
+++ b/linux_os/guide/system/bootloader-grub2/grub2_pti_argument/rule.yml
07cb6b
@@ -7,9 +7,8 @@ title: 'Enable Kernel Page-Table Isolation (KPTI)'
07cb6b
 description: |-
07cb6b
     To enable Kernel page-table isolation,
07cb6b
     add the argument <tt>pti=on</tt> to the default
07cb6b
-    GRUB 2 command line for the Linux operating system in
07cb6b
-    <tt>/etc/default/grub</tt>, in the manner below:
07cb6b
-    
GRUB_CMDLINE_LINUX="pti=on"
07cb6b
+    GRUB 2 command line for the Linux operating system.
07cb6b
+    {{{ describe_grub2_argument("pti=on") | indent(4) }}}
07cb6b
 
07cb6b
 rationale: |-
07cb6b
     Kernel page-table isolation is a kernel feature that mitigates
07cb6b
@@ -33,15 +32,7 @@ references:
07cb6b
 ocil_clause: 'Kernel page-table isolation is not enabled'
07cb6b
 
07cb6b
 ocil: |-
07cb6b
-    Inspect the form of default GRUB 2 command line for the Linux operating system
07cb6b
-    in <tt>/etc/default/grub</tt>. If they include <tt>pti=on</tt>,
07cb6b
-    then Kernel page-table isolation is enabled at boot time.
07cb6b
-    

07cb6b
-    To ensure <tt>pti=on</tt> is configured on all installed kernels, the
07cb6b
-    following command may be used:
07cb6b
-    
07cb6b
-    
$ sudo /sbin/grubby --update-kernel=ALL --args="pti=on
07cb6b
-    
07cb6b
+    {{{ ocil_grub2_argument("pti=on") | indent(4) }}}
07cb6b
 
07cb6b
 warnings:
07cb6b
     - management: |-
07cb6b
diff --git a/linux_os/guide/system/bootloader-grub2/grub2_vsyscall_argument/rule.yml b/linux_os/guide/system/bootloader-grub2/grub2_vsyscall_argument/rule.yml
07cb6b
index 9f38a1c13b9..1b88d13bd3c 100644
07cb6b
--- a/linux_os/guide/system/bootloader-grub2/grub2_vsyscall_argument/rule.yml
07cb6b
+++ b/linux_os/guide/system/bootloader-grub2/grub2_vsyscall_argument/rule.yml
07cb6b
@@ -7,9 +7,8 @@ title: 'Disable vsyscalls'
07cb6b
 description: |-
07cb6b
     To disable use of virtual syscalls,
07cb6b
     add the argument <tt>vsyscall=none</tt> to the default
07cb6b
-    GRUB 2 command line for the Linux operating system in
07cb6b
-    <tt>/etc/default/grub</tt>, in the manner below:
07cb6b
-    
GRUB_CMDLINE_LINUX="vsyscall=none"
07cb6b
+    GRUB 2 command line for the Linux operating system.
07cb6b
+    {{{ describe_grub2_argument("vsyscall=none") | indent(4) }}}
07cb6b
 
07cb6b
 rationale: |-
07cb6b
     Virtual Syscalls provide an opportunity of attack for a user who has control
07cb6b
@@ -33,15 +32,7 @@ references:
07cb6b
 ocil_clause: 'vsyscalls are enabled'
07cb6b
 
07cb6b
 ocil: |-
07cb6b
-    Inspect the form of default GRUB 2 command line for the Linux operating system
07cb6b
-    in <tt>/etc/default/grub</tt>. If they include <tt>vsyscall=none</tt>,
07cb6b
-    then virtyal syscalls are not enabled at boot time.
07cb6b
-    

07cb6b
-    To ensure <tt>vsyscall=none</tt> is configured on all installed kernels, the
07cb6b
-    following command may be used:
07cb6b
-    
07cb6b
-    
$ sudo /sbin/grubby --update-kernel=ALL --args="vsyscall=none
07cb6b
-    
07cb6b
+    {{{ ocil_grub2_argument("vsyscall=none") | indent(4) }}}
07cb6b
 
07cb6b
 warnings:
07cb6b
     - management: |-
07cb6b
diff --git a/linux_os/guide/system/network/network-ipv6/disabling_ipv6/grub2_ipv6_disable_argument/rule.yml b/linux_os/guide/system/network/network-ipv6/disabling_ipv6/grub2_ipv6_disable_argument/rule.yml
07cb6b
index b8ff66c7d6e..c0fda343a1a 100644
07cb6b
--- a/linux_os/guide/system/network/network-ipv6/disabling_ipv6/grub2_ipv6_disable_argument/rule.yml
07cb6b
+++ b/linux_os/guide/system/network/network-ipv6/disabling_ipv6/grub2_ipv6_disable_argument/rule.yml
07cb6b
@@ -7,20 +7,8 @@ title: 'Ensure IPv6 is disabled through kernel boot parameter'
07cb6b
 description: |-
07cb6b
     To disable IPv6 protocol support in the Linux kernel,
07cb6b
     add the argument <tt>ipv6.disable=1</tt> to the default
07cb6b
-    GRUB2 command line for the Linux operating system in
07cb6b
-{{% if product in ["rhel7", "ol7"] %}}
07cb6b
-    <tt>/etc/default/grub</tt>, so that the line looks similar to
07cb6b
-    
GRUB_CMDLINE_LINUX="... ipv6.disable=1 ..."
07cb6b
-    In case the <tt>GRUB_DISABLE_RECOVERY</tt> is set to true, then the parameter should be added to the <tt>GRUB_CMDLINE_LINUX_DEFAULT</tt> instead.
07cb6b
-    Run one of following command to ensure that the configuration is applied when booting currently installed kernels:
07cb6b
-    
sudo grub2-mkconfig -o {{{ grub2_boot_path }}}/grub.cfg
07cb6b
-    or
07cb6b
-    
sudo /sbin/grubby --update-kernel=ALL --args="ipv6.disable=1"
07cb6b
-{{% else %}}
07cb6b
-    <tt>{{{ grub2_boot_path }}}/grubenv</tt>, in the manner below:
07cb6b
-    
sudo  grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) ipv6.disable=1"
07cb6b
-{{% endif %}}
07cb6b
-
07cb6b
+    GRUB2 command line for the Linux operating system.
07cb6b
+    {{{ describe_grub2_argument("ipv6.disable=1") | indent(4) }}}
07cb6b
 
07cb6b
 rationale: |-
07cb6b
     Any unnecessary network stacks, including IPv6, should be disabled to reduce
07cb6b
@@ -40,34 +28,7 @@ references:
07cb6b
 ocil_clause: 'IPv6 is not disabled'
07cb6b
 
07cb6b
 ocil: |-
07cb6b
-    {{% if product in ["rhel7", "ol7"] %}}
07cb6b
-    Inspect the form of default GRUB2 command line for the Linux operating system
07cb6b
-    in <tt>/etc/default/grub</tt>. Check if it includes <tt>ipv6.disable=1</tt>.
07cb6b
-    First check if the GRUB recovery is enabled:
07cb6b
-    
grep 'GRUB_DISABLE_RECOVERY' /etc/default/grub
07cb6b
-    If this option is set to true, then check that the following line is output by the following command:
07cb6b
-    
grep 'GRUB_CMDLINE_LINUX_DEFAULT.*ipv6.disable=1.*' /etc/default/grub
07cb6b
-    If the recovery is disabled, check the line with
07cb6b
-    
grep 'GRUB_CMDLINE_LINUX.*ipv6.disable=1.*' /etc/default/grub
.
07cb6b
-    Moreover, current GRUB2 config file in <tt>/etc/grub2/grub.cfg</tt> must be checked.
07cb6b
-    
sudo grep vmlinuz {{{ grub2_boot_path }}}/grub.cfg | grep -v 'ipv6.disable=1'
07cb6b
-    This command should not return any output. If it does, update the configuration with one of following commands:
07cb6b
-    
sudo grub2-mkconfig -o {{{ grub2_boot_path }}}/grub.cfg
07cb6b
-    or
07cb6b
-    
sudo /sbin/grubby --update-kernel=ALL --args="ipv6.disable=1"
07cb6b
-    
07cb6b
-{{% else %}}
07cb6b
-    Inspect the form of default GRUB2 command line for the Linux operating system
07cb6b
-    in <tt>{{{ grub2_boot_path }}}/grubenv</tt>. Check if it includes <tt>ipv6.disable=1</tt>.
07cb6b
-    
sudo grep 'kernelopts.*ipv6.disable=1.*' {{{ grub2_boot_path }}}/grubenv
07cb6b
-    

07cb6b
-    To ensure <tt>ipv6.disable=1</tt> is configured on all installed kernels, the
07cb6b
-    following command may be used:
07cb6b
-    
07cb6b
-    
sudo grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) ipv6.disable=1"
07cb6b
-    
07cb6b
-{{% endif %}}
07cb6b
-
07cb6b
+    {{{ ocil_grub2_argument("ipv6.disable=1") | indent(4) }}}
07cb6b
 
07cb6b
 warnings:
07cb6b
     - management: |-
07cb6b
diff --git a/linux_os/guide/system/permissions/restrictions/poisoning/grub2_page_poison_argument/rule.yml b/linux_os/guide/system/permissions/restrictions/poisoning/grub2_page_poison_argument/rule.yml
07cb6b
index 3bf592fb4d8..1f4e183d9e7 100644
07cb6b
--- a/linux_os/guide/system/permissions/restrictions/poisoning/grub2_page_poison_argument/rule.yml
07cb6b
+++ b/linux_os/guide/system/permissions/restrictions/poisoning/grub2_page_poison_argument/rule.yml
07cb6b
@@ -7,9 +7,8 @@ title: 'Enable page allocator poisoning'
07cb6b
 description: |-
07cb6b
     To enable poisoning of free pages,
07cb6b
     add the argument <tt>page_poison=1</tt> to the default
07cb6b
-    GRUB 2 command line for the Linux operating system in
07cb6b
-    <tt>/etc/default/grub</tt>, in the manner below:
07cb6b
-    
GRUB_CMDLINE_LINUX="page_poison=1"
07cb6b
+    GRUB 2 command line for the Linux operating system.
07cb6b
+    {{{ describe_grub2_argument("page_poison=1") | indent(4) }}}
07cb6b
 
07cb6b
 rationale: |-
07cb6b
     Poisoning writes an arbitrary value to freed pages, so any modification or
07cb6b
@@ -35,15 +34,7 @@ references:
07cb6b
 ocil_clause: 'page allocator poisoning is not enabled'
07cb6b
 
07cb6b
 ocil: |-
07cb6b
-    Inspect the form of default GRUB 2 command line for the Linux operating system
07cb6b
-    in <tt>/etc/default/grub</tt>. If they include <tt>page_poison=1</tt>,
07cb6b
-    then page poisoning is enabled at boot time.
07cb6b
-    

07cb6b
-    To ensure <tt>page_poison=1</tt> is configured on all installed kernels, the
07cb6b
-    following command may be used:
07cb6b
-    
07cb6b
-    
$ sudo /sbin/grubby --update-kernel=ALL --args="page_poison=1
07cb6b
-    
07cb6b
+    {{{ ocil_grub2_argument("page_poison=1") | indent(4) }}}
07cb6b
 
07cb6b
 warnings:
07cb6b
     - management: |-
07cb6b
diff --git a/linux_os/guide/system/permissions/restrictions/poisoning/grub2_slub_debug_argument/rule.yml b/linux_os/guide/system/permissions/restrictions/poisoning/grub2_slub_debug_argument/rule.yml
07cb6b
index 9964399650a..bb5dbc6c125 100644
07cb6b
--- a/linux_os/guide/system/permissions/restrictions/poisoning/grub2_slub_debug_argument/rule.yml
07cb6b
+++ b/linux_os/guide/system/permissions/restrictions/poisoning/grub2_slub_debug_argument/rule.yml
07cb6b
@@ -7,9 +7,8 @@ title: 'Enable SLUB/SLAB allocator poisoning'
07cb6b
 description: |-
07cb6b
     To enable poisoning of SLUB/SLAB objects,
07cb6b
     add the argument <tt>slub_debug=P</tt> to the default
07cb6b
-    GRUB 2 command line for the Linux operating system in
07cb6b
-    <tt>/etc/default/grub</tt>, in the manner below:
07cb6b
-    
GRUB_CMDLINE_LINUX="slub_debug=P"
07cb6b
+    GRUB 2 command line for the Linux operating system.
07cb6b
+    {{{ describe_grub2_argument("slub_debug=P") | indent(4) }}}
07cb6b
 
07cb6b
 rationale: |-
07cb6b
     Poisoning writes an arbitrary value to freed objects, so any modification or
07cb6b
@@ -35,15 +34,7 @@ references:
07cb6b
 ocil_clause: 'SLUB/SLAB poisoning is not enabled'
07cb6b
 
07cb6b
 ocil: |-
07cb6b
-    Inspect the form of default GRUB 2 command line for the Linux operating system
07cb6b
-    in <tt>/etc/default/grub</tt>. If they include <tt>slub_debug=P</tt>,
07cb6b
-    then SLUB/SLAB poisoning is enabled at boot time.
07cb6b
-    

07cb6b
-    To ensure <tt>slub_debug=P</tt> is configured on all installed kernels, the
07cb6b
-    following command may be used:
07cb6b
-    
07cb6b
-    
$ sudo /sbin/grubby --update-kernel=ALL --args="slub_debug=P
07cb6b
-    
07cb6b
+    {{{ ocil_grub2_argument("slub_debug=P") | indent(4) }}}
07cb6b
 
07cb6b
 warnings:
07cb6b
     - management: |-
07cb6b
07cb6b
From 5c39cf81d49f0eb5bb73337057fb95356784e5c6 Mon Sep 17 00:00:00 2001
07cb6b
From: Vojtech Polasek <vpolasek@redhat.com>
07cb6b
Date: Wed, 9 Feb 2022 16:05:59 +0100
07cb6b
Subject: [PATCH 5/8] fix an error in ubuntu version of macro
07cb6b
07cb6b
---
07cb6b
 shared/macros.jinja | 2 +-
07cb6b
 1 file changed, 1 insertion(+), 1 deletion(-)
07cb6b
07cb6b
diff --git a/shared/macros.jinja b/shared/macros.jinja
07cb6b
index 16a0404b668..54d2b299a47 100644
07cb6b
--- a/shared/macros.jinja
07cb6b
+++ b/shared/macros.jinja
07cb6b
@@ -1660,7 +1660,7 @@ If this option is set to true, then check that a line is output by the following
07cb6b
 If the recovery is disabled, check the line with
07cb6b
 
$ grep 'GRUB_CMDLINE_LINUX.*{{{ arg_name_value }}}.*' /etc/default/grub
.
07cb6b
 {{%- if 'ubuntu' in product -%}}
07cb6b
-Moreover, current Grub2 config file in <tt>/etc/grub2/grub.cfg</tt> must be checked.
07cb6b
+Moreover, current Grub2 config file in <tt>{{{ grub2_boot_path }}}/grub.cfg</tt> must be checked.
07cb6b
 
# grep vmlinuz {{{ grub2_boot_path }}}/grub.cfg | grep -v '{{{ arg_name_value }}}'
07cb6b
 This command should not return any output.
07cb6b
 {{%- else -%}}
07cb6b
07cb6b
From f100d190833d168127715215e788347f806736f3 Mon Sep 17 00:00:00 2001
07cb6b
From: Vojtech Polasek <vpolasek@redhat.com>
07cb6b
Date: Wed, 9 Feb 2022 16:16:21 +0100
07cb6b
Subject: [PATCH 6/8] remove warnings from rules
07cb6b
07cb6b
they are no longer relevant, we do not use grub2-mkconfig anymore
07cb6b
---
07cb6b
 .../auditing/grub2_audit_argument/rule.yml     | 18 ------------------
07cb6b
 .../rule.yml                                   | 18 ------------------
07cb6b
 .../grub2_pti_argument/rule.yml                | 18 ------------------
07cb6b
 .../grub2_vsyscall_argument/rule.yml           | 18 ------------------
07cb6b
 .../grub2_ipv6_disable_argument/rule.yml       | 18 ------------------
07cb6b
 .../grub2_page_poison_argument/rule.yml        | 18 ------------------
07cb6b
 .../grub2_slub_debug_argument/rule.yml         | 18 ------------------
07cb6b
 7 files changed, 126 deletions(-)
07cb6b
07cb6b
diff --git a/linux_os/guide/system/auditing/grub2_audit_argument/rule.yml b/linux_os/guide/system/auditing/grub2_audit_argument/rule.yml
07cb6b
index aff0521ee73..00a4ded2738 100644
07cb6b
--- a/linux_os/guide/system/auditing/grub2_audit_argument/rule.yml
07cb6b
+++ b/linux_os/guide/system/auditing/grub2_audit_argument/rule.yml
07cb6b
@@ -54,24 +54,6 @@ ocil_clause: 'auditing is not enabled at boot time'
07cb6b
 ocil: |-
07cb6b
     {{{ ocil_grub2_argument("audit=1") | indent(4) }}}
07cb6b
 
07cb6b
-warnings:
07cb6b
-    - management: |-
07cb6b
-        The GRUB 2 configuration file, <tt>grub.cfg</tt>,
07cb6b
-        is automatically updated each time a new kernel is installed. Note that any
07cb6b
-        changes to <tt>/etc/default/grub</tt> require rebuilding the <tt>grub.cfg</tt>
07cb6b
-        file. To update the GRUB 2 configuration file manually, use the
07cb6b
-        
grub2-mkconfig -o
command as follows:
07cb6b
-        
    07cb6b
    -        
  • On BIOS-based machines, issue the following command as <tt>root</tt>:
  • 07cb6b
    -        
    ~]# grub2-mkconfig -o {{{ grub2_boot_path }}}/grub.cfg
    07cb6b
    -        
  • On UEFI-based machines, issue the following command as <tt>root</tt>:
  • 07cb6b
    -{{% if product in ["rhel7", "ol7", "rhel8", "ol8"] %}}
    07cb6b
    -        
    ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
    07cb6b
    -{{% else %}}
    07cb6b
    -        
    ~]# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
    07cb6b
    -{{% endif %}}
    07cb6b
    -        
    07cb6b
    -
    07cb6b
     platform: grub2
    07cb6b
     
    07cb6b
     template:
    07cb6b
    diff --git a/linux_os/guide/system/auditing/grub2_audit_backlog_limit_argument/rule.yml b/linux_os/guide/system/auditing/grub2_audit_backlog_limit_argument/rule.yml
    07cb6b
    index 868d525014f..efbc3dae1c1 100644
    07cb6b
    --- a/linux_os/guide/system/auditing/grub2_audit_backlog_limit_argument/rule.yml
    07cb6b
    +++ b/linux_os/guide/system/auditing/grub2_audit_backlog_limit_argument/rule.yml
    07cb6b
    @@ -41,24 +41,6 @@ ocil_clause: 'audit backlog limit is not configured'
    07cb6b
     ocil: |-
    07cb6b
         {{{ ocil_grub2_argument("audit_backlog_limit=8192") | indent(4) }}}
    07cb6b
     
    07cb6b
    -warnings:
    07cb6b
    -    - management: |-
    07cb6b
    -        The GRUB 2 configuration file, <tt>grub.cfg</tt>,
    07cb6b
    -        is automatically updated each time a new kernel is installed. Note that any
    07cb6b
    -        changes to <tt>/etc/default/grub</tt> require rebuilding the <tt>grub.cfg</tt>
    07cb6b
    -        file. To update the GRUB 2 configuration file manually, use the
    07cb6b
    -        
    grub2-mkconfig -o
    command as follows:
    07cb6b
    -        
      07cb6b
      -        
    • On BIOS-based machines, issue the following command as <tt>root</tt>:
    • 07cb6b
      -        
      ~]# grub2-mkconfig -o {{{ grub2_boot_path }}}/grub.cfg
      07cb6b
      -        
    • On UEFI-based machines, issue the following command as <tt>root</tt>:
    • 07cb6b
      -{{% if product in ["rhel7", "rhel8", "ol7", "ol8"] %}}
      07cb6b
      -        
      ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
      07cb6b
      -{{% else %}}
      07cb6b
      -        
      ~]# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
      07cb6b
      -{{% endif %}}
      07cb6b
      -        
      07cb6b
      -
      07cb6b
       platform: grub2
      07cb6b
       
      07cb6b
       template:
      07cb6b
      diff --git a/linux_os/guide/system/bootloader-grub2/grub2_pti_argument/rule.yml b/linux_os/guide/system/bootloader-grub2/grub2_pti_argument/rule.yml
      07cb6b
      index 51b0a284746..52a308e3247 100644
      07cb6b
      --- a/linux_os/guide/system/bootloader-grub2/grub2_pti_argument/rule.yml
      07cb6b
      +++ b/linux_os/guide/system/bootloader-grub2/grub2_pti_argument/rule.yml
      07cb6b
      @@ -34,24 +34,6 @@ ocil_clause: 'Kernel page-table isolation is not enabled'
      07cb6b
       ocil: |-
      07cb6b
           {{{ ocil_grub2_argument("pti=on") | indent(4) }}}
      07cb6b
       
      07cb6b
      -warnings:
      07cb6b
      -    - management: |-
      07cb6b
      -        The GRUB 2 configuration file, <tt>grub.cfg</tt>,
      07cb6b
      -        is automatically updated each time a new kernel is installed. Note that any
      07cb6b
      -        changes to <tt>/etc/default/grub</tt> require rebuilding the <tt>grub.cfg</tt>
      07cb6b
      -        file. To update the GRUB 2 configuration file manually, use the
      07cb6b
      -        
      grub2-mkconfig -o
      command as follows:
      07cb6b
      -        
        07cb6b
        -        
      • On BIOS-based machines, issue the following command as <tt>root</tt>:
      • 07cb6b
        -        
        ~]# grub2-mkconfig -o {{{ grub2_boot_path }}}/grub.cfg
        07cb6b
        -        
      • On UEFI-based machines, issue the following command as <tt>root</tt>:
      • 07cb6b
        -{{% if product in ["rhel8", "ol8"] %}}
        07cb6b
        -        
        ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
        07cb6b
        -{{% else %}}
        07cb6b
        -        
        ~]# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
        07cb6b
        -{{% endif %}}
        07cb6b
        -        
        07cb6b
        -
        07cb6b
         platform: machine
        07cb6b
         
        07cb6b
         template:
        07cb6b
        diff --git a/linux_os/guide/system/bootloader-grub2/grub2_vsyscall_argument/rule.yml b/linux_os/guide/system/bootloader-grub2/grub2_vsyscall_argument/rule.yml
        07cb6b
        index 1b88d13bd3c..93eb31dad7b 100644
        07cb6b
        --- a/linux_os/guide/system/bootloader-grub2/grub2_vsyscall_argument/rule.yml
        07cb6b
        +++ b/linux_os/guide/system/bootloader-grub2/grub2_vsyscall_argument/rule.yml
        07cb6b
        @@ -34,24 +34,6 @@ ocil_clause: 'vsyscalls are enabled'
        07cb6b
         ocil: |-
        07cb6b
             {{{ ocil_grub2_argument("vsyscall=none") | indent(4) }}}
        07cb6b
         
        07cb6b
        -warnings:
        07cb6b
        -    - management: |-
        07cb6b
        -        The GRUB 2 configuration file, <tt>grub.cfg</tt>,
        07cb6b
        -        is automatically updated each time a new kernel is installed. Note that any
        07cb6b
        -        changes to <tt>/etc/default/grub</tt> require rebuilding the <tt>grub.cfg</tt>
        07cb6b
        -        file. To update the GRUB 2 configuration file manually, use the
        07cb6b
        -        
        grub2-mkconfig -o
        command as follows:
        07cb6b
        -        
          07cb6b
          -        
        • On BIOS-based machines, issue the following command as <tt>root</tt>:
        • 07cb6b
          -        
          ~]# grub2-mkconfig -o {{{ grub2_boot_path }}}/grub.cfg
          07cb6b
          -        
        • On UEFI-based machines, issue the following command as <tt>root</tt>:
        • 07cb6b
          -{{% if product in ["rhel7", "rhel8", "ol7", "ol8"] %}}
          07cb6b
          -        
          ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
          07cb6b
          -{{% else %}}
          07cb6b
          -        
          ~]# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
          07cb6b
          -{{% endif %}}
          07cb6b
          -        
          07cb6b
          -
          07cb6b
           platform: machine
          07cb6b
           
          07cb6b
           template:
          07cb6b
          diff --git a/linux_os/guide/system/network/network-ipv6/disabling_ipv6/grub2_ipv6_disable_argument/rule.yml b/linux_os/guide/system/network/network-ipv6/disabling_ipv6/grub2_ipv6_disable_argument/rule.yml
          07cb6b
          index c0fda343a1a..9e1ca48efe0 100644
          07cb6b
          --- a/linux_os/guide/system/network/network-ipv6/disabling_ipv6/grub2_ipv6_disable_argument/rule.yml
          07cb6b
          +++ b/linux_os/guide/system/network/network-ipv6/disabling_ipv6/grub2_ipv6_disable_argument/rule.yml
          07cb6b
          @@ -30,24 +30,6 @@ ocil_clause: 'IPv6 is not disabled'
          07cb6b
           ocil: |-
          07cb6b
               {{{ ocil_grub2_argument("ipv6.disable=1") | indent(4) }}}
          07cb6b
           
          07cb6b
          -warnings:
          07cb6b
          -    - management: |-
          07cb6b
          -        The GRUB 2 configuration file, <tt>grub.cfg</tt>,
          07cb6b
          -        is automatically updated each time a new kernel is installed. Note that any
          07cb6b
          -        changes to <tt>/etc/default/grub</tt> require rebuilding the <tt>grub.cfg</tt>
          07cb6b
          -        file. To update the GRUB 2 configuration file manually, use the
          07cb6b
          -        
          grub2-mkconfig -o
          command as follows:
          07cb6b
          -        
            07cb6b
            -        
          • On BIOS-based machines, issue the following command:
          • 07cb6b
            -        
            sudo grub2-mkconfig -o {{{ grub2_boot_path }}}/grub.cfg
            07cb6b
            -        
          • On UEFI-based machines, issue the following command:
          • 07cb6b
            -{{% if product in ["rhel7", "ol7", "rhel8", "ol8"] %}}
            07cb6b
            -        
            sudo grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
            07cb6b
            -{{% else %}}
            07cb6b
            -        
            sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
            07cb6b
            -{{% endif %}}
            07cb6b
            -        
            07cb6b
            -
            07cb6b
             platform: grub2
            07cb6b
             
            07cb6b
             template:
            07cb6b
            diff --git a/linux_os/guide/system/permissions/restrictions/poisoning/grub2_page_poison_argument/rule.yml b/linux_os/guide/system/permissions/restrictions/poisoning/grub2_page_poison_argument/rule.yml
            07cb6b
            index 1f4e183d9e7..1ad6c6b3c44 100644
            07cb6b
            --- a/linux_os/guide/system/permissions/restrictions/poisoning/grub2_page_poison_argument/rule.yml
            07cb6b
            +++ b/linux_os/guide/system/permissions/restrictions/poisoning/grub2_page_poison_argument/rule.yml
            07cb6b
            @@ -36,24 +36,6 @@ ocil_clause: 'page allocator poisoning is not enabled'
            07cb6b
             ocil: |-
            07cb6b
                 {{{ ocil_grub2_argument("page_poison=1") | indent(4) }}}
            07cb6b
             
            07cb6b
            -warnings:
            07cb6b
            -    - management: |-
            07cb6b
            -        The GRUB 2 configuration file, <tt>grub.cfg</tt>,
            07cb6b
            -        is automatically updated each time a new kernel is installed. Note that any
            07cb6b
            -        changes to <tt>/etc/default/grub</tt> require rebuilding the <tt>grub.cfg</tt>
            07cb6b
            -        file. To update the GRUB 2 configuration file manually, use the
            07cb6b
            -        
            grub2-mkconfig -o
            command as follows:
            07cb6b
            -        
              07cb6b
              -        
            • On BIOS-based machines, issue the following command as <tt>root</tt>:
            • 07cb6b
              -        
              ~]# grub2-mkconfig -o {{{ grub2_boot_path }}}/grub.cfg
              07cb6b
              -        
            • On UEFI-based machines, issue the following command as <tt>root</tt>:
            • 07cb6b
              -{{% if product in ["rhel7", "rhel8", "ol7", "ol8"] %}}
              07cb6b
              -        
              ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
              07cb6b
              -{{% else %}}
              07cb6b
              -        
              ~]# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
              07cb6b
              -{{% endif %}}
              07cb6b
              -        
              07cb6b
              -
              07cb6b
               platform: grub2
              07cb6b
               
              07cb6b
               template:
              07cb6b
              diff --git a/linux_os/guide/system/permissions/restrictions/poisoning/grub2_slub_debug_argument/rule.yml b/linux_os/guide/system/permissions/restrictions/poisoning/grub2_slub_debug_argument/rule.yml
              07cb6b
              index bb5dbc6c125..e40f5377c61 100644
              07cb6b
              --- a/linux_os/guide/system/permissions/restrictions/poisoning/grub2_slub_debug_argument/rule.yml
              07cb6b
              +++ b/linux_os/guide/system/permissions/restrictions/poisoning/grub2_slub_debug_argument/rule.yml
              07cb6b
              @@ -36,24 +36,6 @@ ocil_clause: 'SLUB/SLAB poisoning is not enabled'
              07cb6b
               ocil: |-
              07cb6b
                   {{{ ocil_grub2_argument("slub_debug=P") | indent(4) }}}
              07cb6b
               
              07cb6b
              -warnings:
              07cb6b
              -    - management: |-
              07cb6b
              -        The GRUB 2 configuration file, <tt>grub.cfg</tt>,
              07cb6b
              -        is automatically updated each time a new kernel is installed. Note that any
              07cb6b
              -        changes to <tt>/etc/default/grub</tt> require rebuilding the <tt>grub.cfg</tt>
              07cb6b
              -        file. To update the GRUB 2 configuration file manually, use the
              07cb6b
              -        
              grub2-mkconfig -o
              command as follows:
              07cb6b
              -        
                07cb6b
                -        
              • On BIOS-based machines, issue the following command as <tt>root</tt>:
              • 07cb6b
                -        
                ~]# grub2-mkconfig -o {{{ grub2_boot_path }}}/grub.cfg
                07cb6b
                -        
              • On UEFI-based machines, issue the following command as <tt>root</tt>:
              • 07cb6b
                -{{% if product in ["rhel7", "rhel8", "ol7", "ol8"] %}}
                07cb6b
                -        
                ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
                07cb6b
                -{{% else %}}
                07cb6b
                -        
                ~]# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
                07cb6b
                -{{% endif %}}
                07cb6b
                -        
                07cb6b
                -
                07cb6b
                 platform: grub2
                07cb6b
                 
                07cb6b
                 template:
                07cb6b
                07cb6b
                From bbc3cc093004efd0457ccb33722a4fb14b0b2fb8 Mon Sep 17 00:00:00 2001
                07cb6b
                From: vojtapolasek <krecoun@gmail.com>
                07cb6b
                Date: Mon, 14 Feb 2022 14:29:15 +0100
                07cb6b
                Subject: [PATCH 7/8] Update shared/macros.jinja
                07cb6b
                MIME-Version: 1.0
                07cb6b
                Content-Type: text/plain; charset=UTF-8
                07cb6b
                Content-Transfer-Encoding: 8bit
                07cb6b
                07cb6b
                Co-authored-by: Matěj Týč <matej.tyc@gmail.com>
                07cb6b
                ---
                07cb6b
                 shared/macros.jinja | 7 ++++++-
                07cb6b
                 1 file changed, 6 insertions(+), 1 deletion(-)
                07cb6b
                07cb6b
                diff --git a/shared/macros.jinja b/shared/macros.jinja
                07cb6b
                index 54d2b299a47..392181e2b24 100644
                07cb6b
                --- a/shared/macros.jinja
                07cb6b
                +++ b/shared/macros.jinja
                07cb6b
                @@ -1671,7 +1671,12 @@ The command should not return any output.
                07cb6b
                 {{%- endif -%}}
                07cb6b
                 {{%- else -%}}
                07cb6b
                 Inspect the form of default GRUB 2 command line for the Linux operating system
                07cb6b
                -in <tt>{{{ grub2_boot_path }}}/grubenv</tt>. If they include <tt>{{{ arg_name_value }}}</tt>, then the parameter
                07cb6b
                +{{% if grub2_boot_path == grub2_uefi_boot_path or not grub2_uefi_boot_path -%}}
                07cb6b
                +in <tt>{{{ grub2_boot_path }}}/grubenv</tt>.
                07cb6b
                +{{%- else -%}}
                07cb6b
                +in <tt>grubenv</tt> that can be found either in <tt>{{{ grub2_boot_path }}}</tt> in case of legacy BIOS systems, or in <tt>{{{ grub2_uefi_boot_path }}}</tt> in case of UEFI systems.
                07cb6b
                +{{%- endif %}}
                07cb6b
                +If they include <tt>{{{ arg_name_value }}}</tt>, then the parameter
                07cb6b
                 is configured at boot time.
                07cb6b
                 
                # grep 'kernelopts.*{{{ arg_name_value }}}.*' {{{ grub2_boot_path }}}/grubenv
                07cb6b
                 {{%- endif -%}}
                07cb6b
                07cb6b
                From 8121376668b43d21cf0f9700994bc011c3e313d7 Mon Sep 17 00:00:00 2001
                07cb6b
                From: Vojtech Polasek <vpolasek@redhat.com>
                07cb6b
                Date: Mon, 14 Feb 2022 15:17:33 +0100
                07cb6b
                Subject: [PATCH 8/8] more modifications to description and ocil
                07cb6b
                07cb6b
                final touches
                07cb6b
                ---
                07cb6b
                 shared/macros.jinja | 15 ++++++++++-----
                07cb6b
                 1 file changed, 10 insertions(+), 5 deletions(-)
                07cb6b
                07cb6b
                diff --git a/shared/macros.jinja b/shared/macros.jinja
                07cb6b
                index 392181e2b24..a89bac12f53 100644
                07cb6b
                --- a/shared/macros.jinja
                07cb6b
                +++ b/shared/macros.jinja
                07cb6b
                @@ -1626,7 +1626,7 @@ The audit daemon must be restarted for the changes to take effect.
                07cb6b
                     The parameter should be in form `parameter=value`.
                07cb6b
                 #}}
                07cb6b
                 {{%- macro describe_grub2_argument(arg_name_value) -%}}
                07cb6b
                -{{%- if product in ["rhel7", "ol7", "rhel9"] or 'ubuntu' in product -%}}
                07cb6b
                +{{%- if product in ["rhel7", "ol7", "rhel8", "ol8", "rhel9"] or 'ubuntu' in product -%}}
                07cb6b
                 To ensure that <tt>{{{ arg_name_value }}}</tt> is added as a kernel command line
                07cb6b
                 argument to newly installed kernels, ad <tt>{{{ arg_name_value }}}</tt> to the
                07cb6b
                 default Grub2 command line for Linux operating systems.  Modify the line within
                07cb6b
                @@ -1649,7 +1649,7 @@ Configure the default Grub2 kernel command line to contain {{{ arg_name_value }}
                07cb6b
                     The parameter should have form `parameter=value`.
                07cb6b
                 #}}
                07cb6b
                 {{%- macro ocil_grub2_argument(arg_name_value) -%}}
                07cb6b
                -{{%- if product in ["rhel7", "ol7", "rhel9"] or 'ubuntu' in product -%}}
                07cb6b
                +{{%- if product in ["rhel7", "ol7", "rhel8", "ol8", "rhel9"] or 'ubuntu' in product -%}}
                07cb6b
                 Inspect the form of default GRUB 2 command line for the Linux operating system
                07cb6b
                 in <tt>/etc/default/grub</tt>. If it includes <tt>{{{ arg_name_value }}}</tt>,
                07cb6b
                 then the parameter will be configured for newly installed kernels.
                07cb6b
                @@ -1660,8 +1660,12 @@ If this option is set to true, then check that a line is output by the following
                07cb6b
                 If the recovery is disabled, check the line with
                07cb6b
                 
                $ grep 'GRUB_CMDLINE_LINUX.*{{{ arg_name_value }}}.*' /etc/default/grub
                .
                07cb6b
                 {{%- if 'ubuntu' in product -%}}
                07cb6b
                -Moreover, current Grub2 config file in <tt>{{{ grub2_boot_path }}}/grub.cfg</tt> must be checked.
                07cb6b
                -
                # grep vmlinuz {{{ grub2_boot_path }}}/grub.cfg | grep -v '{{{ arg_name_value }}}'
                07cb6b
                +Moreover, current Grub config file <tt>grub.cfg</tt> must be checked. The file can be found
                07cb6b
                +either in <tt>{{{ grub2_boot_path }}}</tt> in case of legacy BIOS systems, or in <tt>{{{ grub2_uefi_boot_path }}}</tt> in case of UEFI systems.
                07cb6b
                +If they include <tt>{{{ arg_name_value }}}</tt>, then the parameter
                07cb6b
                +is configured at boot time.
                07cb6b
                +
                # grep vmlinuz GRUB_CFG_FILE_PATH | grep -v '{{{ arg_name_value }}}'
                07cb6b
                +Fill in <tt>GRUB_CFG_FILE_PATH</tt> based on information above.
                07cb6b
                 This command should not return any output.
                07cb6b
                 {{%- else -%}}
                07cb6b
                 Moreover, command line parameters for currently installed kernels should be checked as well.
                07cb6b
                @@ -1678,6 +1682,7 @@ in <tt>grubenv</tt> that can be found either in <tt>{{{ grub2_boot_path }}}</tt>
                07cb6b
                 {{%- endif %}}
                07cb6b
                 If they include <tt>{{{ arg_name_value }}}</tt>, then the parameter
                07cb6b
                 is configured at boot time.
                07cb6b
                -
                # grep 'kernelopts.*{{{ arg_name_value }}}.*' {{{ grub2_boot_path }}}/grubenv
                07cb6b
                +
                # grep 'kernelopts.*{{{ arg_name_value }}}.*' GRUBENV_FILE_LOCATION
                07cb6b
                +Fill in <tt>GRUBENV_FILE_LOCATION</tt> based on information above.
                07cb6b
                 {{%- endif -%}}
                07cb6b
                 {{%- endmacro -%}}