Blame SOURCES/scap-security-guide-0.1.64-sysctl_template_extension_and_bpf_rules-PR_9147.patch

49eb97
From 81c2f59f42ffa2cf5a611eaeccc40c802bedd6d7 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Fri, 8 Jul 2022 17:51:57 +0200
49eb97
Subject: [PATCH 01/23] Remove a rule from RHEL 9 OSPP
49eb97
49eb97
Remove rule sysctl_net_core_bpf_jit_harden from RHEL 9 OSPP.  This rule
49eb97
requires to set net.core.bpf_jit_harden value to 2, the RHEL 9 default
49eb97
is 1. However, bpf_jit_harden=1 disables kallsyms access from bpf
49eb97
programs and all users, and it turns on constants blinding by using
49eb97
random value + XOR for CAP_BPF; so the only thing in which value 1 and 2
49eb97
differ is the constants blinding for CAP_SYS_ADMIN processes in the
49eb97
initial user namespaces. The extra constants blinding with
49eb97
bpf_jit_harden=2 does not really help with CVE mitigation.
49eb97
49eb97
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2081728
49eb97
---
49eb97
 products/rhel9/profiles/ospp.profile | 1 -
49eb97
 1 file changed, 1 deletion(-)
49eb97
49eb97
diff --git a/products/rhel9/profiles/ospp.profile b/products/rhel9/profiles/ospp.profile
49eb97
index 244a421fb48..a7ba9532d2c 100644
49eb97
--- a/products/rhel9/profiles/ospp.profile
49eb97
+++ b/products/rhel9/profiles/ospp.profile
49eb97
@@ -75,7 +75,6 @@ selections:
49eb97
     - sysctl_kernel_perf_event_paranoid
49eb97
     - sysctl_user_max_user_namespaces
49eb97
     - sysctl_kernel_unprivileged_bpf_disabled
49eb97
-    - sysctl_net_core_bpf_jit_harden
49eb97
     - service_kdump_disabled
49eb97
 
49eb97
     ### Audit
49eb97
49eb97
From bdcd2bafe5dd68448c0fc13e1aa1be64df607c8f Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Tue, 12 Jul 2022 11:24:42 +0200
49eb97
Subject: [PATCH 02/23] Rename IDs in sysctl OVAL template
49eb97
49eb97
The sysctl template uses its sysctlvar parameter value as a part of OVAL
49eb97
object IDs, test IDs and state IDs. That means we can't have multiple
49eb97
rules using the sysctl template with the same value of sysctlvar
49eb97
parameter (only differ in other parameters) because there would be
49eb97
duplicate elements. We will fix this by using the rule ID as a part of
49eb97
OVAL object IDs, test IDs and state IDs.  That will allow to use the
49eb97
template for the same sysctlvar in different rules.
49eb97
---
49eb97
 .../oval/sysctl_kernel_ipv6_disable.xml       |   4 +-
49eb97
 shared/templates/sysctl/oval.template         | 156 +++++++++---------
49eb97
 2 files changed, 80 insertions(+), 80 deletions(-)
49eb97
49eb97
diff --git a/shared/checks/oval/sysctl_kernel_ipv6_disable.xml b/shared/checks/oval/sysctl_kernel_ipv6_disable.xml
49eb97
index 1195cea518f..f971d28a047 100644
49eb97
--- a/shared/checks/oval/sysctl_kernel_ipv6_disable.xml
49eb97
+++ b/shared/checks/oval/sysctl_kernel_ipv6_disable.xml
49eb97
@@ -19,8 +19,8 @@
49eb97
     </metadata>
49eb97
     <criteria comment="IPv6 disabled or net.ipv6.conf.all.disable_ipv6 set correctly" operator="OR">
49eb97
       <criteria operator="AND">
49eb97
-        <extend_definition comment="net.ipv6.conf.all.disable_ipv6 configuration setting check" definition_ref="sysctl_static_net_ipv6_conf_all_disable_ipv6" />
49eb97
-        <extend_definition comment="net.ipv6.conf.all.disable_ipv6 runtime setting check" definition_ref="sysctl_runtime_net_ipv6_conf_all_disable_ipv6" />
49eb97
+        <extend_definition comment="net.ipv6.conf.all.disable_ipv6 configuration setting check" definition_ref="sysctl_net_ipv6_conf_all_disable_ipv6_static" />
49eb97
+        <extend_definition comment="net.ipv6.conf.all.disable_ipv6 runtime setting check" definition_ref="sysctl_net_ipv6_conf_all_disable_ipv6_runtime" />
49eb97
       </criteria>
49eb97
     </criteria>
49eb97
   </definition>
49eb97
diff --git a/shared/templates/sysctl/oval.template b/shared/templates/sysctl/oval.template
49eb97
index 74583dbee1d..52671c06402 100644
49eb97
--- a/shared/templates/sysctl/oval.template
49eb97
+++ b/shared/templates/sysctl/oval.template
49eb97
@@ -5,8 +5,8 @@
49eb97
 {{%- endif %}}
49eb97
 
49eb97
 {{% macro state_static_sysctld(prefix) -%}}
49eb97
-    <ind:object object_ref="object_static_{{{ prefix }}}_{{{ SYSCTLID }}}"/>
49eb97
-    <ind:state state_ref="state_static_sysctld_{{{ SYSCTLID }}}"/>
49eb97
+    <ind:object object_ref="object_static_{{{ prefix }}}_{{{ rule_id }}}"/>
49eb97
+    <ind:state state_ref="state_static_sysctld_{{{ rule_id }}}"/>
49eb97
 {{%- endmacro -%}}
49eb97
 {{%- macro sysctl_match() -%}}
49eb97
 {{%- if SYSCTLVAL == "" -%}}
49eb97
@@ -20,13 +20,13 @@
49eb97
 {{%- if "P" in FLAGS -%}}
49eb97
 
49eb97
 <def-group>
49eb97
-  <definition class="compliance" id="sysctl_{{{ SYSCTLID }}}" version="3">
49eb97
+  <definition class="compliance" id="{{{ rule_id }}}" version="3">
49eb97
     {{{ oval_metadata("The '" + SYSCTLVAR + "' kernel parameter should be set to the appropriate value in both system configuration and system runtime.") }}}
49eb97
     <criteria operator="AND">
49eb97
       
49eb97
-                         definition_ref="sysctl_static_{{{ SYSCTLID }}}"/>
49eb97
+                         definition_ref="{{{ rule_id }}}_static"/>
49eb97
       
49eb97
-                         definition_ref="sysctl_runtime_{{{ SYSCTLID }}}"/>
49eb97
+                         definition_ref="{{{ rule_id }}}_runtime"/>
49eb97
     </criteria>
49eb97
   </definition>
49eb97
 </def-group>
49eb97
@@ -34,7 +34,7 @@
49eb97
 {{%- elif "I" in FLAGS -%}}
49eb97
 
49eb97
 <def-group>
49eb97
-  <definition class="compliance" id="sysctl_{{{ SYSCTLID }}}" version="4">
49eb97
+  <definition class="compliance" id="{{{ rule_id }}}" version="4">
49eb97
     {{{ oval_metadata("The kernel '" + SYSCTLVAR + "' parameter should be set to the appropriate value in both system configuration and system runtime.") }}}
49eb97
     <criteria comment="IPv6 disabled or {{{ SYSCTLVAR }}} set correctly" operator="OR">
49eb97
 {{% if product in ["ubuntu1604", "ubuntu1804"] %}}
49eb97
@@ -46,9 +46,9 @@
49eb97
 {{% endif %}}
49eb97
       <criteria operator="AND">
49eb97
         
49eb97
-                           definition_ref="sysctl_static_{{{ SYSCTLID }}}"/>
49eb97
+                           definition_ref="{{{ rule_id }}}_static"/>
49eb97
         
49eb97
-                           definition_ref="sysctl_runtime_{{{ SYSCTLID }}}"/>
49eb97
+                           definition_ref="{{{ rule_id }}}_runtime"/>
49eb97
       </criteria>
49eb97
     </criteria>
49eb97
   </definition>
49eb97
@@ -58,33 +58,33 @@
49eb97
 {{%- if "R" in FLAGS -%}}
49eb97
 
49eb97
 <def-group>
49eb97
-  <definition class="compliance" id="sysctl_runtime_{{{ SYSCTLID }}}" version="3">
49eb97
+  <definition class="compliance" id="{{{ rule_id }}}_runtime" version="3">
49eb97
     {{{ oval_metadata("The kernel '" + SYSCTLVAR + "' parameter should be set to " + COMMENT_VALUE + " in the system runtime.") }}}
49eb97
     <criteria operator="AND">
49eb97
       
49eb97
-                 test_ref="test_sysctl_runtime_{{{ SYSCTLID }}}"/>
49eb97
+                 test_ref="test_{{{ rule_id }}}_runtime"/>
49eb97
     </criteria>
49eb97
   </definition>
49eb97
-  
49eb97
+  
49eb97
                     comment="kernel runtime parameter {{{ SYSCTLVAR }}} set to {{{ COMMENT_VALUE }}}"
49eb97
                     check="all" check_existence="all_exist">
49eb97
-    <unix:object object_ref="object_sysctl_runtime_{{{ SYSCTLID }}}"/>
49eb97
-    <unix:state state_ref="state_sysctl_runtime_{{{ SYSCTLID }}}"/>
49eb97
+    <unix:object object_ref="object_{{{ rule_id }}}_runtime"/>
49eb97
+    <unix:state state_ref="state_{{{ rule_id }}}_runtime"/>
49eb97
   </unix:sysctl_test>
49eb97
 
49eb97
-  <unix:sysctl_object id="object_sysctl_runtime_{{{ SYSCTLID }}}" version="1">
49eb97
+  <unix:sysctl_object id="object_{{{ rule_id }}}_runtime" version="1">
49eb97
     <unix:name>{{{ SYSCTLVAR }}}</unix:name>
49eb97
   </unix:sysctl_object>
49eb97
 {{% if SYSCTLVAL == "" %}}
49eb97
-  <unix:sysctl_state id="state_sysctl_runtime_{{{ SYSCTLID }}}" version="1">
49eb97
+  <unix:sysctl_state id="state_{{{ rule_id }}}_runtime" version="1">
49eb97
     
49eb97
-                var_ref="sysctl_{{{ SYSCTLID }}}_value"/>
49eb97
+                var_ref="{{{ rule_id }}}_value"/>
49eb97
   </unix:sysctl_state>
49eb97
 
49eb97
-  
49eb97
+  
49eb97
                      comment="External variable for {{{ SYSCTLVAR }}}" datatype="{{{ DATATYPE }}}"/>
49eb97
 {{%- else %}}
49eb97
-  <unix:sysctl_state id="state_sysctl_runtime_{{{ SYSCTLID }}}" version="1">
49eb97
+  <unix:sysctl_state id="state_{{{ rule_id }}}_runtime" version="1">
49eb97
 {{% if OPERATION == "pattern match" %}}
49eb97
     
49eb97
                 operation="{{{ OPERATION }}}">{{{ SYSCTLVAL_REGEX }}}</unix:value>
49eb97
@@ -100,46 +100,46 @@
49eb97
 {{%- if "S" in FLAGS -%}}
49eb97
 
49eb97
 <def-group>
49eb97
-  <definition class="compliance" id="sysctl_static_{{{ SYSCTLID }}}" version="3">
49eb97
+  <definition class="compliance" id="{{{ rule_id }}}_static" version="3">
49eb97
     {{{ oval_metadata("The kernel '" + SYSCTLVAR + "' parameter should be set to " + COMMENT_VALUE + " in the system configuration.") }}}
49eb97
     <criteria operator="AND">
49eb97
       <criteria operator="OR">
49eb97
         
49eb97
-                   test_ref="test_static_sysctl_{{{ SYSCTLID }}}"/>
49eb97
+                   test_ref="test_{{{ rule_id }}}_static"/>
49eb97
         
49eb97
         
49eb97
-                   test_ref="test_static_etc_sysctld_{{{ SYSCTLID }}}"/>
49eb97
+                   test_ref="test_{{{ rule_id }}}_static_etc_sysctld"/>
49eb97
         
49eb97
-                   test_ref="test_static_run_sysctld_{{{ SYSCTLID }}}"/>
49eb97
+                   test_ref="test_{{{ rule_id }}}_static_run_sysctld"/>
49eb97
 {{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel7", "rhel8", "rhel9"] %}}
49eb97
         
49eb97
-                   test_ref="test_static_usr_lib_sysctld_{{{ SYSCTLID }}}"/>
49eb97
+                   test_ref="test_{{{ rule_id }}}_static_usr_lib_sysctld"/>
49eb97
 {{% endif %}}
49eb97
       </criteria>
49eb97
 {{% if target_oval_version >= [5, 11] %}}
49eb97
-      <criterion comment="Check that {{{ SYSCTLID }}} is defined in only one file" test_ref="test_sysctl_{{{ SYSCTLID }}}_defined_in_one_file" />
49eb97
+      <criterion comment="Check that {{{ SYSCTLID }}} is defined in only one file" test_ref="test_{{{ rule_id }}}_defined_in_one_file" />
49eb97
 {{% endif %}}
49eb97
     </criteria>
49eb97
   </definition>
49eb97
 
49eb97
-  
49eb97
+  
49eb97
                               check="all" check_existence="all_exist"
49eb97
                               comment="{{{ SYSCTLVAR }}} static configuration">
49eb97
     {{{ state_static_sysctld("sysctl") }}}
49eb97
   </ind:textfilecontent54_test>
49eb97
 
49eb97
-  
49eb97
+  
49eb97
                           comment="{{{ SYSCTLVAR }}} static configuration in /etc/sysctl.d/*.conf">
49eb97
     {{{ state_static_sysctld("etc_sysctld") }}}
49eb97
   </ind:textfilecontent54_test>
49eb97
 
49eb97
-  
49eb97
+  
49eb97
                           comment="{{{ SYSCTLVAR }}} static configuration in /run/sysctl.d/*.conf">
49eb97
     {{{ state_static_sysctld("run_sysctld") }}}
49eb97
   </ind:textfilecontent54_test>
49eb97
 
49eb97
 {{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel7", "rhel8", "rhel9"] %}}
49eb97
-  
49eb97
+  
49eb97
                           check="all"
49eb97
                           comment="{{{ SYSCTLVAR }}} static configuration in /usr/lib/sysctl.d/*.conf">
49eb97
     {{{ state_static_sysctld("usr_lib_sysctld") }}}
49eb97
@@ -148,79 +148,79 @@
49eb97
 
49eb97
 {{% if target_oval_version >= [5, 11] %}}
49eb97
   
49eb97
-  id="test_sysctl_{{{ SYSCTLID }}}_defined_in_one_file" version="1">
49eb97
-    <ind:object object_ref="oject_sysctl_{{{ SYSCTLID }}}_defined_in_one_file" />
49eb97
-    <ind:state state_ref="state_sysctl_{{{ SYSCTLID }}}_defined_in_one_file" />
49eb97
+  id="test_{{{ rule_id }}}_defined_in_one_file" version="1">
49eb97
+    <ind:object object_ref="object_{{{ rule_id }}}_defined_in_one_file" />
49eb97
+    <ind:state state_ref="state_{{{ rule_id }}}_defined_in_one_file" />
49eb97
   </ind:variable_test>
49eb97
 
49eb97
-  <ind:variable_object id="oject_sysctl_{{{ SYSCTLID }}}_defined_in_one_file" version="1">
49eb97
-    <ind:var_ref>local_var_unique_sysctl_{{{ SYSCTLID }}}_counter</ind:var_ref>
49eb97
+  <ind:variable_object id="object_{{{ rule_id }}}_defined_in_one_file" version="1">
49eb97
+    <ind:var_ref>local_var_{{{ rule_id }}}_counter</ind:var_ref>
49eb97
   </ind:variable_object>
49eb97
 
49eb97
-  <ind:variable_state id="state_sysctl_{{{ SYSCTLID }}}_defined_in_one_file" version="1">
49eb97
+  <ind:variable_state id="state_{{{ rule_id }}}_defined_in_one_file" version="1">
49eb97
     <ind:value operation="equals" datatype="int">1</ind:value>
49eb97
   </ind:variable_state>
49eb97
 
49eb97
-  <local_variable comment="Count unique sysctls" datatype="int" id="local_var_unique_sysctl_{{{ SYSCTLID }}}_counter" version="1">
49eb97
+  <local_variable comment="Count unique sysctls" datatype="int" id="local_var_{{{ rule_id }}}_counter" version="1">
49eb97
     <count>
49eb97
       <unique>
49eb97
-        <object_component object_ref="object_static_set_sysctls_{{{ SYSCTLID }}}" item_field="filepath" />
49eb97
+        <object_component object_ref="object_{{{ rule_id }}}_static_set_sysctls" item_field="filepath" />
49eb97
       </unique>
49eb97
     </count>
49eb97
   </local_variable>
49eb97
 
49eb97
-  <ind:textfilecontent54_object id="object_static_set_sysctls_{{{ SYSCTLID }}}" version="1">
49eb97
+  <ind:textfilecontent54_object id="object_{{{ rule_id }}}_static_set_sysctls" version="1">
49eb97
     <set>
49eb97
-      <object_reference>object_static_set_unfiltered_sysctls_{{{ SYSCTLID }}}</object_reference>
49eb97
-      <filter action="exclude">state_{{{ SYSCTLID }}}_filepath_is_symlink</filter>
49eb97
+      <object_reference>object_{{{ rule_id }}}_static_set_sysctls_unfiltered</object_reference>
49eb97
+      <filter action="exclude">state_{{{ rule_id }}}_filepath_is_symlink</filter>
49eb97
     </set>
49eb97
   </ind:textfilecontent54_object>
49eb97
 
49eb97
-  <ind:textfilecontent54_state id="state_{{{ SYSCTLID }}}_filepath_is_symlink" version="1">
49eb97
-    <ind:filepath operation="equals" var_check="at least one" var_ref="local_var_safe_symlinks_{{{ SYSCTLID }}}" datatype="string" />
49eb97
+  <ind:textfilecontent54_state id="state_{{{ rule_id }}}_filepath_is_symlink" version="1">
49eb97
+    <ind:filepath operation="equals" var_check="at least one" var_ref="local_var_{{{ rule_id }}}_safe_symlinks" datatype="string" />
49eb97
   </ind:textfilecontent54_state>
49eb97
 
49eb97
-  
49eb97
+  
49eb97
   
49eb97
        This ultimately avoids referencing a variable with "no values",
49eb97
        we reference a variable with a blank string -->
49eb97
-  <local_variable comment="Unique list of symlink conf files" datatype="string" id="local_var_safe_symlinks_{{{ SYSCTLID }}}" version="1">
49eb97
+  <local_variable comment="Unique list of symlink conf files" datatype="string" id="local_var_{{{ rule_id }}}_safe_symlinks" version="1">
49eb97
     <unique>
49eb97
-      <object_component object_ref="var_object_symlink_{{{ SYSCTLID }}}" item_field="value" />
49eb97
+      <object_component object_ref="var_object_symlink_{{{ rule_id }}}" item_field="value" />
49eb97
     </unique>
49eb97
   </local_variable>
49eb97
 
49eb97
-  <ind:variable_object id="var_object_symlink_{{{ SYSCTLID }}}" comment="combine the blank string with symlink paths found" version="1">
49eb97
+  <ind:variable_object id="var_object_symlink_{{{ rule_id }}}" comment="combine the blank string with symlink paths found" version="1">
49eb97
     <set>
49eb97
-      <object_reference>var_obj_symlink_{{{ SYSCTLID }}}</object_reference>
49eb97
-      <object_reference>var_obj_blank_{{{ SYSCTLID }}}</object_reference>
49eb97
+      <object_reference>var_obj_symlink_{{{ rule_id }}}</object_reference>
49eb97
+      <object_reference>var_obj_blank_{{{ rule_id }}}</object_reference>
49eb97
     </set>
49eb97
   </ind:variable_object>
49eb97
 
49eb97
-  <ind:variable_object id="var_obj_blank_{{{ SYSCTLID }}}" comment="variable object of the blank string" version="1">
49eb97
-    <ind:var_ref>local_var_blank_path_{{{ SYSCTLID }}}</ind:var_ref>
49eb97
+  <ind:variable_object id="var_obj_blank_{{{ rule_id }}}" comment="variable object of the blank string" version="1">
49eb97
+    <ind:var_ref>local_var_blank_path_{{{ rule_id }}}</ind:var_ref>
49eb97
   </ind:variable_object>
49eb97
 
49eb97
-  <local_variable comment="Blank string" datatype="string" id="local_var_blank_path_{{{ SYSCTLID }}}" version="1">
49eb97
+  <local_variable comment="Blank string" datatype="string" id="local_var_blank_path_{{{ rule_id }}}" version="1">
49eb97
     <literal_component datatype="string"></literal_component>
49eb97
   </local_variable>
49eb97
 
49eb97
-  <ind:variable_object id="var_obj_symlink_{{{ SYSCTLID }}}" comment="variable object of the symlinks found" version="1">
49eb97
-    <ind:var_ref>local_var_symlinks_{{{ SYSCTLID }}}</ind:var_ref>
49eb97
+  <ind:variable_object id="var_obj_symlink_{{{ rule_id }}}" comment="variable object of the symlinks found" version="1">
49eb97
+    <ind:var_ref>local_var_symlinks_{{{ rule_id }}}</ind:var_ref>
49eb97
   </ind:variable_object>
49eb97
-  
49eb97
+  
49eb97
 
49eb97
-  <local_variable comment="Unique list of symlink conf files" datatype="string" id="local_var_symlinks_{{{ SYSCTLID }}}" version="1">
49eb97
+  <local_variable comment="Unique list of symlink conf files" datatype="string" id="local_var_symlinks_{{{ rule_id }}}" version="1">
49eb97
     <unique>
49eb97
-      <object_component object_ref="object_{{{ SYSCTLID }}}_symlinks" item_field="filepath" />
49eb97
+      <object_component object_ref="object_{{{ rule_id }}}_symlinks" item_field="filepath" />
49eb97
     </unique>
49eb97
   </local_variable>
49eb97
 
49eb97
   
49eb97
        Workaround by querying for all conf files found -->
49eb97
-  <unix:symlink_object comment="Symlinks referencing files in default dirs" id="object_{{{ SYSCTLID }}}_symlinks" version="1">
49eb97
-    <unix:filepath operation="equals" var_ref="local_var_conf_files_{{{ SYSCTLID }}}" />
49eb97
-    <filter action="exclude">state_symlink_points_outside_usual_dirs_{{{ SYSCTLID }}}</filter>
49eb97
+  <unix:symlink_object comment="Symlinks referencing files in default dirs" id="object_{{{ rule_id }}}_symlinks" version="1">
49eb97
+    <unix:filepath operation="equals" var_ref="local_var_conf_files_{{{ rule_id }}}" />
49eb97
+    <filter action="exclude">state_symlink_points_outside_usual_dirs_{{{ rule_id }}}</filter>
49eb97
   </unix:symlink_object>
49eb97
 
49eb97
   
49eb97
@@ -228,59 +228,59 @@
49eb97
        ^/etc/sysctl.d/.*$
49eb97
        ^/run/sysctl.d/.*$
49eb97
        ^/usr/lib/sysctl.d/.*$ -->
49eb97
-  <unix:symlink_state comment="State that matches symlinks referencing files not in the default dirs" id="state_symlink_points_outside_usual_dirs_{{{ SYSCTLID }}}" version="1">
49eb97
+  <unix:symlink_state comment="State that matches symlinks referencing files not in the default dirs" id="state_symlink_points_outside_usual_dirs_{{{ rule_id }}}" version="1">
49eb97
     <unix:canonical_path operation="pattern match">^(?!(\/etc\/sysctl\.conf$|(\/etc|\/run|\/usr\/lib)\/sysctl\.d\/)).*$</unix:canonical_path>
49eb97
   </unix:symlink_state>
49eb97
 {{% endif %}}
49eb97
 
49eb97
-  <local_variable comment="List of conf files" datatype="string" id="local_var_conf_files_{{{ SYSCTLID }}}" version="1">
49eb97
-    <object_component object_ref="object_static_set_unfiltered_sysctls_{{{ SYSCTLID }}}" item_field="filepath" />
49eb97
+  <local_variable comment="List of conf files" datatype="string" id="local_var_conf_files_{{{ rule_id }}}" version="1">
49eb97
+    <object_component object_ref="object_{{{ rule_id }}}_static_set_sysctls_unfiltered" item_field="filepath" />
49eb97
   </local_variable>
49eb97
 
49eb97
   
49eb97
        variable to have no value even when there are valid objects. -->
49eb97
-  <ind:textfilecontent54_object id="object_static_set_unfiltered_sysctls_{{{ SYSCTLID }}}" version="1">
49eb97
+  <ind:textfilecontent54_object id="object_{{{ rule_id }}}_static_set_sysctls_unfiltered" version="1">
49eb97
     <set>
49eb97
-      <object_reference>object_static_etc_sysctls_{{{ SYSCTLID }}}</object_reference>
49eb97
-      <object_reference>object_static_run_usr_sysctls_{{{ SYSCTLID }}}</object_reference>
49eb97
+      <object_reference>object_static_etc_sysctls_{{{ rule_id }}}</object_reference>
49eb97
+      <object_reference>object_static_run_usr_sysctls_{{{ rule_id }}}</object_reference>
49eb97
     </set>
49eb97
   </ind:textfilecontent54_object>
49eb97
 
49eb97
-  <ind:textfilecontent54_object id="object_static_etc_sysctls_{{{ SYSCTLID }}}" version="1">
49eb97
+  <ind:textfilecontent54_object id="object_static_etc_sysctls_{{{ rule_id }}}" version="1">
49eb97
     <set>
49eb97
-      <object_reference>object_static_sysctl_{{{ SYSCTLID }}}</object_reference>
49eb97
-      <object_reference>object_static_etc_sysctld_{{{ SYSCTLID }}}</object_reference>
49eb97
+      <object_reference>object_static_sysctl_{{{ rule_id }}}</object_reference>
49eb97
+      <object_reference>object_static_etc_sysctld_{{{ rule_id }}}</object_reference>
49eb97
     </set>
49eb97
   </ind:textfilecontent54_object>
49eb97
 
49eb97
-  <ind:textfilecontent54_object id="object_static_run_usr_sysctls_{{{ SYSCTLID }}}" version="1">
49eb97
+  <ind:textfilecontent54_object id="object_static_run_usr_sysctls_{{{ rule_id }}}" version="1">
49eb97
     <set>
49eb97
-      <object_reference>object_static_run_sysctld_{{{ SYSCTLID }}}</object_reference>
49eb97
+      <object_reference>object_static_run_sysctld_{{{ rule_id }}}</object_reference>
49eb97
 {{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel7", "rhel8", "rhel9"] %}}
49eb97
-      <object_reference>object_static_usr_lib_sysctld_{{{ SYSCTLID }}}</object_reference>
49eb97
+      <object_reference>object_static_usr_lib_sysctld_{{{ rule_id }}}</object_reference>
49eb97
 {{% endif %}}
49eb97
     </set>
49eb97
   </ind:textfilecontent54_object>
49eb97
 
49eb97
-  <ind:textfilecontent54_object id="object_static_sysctl_{{{ SYSCTLID }}}" version="1">
49eb97
+  <ind:textfilecontent54_object id="object_static_sysctl_{{{ rule_id }}}" version="1">
49eb97
     <ind:filepath>/etc/sysctl.conf</ind:filepath>
49eb97
     {{{ sysctl_match() }}}
49eb97
   </ind:textfilecontent54_object>
49eb97
 
49eb97
-  <ind:textfilecontent54_object id="object_static_etc_sysctld_{{{ SYSCTLID }}}" version="1">
49eb97
+  <ind:textfilecontent54_object id="object_static_etc_sysctld_{{{ rule_id }}}" version="1">
49eb97
     <ind:path>/etc/sysctl.d</ind:path>
49eb97
     <ind:filename operation="pattern match">^.*\.conf$</ind:filename>
49eb97
     {{{ sysctl_match() }}}
49eb97
   </ind:textfilecontent54_object>
49eb97
 
49eb97
-  <ind:textfilecontent54_object id="object_static_run_sysctld_{{{ SYSCTLID }}}" version="1">
49eb97
+  <ind:textfilecontent54_object id="object_static_run_sysctld_{{{ rule_id }}}" version="1">
49eb97
     <ind:path>/run/sysctl.d</ind:path>
49eb97
     <ind:filename operation="pattern match">^.*\.conf$</ind:filename>
49eb97
     {{{ sysctl_match() }}}
49eb97
   </ind:textfilecontent54_object>
49eb97
 
49eb97
 {{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel7", "rhel8", "rhel9"] %}}
49eb97
-  <ind:textfilecontent54_object id="object_static_usr_lib_sysctld_{{{ SYSCTLID }}}" version="1">
49eb97
+  <ind:textfilecontent54_object id="object_static_usr_lib_sysctld_{{{ rule_id }}}" version="1">
49eb97
     <ind:path>/usr/lib/sysctl.d</ind:path>
49eb97
     <ind:filename operation="pattern match">^.*\.conf$</ind:filename>
49eb97
     {{{ sysctl_match() }}}
49eb97
@@ -288,15 +288,15 @@
49eb97
 {{% endif %}}
49eb97
 {{% if SYSCTLVAL == "" %}}
49eb97
 
49eb97
-  <ind:textfilecontent54_state id="state_static_sysctld_{{{ SYSCTLID }}}" version="1">
49eb97
-    
49eb97
+  <ind:textfilecontent54_state id="state_static_sysctld_{{{ rule_id }}}" version="1">
49eb97
+    
49eb97
                        datatype="{{{ DATATYPE }}}" />
49eb97
   </ind:textfilecontent54_state>
49eb97
 
49eb97
-  
49eb97
+  
49eb97
                      comment="External variable for {{{ SYSCTLVAR }}}" datatype="{{{ DATATYPE }}}"/>
49eb97
 {{% else %}}
49eb97
-  <ind:textfilecontent54_state id="state_static_sysctld_{{{ SYSCTLID }}}" version="1">
49eb97
+  <ind:textfilecontent54_state id="state_static_sysctld_{{{ rule_id }}}" version="1">
49eb97
 {{% if OPERATION == "pattern match" %}}
49eb97
     <ind:subexpression operation="{{{ OPERATION }}}" datatype="{{{ DATATYPE }}}">{{{ SYSCTLVAL_REGEX }}}</ind:subexpression>
49eb97
 {{% else %}}
49eb97
49eb97
From ee5d91aaf33504e56b6959c17c8ebc6006a17a5f Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Wed, 13 Jul 2022 10:16:45 +0200
49eb97
Subject: [PATCH 03/23] Use a list of values in sysctl template
49eb97
49eb97
This patch adds an ability to use a list of values instead of a single
49eb97
value in the sysctlval parameter of the sysctl template.  This is useful
49eb97
for situations when we want to create a rule that passes for multiple
49eb97
different sysctl values.  This commit modifies the OVAL for the runtime
49eb97
configuration.  The runtime configuration will be allowed to be any of
49eb97
the values in the list.  There is an OR relation between the values.  In
49eb97
fact, this is a first step to enable multiple values in the sysctlval
49eb97
parameter in the sysctl template, because we will also need to check the
49eb97
static configuration, which is not done in this commit.
49eb97
---
49eb97
 shared/templates/sysctl/oval.template | 32 +++++++++++++++++++++++++++
49eb97
 shared/templates/sysctl/template.py   | 24 ++++++++++++--------
49eb97
 2 files changed, 47 insertions(+), 9 deletions(-)
49eb97
49eb97
diff --git a/shared/templates/sysctl/oval.template b/shared/templates/sysctl/oval.template
49eb97
index 52671c06402..b73ccc94f72 100644
49eb97
--- a/shared/templates/sysctl/oval.template
49eb97
+++ b/shared/templates/sysctl/oval.template
49eb97
@@ -1,5 +1,7 @@
49eb97
 {{%- if SYSCTLVAL == "" %}}
49eb97
 {{%- set COMMENT_VALUE="the appropriate value" %}}
49eb97
+{{%- elif SYSCTLVAL is sequence %}}
49eb97
+{{%- set COMMENT_VALUE = SYSCTLVAL | join(" or " ) %}}
49eb97
 {{%- else %}}
49eb97
 {{%- set COMMENT_VALUE=SYSCTLVAL %}}
49eb97
 {{%- endif %}}
49eb97
@@ -60,21 +62,43 @@
49eb97
 <def-group>
49eb97
   <definition class="compliance" id="{{{ rule_id }}}_runtime" version="3">
49eb97
     {{{ oval_metadata("The kernel '" + SYSCTLVAR + "' parameter should be set to " + COMMENT_VALUE + " in the system runtime.") }}}
49eb97
+{{% if SYSCTLVAL is string %}}
49eb97
     <criteria operator="AND">
49eb97
       
49eb97
                  test_ref="test_{{{ rule_id }}}_runtime"/>
49eb97
     </criteria>
49eb97
+{{% elif SYSCTLVAL is sequence %}}
49eb97
+    <criteria operator="OR">
49eb97
+{{% for x in SYSCTLVAL %}}
49eb97
+      
49eb97
+                 test_ref="test_{{{ rule_id }}}_runtime_{{{ x }}}"/>
49eb97
+{{% endfor %}}
49eb97
+    </criteria>
49eb97
+{{% endif %}}
49eb97
   </definition>
49eb97
+
49eb97
+{{% if SYSCTLVAL is string %}}
49eb97
   
49eb97
                     comment="kernel runtime parameter {{{ SYSCTLVAR }}} set to {{{ COMMENT_VALUE }}}"
49eb97
                     check="all" check_existence="all_exist">
49eb97
     <unix:object object_ref="object_{{{ rule_id }}}_runtime"/>
49eb97
     <unix:state state_ref="state_{{{ rule_id }}}_runtime"/>
49eb97
   </unix:sysctl_test>
49eb97
+{{% elif SYSCTLVAL is sequence %}}
49eb97
+{{% for x in SYSCTLVAL %}}
49eb97
+  
49eb97
+                    comment="kernel runtime parameter {{{ SYSCTLVAR }}} set to {{{ x }}}"
49eb97
+                    check="all" check_existence="all_exist">
49eb97
+    <unix:object object_ref="object_{{{ rule_id }}}_runtime"/>
49eb97
+    <unix:state state_ref="state_{{{ rule_id }}}_runtime_{{{ x }}}" />
49eb97
+  </unix:sysctl_test>
49eb97
+{{% endfor %}}
49eb97
+{{% endif %}}
49eb97
 
49eb97
   <unix:sysctl_object id="object_{{{ rule_id }}}_runtime" version="1">
49eb97
     <unix:name>{{{ SYSCTLVAR }}}</unix:name>
49eb97
   </unix:sysctl_object>
49eb97
+{{% if SYSCTLVAL is string %}}
49eb97
 {{% if SYSCTLVAL == "" %}}
49eb97
   <unix:sysctl_state id="state_{{{ rule_id }}}_runtime" version="1">
49eb97
     
49eb97
@@ -94,6 +118,14 @@
49eb97
 {{% endif %}}
49eb97
   </unix:sysctl_state>
49eb97
 {{%- endif %}}
49eb97
+{{% elif SYSCTLVAL is sequence %}}
49eb97
+{{% for x in SYSCTLVAL %}}
49eb97
+  <unix:sysctl_state id="state_{{{ rule_id }}}_runtime_{{{ x }}}" version="1">
49eb97
+    
49eb97
+                operation="{{{ OPERATION }}}">{{{ x }}}</unix:value>
49eb97
+  </unix:sysctl_state>
49eb97
+{{% endfor %}}
49eb97
+{{% endif %}}
49eb97
 </def-group>
49eb97
 
49eb97
 {{%- endif -%}}
49eb97
diff --git a/shared/templates/sysctl/template.py b/shared/templates/sysctl/template.py
49eb97
index fa981a9dce9..c62591357c0 100644
49eb97
--- a/shared/templates/sysctl/template.py
49eb97
+++ b/shared/templates/sysctl/template.py
49eb97
@@ -12,6 +12,13 @@ def preprocess(data, lang):
49eb97
     if "operation" not in data:
49eb97
         data["operation"] = "equals"
49eb97
 
49eb97
+    if data["datatype"] not in ["string", "int"]:
49eb97
+        raise ValueError(
49eb97
+            "Test scenarios for data type '{0}' are not implemented yet.\n"
49eb97
+            "Please check if rule '{1}' has correct data type and edit "
49eb97
+            "{2} to add tests for it.".format(
49eb97
+                data["datatype"], data["_rule_id"], __file__))
49eb97
+
49eb97
     # Configure data for test scenarios
49eb97
     if data["sysctlval"] == "":
49eb97
         if data["datatype"] == "int":
49eb97
@@ -20,20 +27,19 @@ def preprocess(data, lang):
49eb97
         elif data["datatype"] == "string":
49eb97
             data["sysctl_correct_value"] = "correct_value"
49eb97
             data["sysctl_wrong_value"] = "wrong_value"
49eb97
-        else:
49eb97
+    elif isinstance(data["sysctlval"], list):
49eb97
+        if len(data["sysctlval"]) == 0:
49eb97
             raise ValueError(
49eb97
-                "Test scenarios for data type '{0}' are not implemented yet.\n"
49eb97
-                "Please check if rule '{1}' has correct data type and edit "
49eb97
-                "{2} to add tests for it.".format(data["datatype"], data["_rule_id"], __file__))
49eb97
+                "The sysctlval parameter of {0} is an empty list".format(data["_rule_id"]))
49eb97
+        data["sysctl_correct_value"] = data["sysctlval"][0]
49eb97
+        if data["datatype"] == "int":
49eb97
+            data["sysctl_wrong_value"] = "1" + data["sysctlval"][0]
49eb97
+        elif data["datatype"] == "string":
49eb97
+            data["sysctl_wrong_value"] = "wrong_value"
49eb97
     else:
49eb97
         data["sysctl_correct_value"] = data["sysctlval"]
49eb97
         if data["datatype"] == "int":
49eb97
             data["sysctl_wrong_value"] = "1" + data["sysctlval"]
49eb97
         elif data["datatype"] == "string":
49eb97
             data["sysctl_wrong_value"] = "wrong_value"
49eb97
-        else:
49eb97
-            raise ValueError(
49eb97
-                "Test scenarios for data type '{0}' are not implemented yet.\n"
49eb97
-                "Please check if rule '{1}' has correct data type and edit "
49eb97
-                "{2} to add tests for it.".format(data["datatype"], data["_rule_id"], __file__))
49eb97
     return data
49eb97
49eb97
From c50304234dfac1dcd74b3056c978eec2c097216d Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Wed, 13 Jul 2022 10:47:51 +0200
49eb97
Subject: [PATCH 04/23] Move check unrelated to the test scenarios
49eb97
49eb97
The check for an mepty list is unrelated to the test scenarios,
49eb97
rather is a generic check to avoid problems during the build.
49eb97
Therefore, it shouldn't be inside code block that is handling
49eb97
data for test scenarios, but can be extracted to a sooner position.
49eb97
---
49eb97
 shared/templates/sysctl/template.py | 9 +++++----
49eb97
 1 file changed, 5 insertions(+), 4 deletions(-)
49eb97
49eb97
diff --git a/shared/templates/sysctl/template.py b/shared/templates/sysctl/template.py
49eb97
index c62591357c0..421e42c6ca1 100644
49eb97
--- a/shared/templates/sysctl/template.py
49eb97
+++ b/shared/templates/sysctl/template.py
49eb97
@@ -11,7 +11,12 @@ def preprocess(data, lang):
49eb97
     data["flags"] = "SR" + ipv6_flag
49eb97
     if "operation" not in data:
49eb97
         data["operation"] = "equals"
49eb97
+    if isinstance(data["sysctlval"], list) and len(data["sysctlval"]) == 0:
49eb97
+        raise ValueError(
49eb97
+            "The sysctlval parameter of {0} is an empty list".format(
49eb97
+                data["_rule_id"]))
49eb97
 
49eb97
+    # Configure data for test scenarios
49eb97
     if data["datatype"] not in ["string", "int"]:
49eb97
         raise ValueError(
49eb97
             "Test scenarios for data type '{0}' are not implemented yet.\n"
49eb97
@@ -19,7 +24,6 @@ def preprocess(data, lang):
49eb97
             "{2} to add tests for it.".format(
49eb97
                 data["datatype"], data["_rule_id"], __file__))
49eb97
 
49eb97
-    # Configure data for test scenarios
49eb97
     if data["sysctlval"] == "":
49eb97
         if data["datatype"] == "int":
49eb97
             data["sysctl_correct_value"] = "0"
49eb97
@@ -28,9 +32,6 @@ def preprocess(data, lang):
49eb97
             data["sysctl_correct_value"] = "correct_value"
49eb97
             data["sysctl_wrong_value"] = "wrong_value"
49eb97
     elif isinstance(data["sysctlval"], list):
49eb97
-        if len(data["sysctlval"]) == 0:
49eb97
-            raise ValueError(
49eb97
-                "The sysctlval parameter of {0} is an empty list".format(data["_rule_id"]))
49eb97
         data["sysctl_correct_value"] = data["sysctlval"][0]
49eb97
         if data["datatype"] == "int":
49eb97
             data["sysctl_wrong_value"] = "1" + data["sysctlval"][0]
49eb97
49eb97
From eb1fe4f349e2dcadd9b870e074e679383601be62 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Wed, 13 Jul 2022 11:57:50 +0200
49eb97
Subject: [PATCH 05/23] Allow multiple values in sysctl static configuration
49eb97
49eb97
This extends the OVAL checks for sysctl static configuration
49eb97
to enable a list of values instead of a single value in the
49eb97
sysctlval parameter of the sysctl template. The template
49eb97
will generate OVAL tests for each value in the sysctlval
49eb97
list.
49eb97
---
49eb97
 shared/templates/sysctl/oval.template | 56 +++++++++++++++++++++++++++
49eb97
 1 file changed, 56 insertions(+)
49eb97
49eb97
diff --git a/shared/templates/sysctl/oval.template b/shared/templates/sysctl/oval.template
49eb97
index b73ccc94f72..4e1bf3cfce3 100644
49eb97
--- a/shared/templates/sysctl/oval.template
49eb97
+++ b/shared/templates/sysctl/oval.template
49eb97
@@ -136,6 +136,7 @@
49eb97
     {{{ oval_metadata("The kernel '" + SYSCTLVAR + "' parameter should be set to " + COMMENT_VALUE + " in the system configuration.") }}}
49eb97
     <criteria operator="AND">
49eb97
       <criteria operator="OR">
49eb97
+{{% if SYSCTLVAL is string %}}
49eb97
         
49eb97
                    test_ref="test_{{{ rule_id }}}_static"/>
49eb97
         
49eb97
@@ -146,6 +147,21 @@
49eb97
 {{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel7", "rhel8", "rhel9"] %}}
49eb97
         
49eb97
                    test_ref="test_{{{ rule_id }}}_static_usr_lib_sysctld"/>
49eb97
+{{% endif %}}
49eb97
+{{% elif SYSCTLVAL is sequence %}}
49eb97
+{{% for x in SYSCTLVAL %}}
49eb97
+        
49eb97
+                   test_ref="test_{{{ rule_id }}}_static_{{{ x }}}"/>
49eb97
+        
49eb97
+        
49eb97
+                   test_ref="test_{{{ rule_id }}}_static_{{{ x }}}_etc_sysctld"/>
49eb97
+        
49eb97
+                   test_ref="test_{{{ rule_id }}}_static_{{{ x }}}_run_sysctld"/>
49eb97
+{{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel7", "rhel8", "rhel9"] %}}
49eb97
+        
49eb97
+                   test_ref="test_{{{ rule_id }}}_static_{{{ x }}}_usr_lib_sysctld"/>
49eb97
+{{% endif %}}
49eb97
+{{% endfor %}}
49eb97
 {{% endif %}}
49eb97
       </criteria>
49eb97
 {{% if target_oval_version >= [5, 11] %}}
49eb97
@@ -154,6 +170,7 @@
49eb97
     </criteria>
49eb97
   </definition>
49eb97
 
49eb97
+{{% if SYSCTLVAL is string %}}
49eb97
   
49eb97
                               check="all" check_existence="all_exist"
49eb97
                               comment="{{{ SYSCTLVAR }}} static configuration">
49eb97
@@ -177,6 +194,37 @@
49eb97
     {{{ state_static_sysctld("usr_lib_sysctld") }}}
49eb97
   </ind:textfilecontent54_test>
49eb97
 {{% endif %}}
49eb97
+{{% elif SYSCTLVAL is sequence %}}
49eb97
+{{% for x in SYSCTLVAL %}}
49eb97
+  
49eb97
+                              check="all" check_existence="all_exist"
49eb97
+                              comment="{{{ SYSCTLVAR }}} static configuration">
49eb97
+    <ind:object object_ref="object_static_sysctl_{{{ rule_id }}}"/>
49eb97
+    <ind:state state_ref="state_static_sysctld_{{{ rule_id }}}_{{{ x }}}"/>
49eb97
+  </ind:textfilecontent54_test>
49eb97
+
49eb97
+  
49eb97
+                          comment="{{{ SYSCTLVAR }}} static configuration in /etc/sysctl.d/*.conf">
49eb97
+    <ind:object object_ref="object_static_etc_sysctld_{{{ rule_id }}}"/>
49eb97
+    <ind:state state_ref="state_static_sysctld_{{{ rule_id }}}_{{{ x }}}"/>
49eb97
+  </ind:textfilecontent54_test>
49eb97
+
49eb97
+  
49eb97
+                          comment="{{{ SYSCTLVAR }}} static configuration in /run/sysctl.d/*.conf">
49eb97
+    <ind:object object_ref="object_static_run_sysctld_{{{ rule_id }}}"/>
49eb97
+    <ind:state state_ref="state_static_sysctld_{{{ rule_id }}}_{{{ x }}}"/>
49eb97
+  </ind:textfilecontent54_test>
49eb97
+
49eb97
+{{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel7", "rhel8", "rhel9"] %}}
49eb97
+  
49eb97
+                          check="all"
49eb97
+                          comment="{{{ SYSCTLVAR }}} static configuration in /usr/lib/sysctl.d/*.conf">
49eb97
+    <ind:object object_ref="object_static_usr_lib_sysctld_{{{ rule_id }}}"/>
49eb97
+    <ind:state state_ref="state_static_sysctld_{{{ rule_id }}}_{{{ x }}}"/>
49eb97
+  </ind:textfilecontent54_test>
49eb97
+{{% endif %}}
49eb97
+{{% endfor %}}
49eb97
+{{% endif %}}
49eb97
 
49eb97
 {{% if target_oval_version >= [5, 11] %}}
49eb97
   
49eb97
@@ -318,6 +366,7 @@
49eb97
     {{{ sysctl_match() }}}
49eb97
   </ind:textfilecontent54_object>
49eb97
 {{% endif %}}
49eb97
+{{% if SYSCTLVAL is string %}}
49eb97
 {{% if SYSCTLVAL == "" %}}
49eb97
 
49eb97
   <ind:textfilecontent54_state id="state_static_sysctld_{{{ rule_id }}}" version="1">
49eb97
@@ -336,5 +385,12 @@
49eb97
 {{% endif %}}
49eb97
   </ind:textfilecontent54_state>
49eb97
 {{% endif %}}
49eb97
+{{% elif SYSCTLVAL is sequence %}}
49eb97
+{{% for x in SYSCTLVAL %}}
49eb97
+  <ind:textfilecontent54_state id="state_static_sysctld_{{{ rule_id }}}_{{{ x }}}" version="1">
49eb97
+    <ind:subexpression operation="{{{ OPERATION }}}" datatype="{{{ DATATYPE }}}">{{{ x }}}</ind:subexpression>
49eb97
+  </ind:textfilecontent54_state>
49eb97
+{{% endfor %}}
49eb97
+{{% endif %}}
49eb97
 </def-group>
49eb97
 {{%- endif -%}}
49eb97
49eb97
From 93d496fb8dda6c47707e27c0b2cad15616261f27 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Wed, 13 Jul 2022 14:55:28 +0200
49eb97
Subject: [PATCH 06/23] Add option to allow system default
49eb97
49eb97
Introduce new template option `missing_static_pass` to the
49eb97
systemctl template. If this option is set to `"true"` in rule.yml
49eb97
the OVAL will be generated in a way that the check will pass if
49eb97
there is no sysctl static configuration option in the watched sysctl
49eb97
configuration files. In other words, the OVAL check will pass if
49eb97
the system default isn't overridden.
49eb97
---
49eb97
 shared/templates/sysctl/oval.template | 15 +++++++++++++++
49eb97
 1 file changed, 15 insertions(+)
49eb97
49eb97
diff --git a/shared/templates/sysctl/oval.template b/shared/templates/sysctl/oval.template
49eb97
index 4e1bf3cfce3..1719a59f9c7 100644
49eb97
--- a/shared/templates/sysctl/oval.template
49eb97
+++ b/shared/templates/sysctl/oval.template
49eb97
@@ -134,6 +134,9 @@
49eb97
 <def-group>
49eb97
   <definition class="compliance" id="{{{ rule_id }}}_static" version="3">
49eb97
     {{{ oval_metadata("The kernel '" + SYSCTLVAR + "' parameter should be set to " + COMMENT_VALUE + " in the system configuration.") }}}
49eb97
+{{% if MISSING_STATIC_PASS == "true" %}}
49eb97
+    <criteria operator="OR">
49eb97
+{{% endif %}}
49eb97
     <criteria operator="AND">
49eb97
       <criteria operator="OR">
49eb97
 {{% if SYSCTLVAL is string %}}
49eb97
@@ -168,8 +171,20 @@
49eb97
       <criterion comment="Check that {{{ SYSCTLID }}} is defined in only one file" test_ref="test_{{{ rule_id }}}_defined_in_one_file" />
49eb97
 {{% endif %}}
49eb97
     </criteria>
49eb97
+{{% if MISSING_STATIC_PASS == "true" %}}
49eb97
+      <criterion comment="Check that {{{ SYSCTLID }}} is not defined in any file" test_ref="test_{{{ rule_id }}}_not_defined" />
49eb97
+    </criteria>
49eb97
+{{% endif %}}
49eb97
   </definition>
49eb97
 
49eb97
+{{% if MISSING_STATIC_PASS == "true" %}}
49eb97
+  
49eb97
+                              check="all" check_existence="none_exist"
49eb97
+                              comment="{{{ SYSCTLVAR }}} static configuration">
49eb97
+    <ind:object object_ref="object_{{{ rule_id }}}_static_set_sysctls" />
49eb97
+  </ind:textfilecontent54_test>
49eb97
+{{% endif %}}
49eb97
+
49eb97
 {{% if SYSCTLVAL is string %}}
49eb97
   
49eb97
                               check="all" check_existence="all_exist"
49eb97
49eb97
From 97dca34b717621d5fbbdfdab459ac087f20d1e4b Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Wed, 13 Jul 2022 17:02:35 +0200
49eb97
Subject: [PATCH 07/23] Accept multiple values in the sysctl remediation
49eb97
49eb97
A new parameter sysctlval_remediate is introduced to the sysctl
49eb97
template. This allows to choose which of the multiple values in
49eb97
the sysctl list will be used in the Bash and Ansible remediations.
49eb97
---
49eb97
 docs/templates/template_reference.md     |  8 ++++++++
49eb97
 shared/templates/sysctl/ansible.template |  6 +++---
49eb97
 shared/templates/sysctl/bash.template    | 10 +++++-----
49eb97
 shared/templates/sysctl/template.py      |  9 +++++++++
49eb97
 4 files changed, 25 insertions(+), 8 deletions(-)
49eb97
49eb97
diff --git a/docs/templates/template_reference.md b/docs/templates/template_reference.md
49eb97
index a439e3dca94..5785f1d453f 100644
49eb97
--- a/docs/templates/template_reference.md
49eb97
+++ b/docs/templates/template_reference.md
49eb97
@@ -818,6 +818,14 @@ The selected value can be changed in the profile (consult the actual variable fo
49eb97
     -   **sysctlval** - value of the sysctl value, eg. `'1'`. If this
49eb97
         parameter is not specified, XCCDF Value is used instead.
49eb97
 
49eb97
+    -   **sysctlval_remediate** - the value that will be used in remediations.
49eb97
+        If **sysctlval_remediate** is not specified, the template will use the
49eb97
+        value of the **sysctlval** parameter in the remediations.
49eb97
+        This parameter is mandatory when the **sysctlval** parameter is a list
49eb97
+        because we need to know which of the values in the list the system
49eb97
+        should be remedied to. When  the **sysctlval** parameter is not a list
49eb97
+        this parameter is optional.
49eb97
+
49eb97
     -   **operation** - operation used for comparison of collected object
49eb97
         with **sysctlval**. Default value: `equals`.
49eb97
 
49eb97
diff --git a/shared/templates/sysctl/ansible.template b/shared/templates/sysctl/ansible.template
49eb97
index c13bb6637fe..7724db5e5ff 100644
49eb97
--- a/shared/templates/sysctl/ansible.template
49eb97
+++ b/shared/templates/sysctl/ansible.template
49eb97
@@ -21,7 +21,7 @@
49eb97
     replace: '#{{{ SYSCTLVAR }}}'
49eb97
   loop: "{{ find_sysctl_d.files }}"
49eb97
 
49eb97
-{{%- if SYSCTLVAL == "" %}}
49eb97
+{{%- if SYSCTLVAL_REMEDIATE == "" %}}
49eb97
 - (xccdf-var sysctl_{{{ SYSCTLID }}}_value)
49eb97
 
49eb97
 - name: Ensure sysctl {{{ SYSCTLVAR }}} is set
49eb97
@@ -29,10 +29,10 @@
49eb97
     name: "{{{ SYSCTLVAR }}}"
49eb97
     value: "{{ sysctl_{{{ SYSCTLID }}}_value }}"
49eb97
 {{%- else %}}
49eb97
-- name: Ensure sysctl {{{ SYSCTLVAR }}} is set to {{{ SYSCTLVAL }}}
49eb97
+- name: Ensure sysctl {{{ SYSCTLVAR }}} is set to {{{ SYSCTLVAL_REMEDIATE }}}
49eb97
   sysctl:
49eb97
     name: "{{{ SYSCTLVAR }}}"
49eb97
-    value: "{{{ SYSCTLVAL }}}"
49eb97
+    value: "{{{ SYSCTLVAL_REMEDIATE }}}"
49eb97
 {{%- endif %}}
49eb97
     state: present
49eb97
     reload: yes
49eb97
diff --git a/shared/templates/sysctl/bash.template b/shared/templates/sysctl/bash.template
49eb97
index d67a59c3886..63948bd5a26 100644
49eb97
--- a/shared/templates/sysctl/bash.template
49eb97
+++ b/shared/templates/sysctl/bash.template
49eb97
@@ -20,7 +20,7 @@ for f in /etc/sysctl.d/*.conf /run/sysctl.d/*.conf; do
49eb97
   fi
49eb97
 done
49eb97
 
49eb97
-{{%- if SYSCTLVAL == "" %}}
49eb97
+{{%- if SYSCTLVAL_REMEDIATE == "" %}}
49eb97
 {{{ bash_instantiate_variables("sysctl_" + SYSCTLID + "_value") }}}
49eb97
 
49eb97
 #
49eb97
@@ -38,11 +38,11 @@ done
49eb97
 #
49eb97
 # Set runtime for {{{ SYSCTLVAR }}}
49eb97
 #
49eb97
-/sbin/sysctl -q -n -w {{{ SYSCTLVAR }}}="{{{ SYSCTLVAL }}}"
49eb97
+/sbin/sysctl -q -n -w {{{ SYSCTLVAR }}}="{{{ SYSCTLVAL_REMEDIATE }}}"
49eb97
 
49eb97
 #
49eb97
-# If {{{ SYSCTLVAR }}} present in /etc/sysctl.conf, change value to "{{{ SYSCTLVAL }}}"
49eb97
-#	else, add "{{{ SYSCTLVAR }}} = {{{ SYSCTLVAL }}}" to /etc/sysctl.conf
49eb97
+# If {{{ SYSCTLVAR }}} present in /etc/sysctl.conf, change value to "{{{ SYSCTLVAL_REMEDIATE }}}"
49eb97
+#	else, add "{{{ SYSCTLVAR }}} = {{{ SYSCTLVAL_REMEDIATE }}}" to /etc/sysctl.conf
49eb97
 #
49eb97
-{{{ bash_replace_or_append('/etc/sysctl.conf', '^' + SYSCTLVAR , SYSCTLVAL ) }}}
49eb97
+{{{ bash_replace_or_append('/etc/sysctl.conf', '^' + SYSCTLVAR , SYSCTLVAL_REMEDIATE ) }}}
49eb97
 {{%- endif %}}
49eb97
diff --git a/shared/templates/sysctl/template.py b/shared/templates/sysctl/template.py
49eb97
index 421e42c6ca1..2574d5d42b0 100644
49eb97
--- a/shared/templates/sysctl/template.py
49eb97
+++ b/shared/templates/sysctl/template.py
49eb97
@@ -16,6 +16,15 @@ def preprocess(data, lang):
49eb97
             "The sysctlval parameter of {0} is an empty list".format(
49eb97
                 data["_rule_id"]))
49eb97
 
49eb97
+    if not data.get("sysctlval_remediate"):
49eb97
+        if isinstance(data["sysctlval"], list):
49eb97
+            raise ValueError(
49eb97
+                "Problem with rule {0}: the 'sysctlval' parameter is a list "
49eb97
+                "but we are missing the 'sysctlval_remediate' parameter, so "
49eb97
+                "we don't know how to generate remediation content.".format(
49eb97
+                    data["_rule_id"]))
49eb97
+        data["sysctlval_remediate"] = data["sysctlval"]
49eb97
+
49eb97
     # Configure data for test scenarios
49eb97
     if data["datatype"] not in ["string", "int"]:
49eb97
         raise ValueError(
49eb97
49eb97
From 8a3ba3f74760b360e179da221acf7bb06f4bdc12 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Wed, 13 Jul 2022 17:10:16 +0200
49eb97
Subject: [PATCH 08/23] Introduce new rule
49eb97
 sysctl_kernel_unprivileged_bpf_disabled_accept_default
49eb97
49eb97
This rule is very similar to the existing rule
49eb97
sysctl_kernel_unprivileged_bpf_disabled, but it allows the sysctl
49eb97
setting kernel.unprivileged_bpf_disabled to be either 1 or 2. Also, the
49eb97
rule will pass when the explicit configuration isn't present, allowing
49eb97
to honor the system's default value which is 2. The goal of this rule is
49eb97
to prevent unnecessary modification of the RHEL system default value
49eb97
while still checking for the secure configuration.
49eb97
49eb97
See the explanation in
49eb97
https://bugzilla.redhat.com/show_bug.cgi?id=2081728:
49eb97
sysctl_kernel_unprivileged_bpf_disabled sets the
49eb97
kernel.unprivileged_bpf_disabled value to 1.  However, on RHEL 9 the
49eb97
kernel supports new value 2 which per
49eb97
https://www.kernel.org/doc/html/latest/admin-guide/sysctl/kernel.html#unprivileged-bpf-disabled
49eb97
makes it for a privileged admin to re-enable unprivileged BPF. The value
49eb97
2 is also the RHEL 9 default. So the current
49eb97
sysctl_kernel_unprivileged_bpf_disabled rule unnecessarily modifies
49eb97
the RHEL 9 default.
49eb97
---
49eb97
 .../rule.yml                                  | 82 +++++++++++++++++++
49eb97
 shared/references/cce-redhat-avail.txt        |  1 -
49eb97
 2 files changed, 82 insertions(+), 1 deletion(-)
49eb97
 create mode 100644 linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
new file mode 100644
49eb97
index 00000000000..f45769dd2d0
49eb97
--- /dev/null
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
@@ -0,0 +1,82 @@
49eb97
+documentation_complete: true
49eb97
+
49eb97
+prodtype: rhel9
49eb97
+
49eb97
+title: 'Disable Access to Network bpf() Syscall From Unprivileged Processes'
49eb97
+
49eb97
+description: |-
49eb97
+    To prevent unprivileged processes from using the bpf() syscall
49eb97
+    the kernel.unprivileged_bpf_disabled kernel parameter must
49eb97
+    be set to 1 or 2.
49eb97
+
49eb97
+    Writing 1 to this entry will disable unprivileged calls to bpf(); once
49eb97
+    disabled, calling bpf() without CAP_SYS_ADMIN or CAP_BPF will return -EPERM.
49eb97
+    Once set to 1, this can't be cleared from the running kernel anymore.
49eb97
+
49eb97
+    Writing 2 to this entry will also disable unprivileged calls to bpf(),
49eb97
+    however, an admin can still change this setting later on, if needed, by
49eb97
+    writing 0 or 1 to this entry.
49eb97
+
49eb97
+    {{{ describe_sysctl_option_value(sysctl="kernel.unprivileged_bpf_disabled", value="1") }}}
49eb97
+
49eb97
+rationale: |-
49eb97
+    Loading and accessing the packet filters programs and maps using the bpf()
49eb97
+    syscall has the potential of revealing sensitive information about the kernel state.
49eb97
+
49eb97
+severity: medium
49eb97
+
49eb97
+identifiers:
49eb97
+    cce@rhel9: CCE-87712-6
49eb97
+
49eb97
+references:
49eb97
+    disa: CCI-000366
49eb97
+    nist: AC-6,SC-7(10)
49eb97
+    ospp: FMT_SMF_EXT.1
49eb97
+    srg: SRG-OS-000132-GPOS-00067,SRG-OS-000480-GPOS-00227
49eb97
+    stigid@ol8: OL08-00-040281
49eb97
+    stigid@rhel8: RHEL-08-040281
49eb97
+
49eb97
+ocil: |-
49eb97
+    The runtime status of the kernel.unprivileged_bpf_disabled
49eb97
+    kernel parameter can be queried by running the following command:
49eb97
+    
$ sysctl kernel.unprivileged_bpf_disabled
49eb97
+    The output of the command should indicate either:
49eb97
+    kernel.unprivileged_bpf_disabled = 1
49eb97
+    or:
49eb97
+    kernel.unprivileged_bpf_disabled = 2
49eb97
+    The output of the command should not indicate:
49eb97
+    kernel.unprivileged_bpf_disabled = 0
49eb97
+
49eb97
+    The preferable way how to assure the runtime compliance is to have
49eb97
+    correct persistent configuration, and rebooting the system.
49eb97
+
49eb97
+    The persistent kernel parameter configuration is performed by specifying the appropriate
49eb97
+    assignment in any file located in the 
/etc/sysctl.d
directory.
49eb97
+    Verify that there is not any existing incorrect configuration by executing the following command:
49eb97
+    
$ grep -r '^\s*{{{ sysctl }}}\s*=' /etc/sysctl.conf /etc/sysctl.d
49eb97
+    The command should not find any assignments other than:
49eb97
+    kernel.unprivileged_bpf_disabled = 1
49eb97
+    or:
49eb97
+    kernel.unprivileged_bpf_disabled = 2
49eb97
+
49eb97
+    Duplicate assignments are not allowed. Empty output is allowed, because the system default is 2.
49eb97
+
49eb97
+ocil_clause: "the kernel.unprivileged_bpf_disabled is not set to 1 or 2 or is configured to be 0"
49eb97
+
49eb97
+fixtext: |-
49eb97
+    Configure {{{ full_name }}} to prevent privilege escalation thru the kernel by disabling access to the bpf syscall.
49eb97
+
49eb97
+srg_requirement: '{{{ full_name }}} must disable access to network bpf syscall from unprivileged processes.'
49eb97
+
49eb97
+platform: machine
49eb97
+
49eb97
+template:
49eb97
+    name: sysctl
49eb97
+    vars:
49eb97
+        sysctlvar: kernel.unprivileged_bpf_disabled
49eb97
+        sysctlval:
49eb97
+        - '1'
49eb97
+        - '2'
49eb97
+        sysctlval_remediate: "2"
49eb97
+        missing_static_pass: "true"
49eb97
+        datatype: int
49eb97
diff --git a/shared/references/cce-redhat-avail.txt b/shared/references/cce-redhat-avail.txt
49eb97
index 914233f06bf..2c2cf12cafe 100644
49eb97
--- a/shared/references/cce-redhat-avail.txt
49eb97
+++ b/shared/references/cce-redhat-avail.txt
49eb97
@@ -1435,7 +1435,6 @@ CCE-87708-4
49eb97
 CCE-87709-2
49eb97
 CCE-87710-0
49eb97
 CCE-87711-8
49eb97
-CCE-87712-6
49eb97
 CCE-87713-4
49eb97
 CCE-87714-2
49eb97
 CCE-87715-9
49eb97
49eb97
From 0327b48990c2cf35aeff8adf63a2102378e43c54 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Wed, 13 Jul 2022 17:21:50 +0200
49eb97
Subject: [PATCH 09/23] Add test scenarios for rule
49eb97
 sysctl_kernel_unprivileged_bpf_disabled_accept_default
49eb97
49eb97
---
49eb97
 .../tests/system_default.pass.sh                      |  5 +++++
49eb97
 .../tests/test_config.yml                             |  6 ++++++
49eb97
 .../tests/value_0.fail.sh                             | 11 +++++++++++
49eb97
 .../tests/value_1.pass.sh                             | 11 +++++++++++
49eb97
 .../tests/value_2.pass.sh                             | 11 +++++++++++
49eb97
 5 files changed, 44 insertions(+)
49eb97
 create mode 100644 linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/system_default.pass.sh
49eb97
 create mode 100644 linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml
49eb97
 create mode 100644 linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_0.fail.sh
49eb97
 create mode 100644 linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_1.pass.sh
49eb97
 create mode 100644 linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_2.pass.sh
49eb97
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/system_default.pass.sh b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/system_default.pass.sh
49eb97
new file mode 100644
49eb97
index 00000000000..b9776227bdb
49eb97
--- /dev/null
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/system_default.pass.sh
49eb97
@@ -0,0 +1,5 @@
49eb97
+#!/bin/bash
49eb97
+# platform = Red Hat Enterprise Linux 9
49eb97
+
49eb97
+# Clean sysctl config directories
49eb97
+rm -rf /usr/lib/sysctl.d/* /run/sysctl.d/* /etc/sysctl.d/*
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml
49eb97
new file mode 100644
49eb97
index 00000000000..dbac89b4caa
49eb97
--- /dev/null
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml
49eb97
@@ -0,0 +1,6 @@
49eb97
+deny_templated_scenarios:
49eb97
+  - line_not_there.fail.sh
49eb97
+  - comment.fail.sh
49eb97
+  - wrong_value.fail.sh
49eb97
+  - wrong_value_d_directory.fail.sh
49eb97
+  - wrong_runtime.fail.sh
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_0.fail.sh b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_0.fail.sh
49eb97
new file mode 100644
49eb97
index 00000000000..9f19e0140b4
49eb97
--- /dev/null
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_0.fail.sh
49eb97
@@ -0,0 +1,11 @@
49eb97
+#!/bin/bash
49eb97
+# platform = Red Hat Enterprise Linux 9
49eb97
+
49eb97
+# Clean sysctl config directories
49eb97
+rm -rf /usr/lib/sysctl.d/* /run/sysctl.d/* /etc/sysctl.d/*
49eb97
+
49eb97
+sed -i "/kernel.unprivileged_bpf_disabled/d" /etc/sysctl.conf
49eb97
+echo "kernel.unprivileged_bpf_disabled = 0" >> /etc/sysctl.conf
49eb97
+
49eb97
+# set correct runtime value to check if the filesystem configuration is evaluated properly
49eb97
+sysctl -w kernel.unprivileged_bpf_disabled="0"
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_1.pass.sh b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_1.pass.sh
49eb97
new file mode 100644
49eb97
index 00000000000..e976db594c8
49eb97
--- /dev/null
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_1.pass.sh
49eb97
@@ -0,0 +1,11 @@
49eb97
+#!/bin/bash
49eb97
+# platform = Red Hat Enterprise Linux 9
49eb97
+
49eb97
+# Clean sysctl config directories
49eb97
+rm -rf /usr/lib/sysctl.d/* /run/sysctl.d/* /etc/sysctl.d/*
49eb97
+
49eb97
+sed -i "/kernel.unprivileged_bpf_disabled/d" /etc/sysctl.conf
49eb97
+echo "kernel.unprivileged_bpf_disabled = 1" >> /etc/sysctl.conf
49eb97
+
49eb97
+# set correct runtime value to check if the filesystem configuration is evaluated properly
49eb97
+sysctl -w kernel.unprivileged_bpf_disabled="1"
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_2.pass.sh b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_2.pass.sh
49eb97
new file mode 100644
49eb97
index 00000000000..b1537175eb4
49eb97
--- /dev/null
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/value_2.pass.sh
49eb97
@@ -0,0 +1,11 @@
49eb97
+#!/bin/bash
49eb97
+# platform = Red Hat Enterprise Linux 9
49eb97
+
49eb97
+# Clean sysctl config directories
49eb97
+rm -rf /usr/lib/sysctl.d/* /run/sysctl.d/* /etc/sysctl.d/*
49eb97
+
49eb97
+sed -i "/kernel.unprivileged_bpf_disabled/d" /etc/sysctl.conf
49eb97
+echo "kernel.unprivileged_bpf_disabled = 2" >> /etc/sysctl.conf
49eb97
+
49eb97
+# set correct runtime value to check if the filesystem configuration is evaluated properly
49eb97
+sysctl -w kernel.unprivileged_bpf_disabled="2"
49eb97
49eb97
From 52415b3effb7bf80038b8d866982fd44c8c45312 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Thu, 14 Jul 2022 09:14:53 +0200
49eb97
Subject: [PATCH 10/23] Use rule
49eb97
 sysctl_kernel_unprivileged_bpf_disabled_accept_default
49eb97
49eb97
Use rule sysctl_kernel_unprivileged_bpf_disabled_accept_default
49eb97
instead of the rule sysctl_kernel_unprivileged_bpf_disabled
49eb97
in the RHEL 9 OSPP profile.
49eb97
---
49eb97
 products/rhel9/profiles/ospp.profile | 2 +-
49eb97
 1 file changed, 1 insertion(+), 1 deletion(-)
49eb97
49eb97
diff --git a/products/rhel9/profiles/ospp.profile b/products/rhel9/profiles/ospp.profile
49eb97
index a7ba9532d2c..19e4878c4b0 100644
49eb97
--- a/products/rhel9/profiles/ospp.profile
49eb97
+++ b/products/rhel9/profiles/ospp.profile
49eb97
@@ -74,7 +74,7 @@ selections:
49eb97
     - sysctl_kernel_yama_ptrace_scope
49eb97
     - sysctl_kernel_perf_event_paranoid
49eb97
     - sysctl_user_max_user_namespaces
49eb97
-    - sysctl_kernel_unprivileged_bpf_disabled
49eb97
+    - sysctl_kernel_unprivileged_bpf_disabled_accept_default
49eb97
     - service_kdump_disabled
49eb97
 
49eb97
     ### Audit
49eb97
49eb97
From 4ff536a006a9d25c9c90a1b1e5fce0f957c51c28 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Thu, 14 Jul 2022 09:25:26 +0200
49eb97
Subject: [PATCH 11/23] Document that sysctlval can be a list
49eb97
49eb97
---
49eb97
 docs/templates/template_reference.md | 3 ++-
49eb97
 1 file changed, 2 insertions(+), 1 deletion(-)
49eb97
49eb97
diff --git a/docs/templates/template_reference.md b/docs/templates/template_reference.md
49eb97
index 5785f1d453f..716407fd5c9 100644
49eb97
--- a/docs/templates/template_reference.md
49eb97
+++ b/docs/templates/template_reference.md
49eb97
@@ -815,7 +815,8 @@ The selected value can be changed in the profile (consult the actual variable fo
49eb97
 
49eb97
     -   **datatype** - data type of the sysctl value, eg. `int`.
49eb97
 
49eb97
-    -   **sysctlval** - value of the sysctl value, eg. `'1'`. If this
49eb97
+    -   **sysctlval** - value of the sysctl value. This can be either an atomic
49eb97
+        value, eg. `'1'`, or a list of values, eg. `['1','2']`. If this
49eb97
         parameter is not specified, XCCDF Value is used instead.
49eb97
 
49eb97
     -   **sysctlval_remediate** - the value that will be used in remediations.
49eb97
49eb97
From df27fec11a6e8037288ee8cf5b7bfc7d05537f33 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Thu, 14 Jul 2022 11:00:59 +0200
49eb97
Subject: [PATCH 12/23] Document the missing_static_pass option
49eb97
49eb97
---
49eb97
 docs/templates/template_reference.md | 5 +++++
49eb97
 1 file changed, 5 insertions(+)
49eb97
49eb97
diff --git a/docs/templates/template_reference.md b/docs/templates/template_reference.md
49eb97
index 716407fd5c9..65da697b808 100644
49eb97
--- a/docs/templates/template_reference.md
49eb97
+++ b/docs/templates/template_reference.md
49eb97
@@ -827,6 +827,11 @@ The selected value can be changed in the profile (consult the actual variable fo
49eb97
         should be remedied to. When  the **sysctlval** parameter is not a list
49eb97
         this parameter is optional.
49eb97
 
49eb97
+    -   **missing_static_pass** - if set to `true` the check will pass if the
49eb97
+        setting for the given **sysctlvar** is not present in sysctl
49eb97
+        configuration files. In other words, the check will pass if the system
49eb97
+        default isn't overriden by configuration. Default value: `false`.
49eb97
+
49eb97
     -   **operation** - operation used for comparison of collected object
49eb97
         with **sysctlval**. Default value: `equals`.
49eb97
 
49eb97
49eb97
From e8b8497d32d84282d7f34d83f3661c02235d33cb Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Thu, 14 Jul 2022 11:03:53 +0200
49eb97
Subject: [PATCH 13/23] Introduce sysctlval_wrong parameter
49eb97
49eb97
When the `sysctalval` parameter is a list, this parameter will be
49eb97
substitued into the SYSCTL_WRONG_VALUE parameter in test scenarios. This
49eb97
is better than current computing of the SYSCTL_WRONG_VALUE parameter
49eb97
which is done by prepending "1" to the string value, because the
49eb97
computed value could be invalid and the `sysctl -w` command used in the
49eb97
test scenario wrong_runtime.fail.sh could fail to set the value to
49eb97
SYSCTL_WRONG_VALUE therefore not changing the runtime. If at the same
49eb97
time the `missing_static_pass` is set to `true` and the system is set to
49eb97
system default, then the unchanged runtime would cause the check to pass
49eb97
and therefore the test scenario wrong_runtime.fail.sh to error.
49eb97
---
49eb97
 docs/templates/template_reference.md                       | 3 +++
49eb97
 .../rule.yml                                               | 1 +
49eb97
 shared/templates/sysctl/template.py                        | 7 ++-----
49eb97
 3 files changed, 6 insertions(+), 5 deletions(-)
49eb97
49eb97
diff --git a/docs/templates/template_reference.md b/docs/templates/template_reference.md
49eb97
index 65da697b808..7e1fc7049cf 100644
49eb97
--- a/docs/templates/template_reference.md
49eb97
+++ b/docs/templates/template_reference.md
49eb97
@@ -827,6 +827,9 @@ The selected value can be changed in the profile (consult the actual variable fo
49eb97
         should be remedied to. When  the **sysctlval** parameter is not a list
49eb97
         this parameter is optional.
49eb97
 
49eb97
+    -   **sysctlval_wrong** - the value that is always wrong. This will be used
49eb97
+        only in the test scenarios only if **sysctlval** is a list.
49eb97
+
49eb97
     -   **missing_static_pass** - if set to `true` the check will pass if the
49eb97
         setting for the given **sysctlvar** is not present in sysctl
49eb97
         configuration files. In other words, the check will pass if the system
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
index f45769dd2d0..ddff15dff8f 100644
49eb97
--- a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
@@ -78,5 +78,6 @@ template:
49eb97
         - '1'
49eb97
         - '2'
49eb97
         sysctlval_remediate: "2"
49eb97
+        sysctlval_wrong: "0"
49eb97
         missing_static_pass: "true"
49eb97
         datatype: int
49eb97
diff --git a/shared/templates/sysctl/template.py b/shared/templates/sysctl/template.py
49eb97
index 2574d5d42b0..96663694997 100644
49eb97
--- a/shared/templates/sysctl/template.py
49eb97
+++ b/shared/templates/sysctl/template.py
49eb97
@@ -41,11 +41,8 @@ def preprocess(data, lang):
49eb97
             data["sysctl_correct_value"] = "correct_value"
49eb97
             data["sysctl_wrong_value"] = "wrong_value"
49eb97
     elif isinstance(data["sysctlval"], list):
49eb97
-        data["sysctl_correct_value"] = data["sysctlval"][0]
49eb97
-        if data["datatype"] == "int":
49eb97
-            data["sysctl_wrong_value"] = "1" + data["sysctlval"][0]
49eb97
-        elif data["datatype"] == "string":
49eb97
-            data["sysctl_wrong_value"] = "wrong_value"
49eb97
+        data["sysctl_correct_value"] = data["sysctlval_remediate"]
49eb97
+        data["sysctl_wrong_value"] = data["sysctlval_wrong"]
49eb97
     else:
49eb97
         data["sysctl_correct_value"] = data["sysctlval"]
49eb97
         if data["datatype"] == "int":
49eb97
49eb97
From 5f391a7053f7ce18dd34c45a1d319d65b78348d4 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Thu, 14 Jul 2022 11:23:59 +0200
49eb97
Subject: [PATCH 14/23] Change test_config.yml
49eb97
49eb97
---
49eb97
 .../tests/test_config.yml                                   | 6 +++---
49eb97
 1 file changed, 3 insertions(+), 3 deletions(-)
49eb97
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml
49eb97
index dbac89b4caa..c379680e25c 100644
49eb97
--- a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml
49eb97
@@ -1,6 +1,6 @@
49eb97
 deny_templated_scenarios:
49eb97
+  # this rule uses missing_static_pass: true which means the check should pass
49eb97
+  # if the configuration is missing (or commented out) therefore we disable
49eb97
+  # line_not_there.fail.sh and comment.fail.sh test scenarios
49eb97
   - line_not_there.fail.sh
49eb97
   - comment.fail.sh
49eb97
-  - wrong_value.fail.sh
49eb97
-  - wrong_value_d_directory.fail.sh
49eb97
-  - wrong_runtime.fail.sh
49eb97
49eb97
From 92207a9bd11df0e69bf732e27fb91e5db270f7f6 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Fri, 15 Jul 2022 10:36:05 +0200
49eb97
Subject: [PATCH 15/23] Simplify sysctl template
49eb97
49eb97
Instead of using multiple OVAL tests in OR relation we can have
49eb97
a single OVAL test containing multiple OVAL states in OR relation.
49eb97
That will simplify the code.
49eb97
---
49eb97
 shared/templates/sysctl/oval.template | 82 +++++----------------------
49eb97
 1 file changed, 13 insertions(+), 69 deletions(-)
49eb97
49eb97
diff --git a/shared/templates/sysctl/oval.template b/shared/templates/sysctl/oval.template
49eb97
index 1719a59f9c7..8241c391ad2 100644
49eb97
--- a/shared/templates/sysctl/oval.template
49eb97
+++ b/shared/templates/sysctl/oval.template
49eb97
@@ -8,7 +8,13 @@
49eb97
 
49eb97
 {{% macro state_static_sysctld(prefix) -%}}
49eb97
     <ind:object object_ref="object_static_{{{ prefix }}}_{{{ rule_id }}}"/>
49eb97
+{{% if SYSCTLVAL is string %}}
49eb97
     <ind:state state_ref="state_static_sysctld_{{{ rule_id }}}"/>
49eb97
+{{% elif SYSCTLVAL is sequence %}}
49eb97
+{{% for x in SYSCTLVAL %}}
49eb97
+    <ind:state state_ref="state_static_sysctld_{{{ rule_id }}}_{{{ x }}}" />
49eb97
+{{% endfor %}}
49eb97
+{{% endif %}}
49eb97
 {{%- endmacro -%}}
49eb97
 {{%- macro sysctl_match() -%}}
49eb97
 {{%- if SYSCTLVAL == "" -%}}
49eb97
@@ -62,38 +68,24 @@
49eb97
 <def-group>
49eb97
   <definition class="compliance" id="{{{ rule_id }}}_runtime" version="3">
49eb97
     {{{ oval_metadata("The kernel '" + SYSCTLVAR + "' parameter should be set to " + COMMENT_VALUE + " in the system runtime.") }}}
49eb97
-{{% if SYSCTLVAL is string %}}
49eb97
     <criteria operator="AND">
49eb97
       
49eb97
                  test_ref="test_{{{ rule_id }}}_runtime"/>
49eb97
     </criteria>
49eb97
-{{% elif SYSCTLVAL is sequence %}}
49eb97
-    <criteria operator="OR">
49eb97
-{{% for x in SYSCTLVAL %}}
49eb97
-      
49eb97
-                 test_ref="test_{{{ rule_id }}}_runtime_{{{ x }}}"/>
49eb97
-{{% endfor %}}
49eb97
-    </criteria>
49eb97
-{{% endif %}}
49eb97
   </definition>
49eb97
 
49eb97
-{{% if SYSCTLVAL is string %}}
49eb97
   
49eb97
                     comment="kernel runtime parameter {{{ SYSCTLVAR }}} set to {{{ COMMENT_VALUE }}}"
49eb97
-                    check="all" check_existence="all_exist">
49eb97
+                    check="all" check_existence="all_exist" state_operator="OR">
49eb97
     <unix:object object_ref="object_{{{ rule_id }}}_runtime"/>
49eb97
+{{% if SYSCTLVAL is string %}}
49eb97
     <unix:state state_ref="state_{{{ rule_id }}}_runtime"/>
49eb97
-  </unix:sysctl_test>
49eb97
 {{% elif SYSCTLVAL is sequence %}}
49eb97
 {{% for x in SYSCTLVAL %}}
49eb97
-  
49eb97
-                    comment="kernel runtime parameter {{{ SYSCTLVAR }}} set to {{{ x }}}"
49eb97
-                    check="all" check_existence="all_exist">
49eb97
-    <unix:object object_ref="object_{{{ rule_id }}}_runtime"/>
49eb97
     <unix:state state_ref="state_{{{ rule_id }}}_runtime_{{{ x }}}" />
49eb97
-  </unix:sysctl_test>
49eb97
 {{% endfor %}}
49eb97
 {{% endif %}}
49eb97
+  </unix:sysctl_test>
49eb97
 
49eb97
   <unix:sysctl_object id="object_{{{ rule_id }}}_runtime" version="1">
49eb97
     <unix:name>{{{ SYSCTLVAR }}}</unix:name>
49eb97
@@ -139,7 +131,6 @@
49eb97
 {{% endif %}}
49eb97
     <criteria operator="AND">
49eb97
       <criteria operator="OR">
49eb97
-{{% if SYSCTLVAL is string %}}
49eb97
         
49eb97
                    test_ref="test_{{{ rule_id }}}_static"/>
49eb97
         
49eb97
@@ -150,21 +141,6 @@
49eb97
 {{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel7", "rhel8", "rhel9"] %}}
49eb97
         
49eb97
                    test_ref="test_{{{ rule_id }}}_static_usr_lib_sysctld"/>
49eb97
-{{% endif %}}
49eb97
-{{% elif SYSCTLVAL is sequence %}}
49eb97
-{{% for x in SYSCTLVAL %}}
49eb97
-        
49eb97
-                   test_ref="test_{{{ rule_id }}}_static_{{{ x }}}"/>
49eb97
-        
49eb97
-        
49eb97
-                   test_ref="test_{{{ rule_id }}}_static_{{{ x }}}_etc_sysctld"/>
49eb97
-        
49eb97
-                   test_ref="test_{{{ rule_id }}}_static_{{{ x }}}_run_sysctld"/>
49eb97
-{{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel7", "rhel8", "rhel9"] %}}
49eb97
-        
49eb97
-                   test_ref="test_{{{ rule_id }}}_static_{{{ x }}}_usr_lib_sysctld"/>
49eb97
-{{% endif %}}
49eb97
-{{% endfor %}}
49eb97
 {{% endif %}}
49eb97
       </criteria>
49eb97
 {{% if target_oval_version >= [5, 11] %}}
49eb97
@@ -185,61 +161,29 @@
49eb97
   </ind:textfilecontent54_test>
49eb97
 {{% endif %}}
49eb97
 
49eb97
-{{% if SYSCTLVAL is string %}}
49eb97
   
49eb97
                               check="all" check_existence="all_exist"
49eb97
-                              comment="{{{ SYSCTLVAR }}} static configuration">
49eb97
+                              comment="{{{ SYSCTLVAR }}} static configuration" state_operator="OR">
49eb97
     {{{ state_static_sysctld("sysctl") }}}
49eb97
   </ind:textfilecontent54_test>
49eb97
 
49eb97
   
49eb97
-                          comment="{{{ SYSCTLVAR }}} static configuration in /etc/sysctl.d/*.conf">
49eb97
+                          comment="{{{ SYSCTLVAR }}} static configuration in /etc/sysctl.d/*.conf" state_operator="OR">
49eb97
     {{{ state_static_sysctld("etc_sysctld") }}}
49eb97
   </ind:textfilecontent54_test>
49eb97
 
49eb97
   
49eb97
-                          comment="{{{ SYSCTLVAR }}} static configuration in /run/sysctl.d/*.conf">
49eb97
+                          comment="{{{ SYSCTLVAR }}} static configuration in /run/sysctl.d/*.conf" state_operator="OR">
49eb97
     {{{ state_static_sysctld("run_sysctld") }}}
49eb97
   </ind:textfilecontent54_test>
49eb97
 
49eb97
 {{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel7", "rhel8", "rhel9"] %}}
49eb97
   
49eb97
                           check="all"
49eb97
-                          comment="{{{ SYSCTLVAR }}} static configuration in /usr/lib/sysctl.d/*.conf">
49eb97
+                          comment="{{{ SYSCTLVAR }}} static configuration in /usr/lib/sysctl.d/*.conf" state_operator="OR">
49eb97
     {{{ state_static_sysctld("usr_lib_sysctld") }}}
49eb97
   </ind:textfilecontent54_test>
49eb97
 {{% endif %}}
49eb97
-{{% elif SYSCTLVAL is sequence %}}
49eb97
-{{% for x in SYSCTLVAL %}}
49eb97
-  
49eb97
-                              check="all" check_existence="all_exist"
49eb97
-                              comment="{{{ SYSCTLVAR }}} static configuration">
49eb97
-    <ind:object object_ref="object_static_sysctl_{{{ rule_id }}}"/>
49eb97
-    <ind:state state_ref="state_static_sysctld_{{{ rule_id }}}_{{{ x }}}"/>
49eb97
-  </ind:textfilecontent54_test>
49eb97
-
49eb97
-  
49eb97
-                          comment="{{{ SYSCTLVAR }}} static configuration in /etc/sysctl.d/*.conf">
49eb97
-    <ind:object object_ref="object_static_etc_sysctld_{{{ rule_id }}}"/>
49eb97
-    <ind:state state_ref="state_static_sysctld_{{{ rule_id }}}_{{{ x }}}"/>
49eb97
-  </ind:textfilecontent54_test>
49eb97
-
49eb97
-  
49eb97
-                          comment="{{{ SYSCTLVAR }}} static configuration in /run/sysctl.d/*.conf">
49eb97
-    <ind:object object_ref="object_static_run_sysctld_{{{ rule_id }}}"/>
49eb97
-    <ind:state state_ref="state_static_sysctld_{{{ rule_id }}}_{{{ x }}}"/>
49eb97
-  </ind:textfilecontent54_test>
49eb97
-
49eb97
-{{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel7", "rhel8", "rhel9"] %}}
49eb97
-  
49eb97
-                          check="all"
49eb97
-                          comment="{{{ SYSCTLVAR }}} static configuration in /usr/lib/sysctl.d/*.conf">
49eb97
-    <ind:object object_ref="object_static_usr_lib_sysctld_{{{ rule_id }}}"/>
49eb97
-    <ind:state state_ref="state_static_sysctld_{{{ rule_id }}}_{{{ x }}}"/>
49eb97
-  </ind:textfilecontent54_test>
49eb97
-{{% endif %}}
49eb97
-{{% endfor %}}
49eb97
-{{% endif %}}
49eb97
 
49eb97
 {{% if target_oval_version >= [5, 11] %}}
49eb97
   
49eb97
49eb97
From d78d946740b0b8bef31c054ad0b5c4ab14159442 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Mon, 25 Jul 2022 15:40:24 +0200
49eb97
Subject: [PATCH 16/23] Replace the sysctlval_remediate template parameter
49eb97
49eb97
Replace the sysctlval_remediate template parameter by using an XCCDF
49eb97
value. The variable would be only used in the remediation and would
49eb97
allow users to tailor the value, instead of the current solution where
49eb97
the value is hardcoded and can be only changed during build time.
49eb97
---
49eb97
 docs/templates/template_reference.md          | 21 +++++++++----------
49eb97
 .../rule.yml                                  |  1 -
49eb97
 products/rhel9/profiles/ospp.profile          |  1 +
49eb97
 shared/templates/sysctl/ansible.template      |  6 +++---
49eb97
 shared/templates/sysctl/bash.template         | 10 ++++-----
49eb97
 shared/templates/sysctl/template.py           | 11 +---------
49eb97
 6 files changed, 20 insertions(+), 30 deletions(-)
49eb97
49eb97
diff --git a/docs/templates/template_reference.md b/docs/templates/template_reference.md
49eb97
index 7e1fc7049cf..00f991daae7 100644
49eb97
--- a/docs/templates/template_reference.md
49eb97
+++ b/docs/templates/template_reference.md
49eb97
@@ -815,17 +815,16 @@ The selected value can be changed in the profile (consult the actual variable fo
49eb97
 
49eb97
     -   **datatype** - data type of the sysctl value, eg. `int`.
49eb97
 
49eb97
-    -   **sysctlval** - value of the sysctl value. This can be either an atomic
49eb97
-        value, eg. `'1'`, or a list of values, eg. `['1','2']`. If this
49eb97
-        parameter is not specified, XCCDF Value is used instead.
49eb97
-
49eb97
-    -   **sysctlval_remediate** - the value that will be used in remediations.
49eb97
-        If **sysctlval_remediate** is not specified, the template will use the
49eb97
-        value of the **sysctlval** parameter in the remediations.
49eb97
-        This parameter is mandatory when the **sysctlval** parameter is a list
49eb97
-        because we need to know which of the values in the list the system
49eb97
-        should be remedied to. When  the **sysctlval** parameter is not a list
49eb97
-        this parameter is optional.
49eb97
+    -   **sysctlval** - value of the sysctl value. This can be either not
49eb97
+        specified, or an atomic value, eg. `'1'`, or a list of values,
49eb97
+        eg. `['1','2']`.
49eb97
+        -   If this parameter is not specified, an XCCDF Value is used instead
49eb97
+            in OVAL check and remediations.
49eb97
+        -   If this parameter is set to an atomic value, this atomic value
49eb97
+            will be used in OVAL check and remediations.
49eb97
+        -   If this parameter is set to a list of values, the list will be used
49eb97
+            in the OVAL check, but won't be used in the remediations.
49eb97
+            All remediations will use an XCCDF value instead.
49eb97
 
49eb97
     -   **sysctlval_wrong** - the value that is always wrong. This will be used
49eb97
         only in the test scenarios only if **sysctlval** is a list.
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
index ddff15dff8f..9936ed777c8 100644
49eb97
--- a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
@@ -77,7 +77,6 @@ template:
49eb97
         sysctlval:
49eb97
         - '1'
49eb97
         - '2'
49eb97
-        sysctlval_remediate: "2"
49eb97
         sysctlval_wrong: "0"
49eb97
         missing_static_pass: "true"
49eb97
         datatype: int
49eb97
diff --git a/products/rhel9/profiles/ospp.profile b/products/rhel9/profiles/ospp.profile
49eb97
index 19e4878c4b0..b47630c62b0 100644
49eb97
--- a/products/rhel9/profiles/ospp.profile
49eb97
+++ b/products/rhel9/profiles/ospp.profile
49eb97
@@ -75,6 +75,7 @@ selections:
49eb97
     - sysctl_kernel_perf_event_paranoid
49eb97
     - sysctl_user_max_user_namespaces
49eb97
     - sysctl_kernel_unprivileged_bpf_disabled_accept_default
49eb97
+    - sysctl_kernel_unprivileged_bpf_disabled_value=2
49eb97
     - service_kdump_disabled
49eb97
 
49eb97
     ### Audit
49eb97
diff --git a/shared/templates/sysctl/ansible.template b/shared/templates/sysctl/ansible.template
49eb97
index 7724db5e5ff..edc4d3fb667 100644
49eb97
--- a/shared/templates/sysctl/ansible.template
49eb97
+++ b/shared/templates/sysctl/ansible.template
49eb97
@@ -21,7 +21,7 @@
49eb97
     replace: '#{{{ SYSCTLVAR }}}'
49eb97
   loop: "{{ find_sysctl_d.files }}"
49eb97
 
49eb97
-{{%- if SYSCTLVAL_REMEDIATE == "" %}}
49eb97
+{{%- if SYSCTLVAL == "" or SYSCTLVAL is not string  %}}
49eb97
 - (xccdf-var sysctl_{{{ SYSCTLID }}}_value)
49eb97
 
49eb97
 - name: Ensure sysctl {{{ SYSCTLVAR }}} is set
49eb97
@@ -29,10 +29,10 @@
49eb97
     name: "{{{ SYSCTLVAR }}}"
49eb97
     value: "{{ sysctl_{{{ SYSCTLID }}}_value }}"
49eb97
 {{%- else %}}
49eb97
-- name: Ensure sysctl {{{ SYSCTLVAR }}} is set to {{{ SYSCTLVAL_REMEDIATE }}}
49eb97
+- name: Ensure sysctl {{{ SYSCTLVAR }}} is set to {{{ SYSCTLVAL }}}
49eb97
   sysctl:
49eb97
     name: "{{{ SYSCTLVAR }}}"
49eb97
-    value: "{{{ SYSCTLVAL_REMEDIATE }}}"
49eb97
+    value: "{{{ SYSCTLVAL }}}"
49eb97
 {{%- endif %}}
49eb97
     state: present
49eb97
     reload: yes
49eb97
diff --git a/shared/templates/sysctl/bash.template b/shared/templates/sysctl/bash.template
49eb97
index 63948bd5a26..cd3424b0228 100644
49eb97
--- a/shared/templates/sysctl/bash.template
49eb97
+++ b/shared/templates/sysctl/bash.template
49eb97
@@ -20,7 +20,7 @@ for f in /etc/sysctl.d/*.conf /run/sysctl.d/*.conf; do
49eb97
   fi
49eb97
 done
49eb97
 
49eb97
-{{%- if SYSCTLVAL_REMEDIATE == "" %}}
49eb97
+{{%- if SYSCTLVAL == "" or SYSCTLVAL is not string %}}
49eb97
 {{{ bash_instantiate_variables("sysctl_" + SYSCTLID + "_value") }}}
49eb97
 
49eb97
 #
49eb97
@@ -38,11 +38,11 @@ done
49eb97
 #
49eb97
 # Set runtime for {{{ SYSCTLVAR }}}
49eb97
 #
49eb97
-/sbin/sysctl -q -n -w {{{ SYSCTLVAR }}}="{{{ SYSCTLVAL_REMEDIATE }}}"
49eb97
+/sbin/sysctl -q -n -w {{{ SYSCTLVAR }}}="{{{ SYSCTLVAL }}}"
49eb97
 
49eb97
 #
49eb97
-# If {{{ SYSCTLVAR }}} present in /etc/sysctl.conf, change value to "{{{ SYSCTLVAL_REMEDIATE }}}"
49eb97
-#	else, add "{{{ SYSCTLVAR }}} = {{{ SYSCTLVAL_REMEDIATE }}}" to /etc/sysctl.conf
49eb97
+# If {{{ SYSCTLVAR }}} present in /etc/sysctl.conf, change value to "{{{ SYSCTLVAL }}}"
49eb97
+#	else, add "{{{ SYSCTLVAR }}} = {{{ SYSCTLVAL }}}" to /etc/sysctl.conf
49eb97
 #
49eb97
-{{{ bash_replace_or_append('/etc/sysctl.conf', '^' + SYSCTLVAR , SYSCTLVAL_REMEDIATE ) }}}
49eb97
+{{{ bash_replace_or_append('/etc/sysctl.conf', '^' + SYSCTLVAR , SYSCTLVAL ) }}}
49eb97
 {{%- endif %}}
49eb97
diff --git a/shared/templates/sysctl/template.py b/shared/templates/sysctl/template.py
49eb97
index 96663694997..2b779f99a62 100644
49eb97
--- a/shared/templates/sysctl/template.py
49eb97
+++ b/shared/templates/sysctl/template.py
49eb97
@@ -16,15 +16,6 @@ def preprocess(data, lang):
49eb97
             "The sysctlval parameter of {0} is an empty list".format(
49eb97
                 data["_rule_id"]))
49eb97
 
49eb97
-    if not data.get("sysctlval_remediate"):
49eb97
-        if isinstance(data["sysctlval"], list):
49eb97
-            raise ValueError(
49eb97
-                "Problem with rule {0}: the 'sysctlval' parameter is a list "
49eb97
-                "but we are missing the 'sysctlval_remediate' parameter, so "
49eb97
-                "we don't know how to generate remediation content.".format(
49eb97
-                    data["_rule_id"]))
49eb97
-        data["sysctlval_remediate"] = data["sysctlval"]
49eb97
-
49eb97
     # Configure data for test scenarios
49eb97
     if data["datatype"] not in ["string", "int"]:
49eb97
         raise ValueError(
49eb97
@@ -41,7 +32,7 @@ def preprocess(data, lang):
49eb97
             data["sysctl_correct_value"] = "correct_value"
49eb97
             data["sysctl_wrong_value"] = "wrong_value"
49eb97
     elif isinstance(data["sysctlval"], list):
49eb97
-        data["sysctl_correct_value"] = data["sysctlval_remediate"]
49eb97
+        data["sysctl_correct_value"] = data["sysctlval"][0]
49eb97
         data["sysctl_wrong_value"] = data["sysctlval_wrong"]
49eb97
     else:
49eb97
         data["sysctl_correct_value"] = data["sysctlval"]
49eb97
49eb97
From 817b47544b4a62aad8153360839bb14dd607d46d Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Mon, 25 Jul 2022 15:47:11 +0200
49eb97
Subject: [PATCH 17/23] Rename a template parameter
49eb97
49eb97
Rename the sysctlval_wrong parameter to wrong_sysctlval_for_testing
49eb97
---
49eb97
 docs/templates/template_reference.md                          | 4 ++--
49eb97
 .../rule.yml                                                  | 2 +-
49eb97
 shared/templates/sysctl/template.py                           | 2 +-
49eb97
 3 files changed, 4 insertions(+), 4 deletions(-)
49eb97
49eb97
diff --git a/docs/templates/template_reference.md b/docs/templates/template_reference.md
49eb97
index 00f991daae7..4e6357c1579 100644
49eb97
--- a/docs/templates/template_reference.md
49eb97
+++ b/docs/templates/template_reference.md
49eb97
@@ -826,8 +826,8 @@ The selected value can be changed in the profile (consult the actual variable fo
49eb97
             in the OVAL check, but won't be used in the remediations.
49eb97
             All remediations will use an XCCDF value instead.
49eb97
 
49eb97
-    -   **sysctlval_wrong** - the value that is always wrong. This will be used
49eb97
-        only in the test scenarios only if **sysctlval** is a list.
49eb97
+    -   **wrong_sysctlval_for_testing** - the value that is always wrong. This will be used
49eb97
+        only in the templated test scenarios only if **sysctlval** is a list.
49eb97
 
49eb97
     -   **missing_static_pass** - if set to `true` the check will pass if the
49eb97
         setting for the given **sysctlvar** is not present in sysctl
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
index 9936ed777c8..b8af4f7560d 100644
49eb97
--- a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
@@ -77,6 +77,6 @@ template:
49eb97
         sysctlval:
49eb97
         - '1'
49eb97
         - '2'
49eb97
-        sysctlval_wrong: "0"
49eb97
+        wrong_sysctlval_for_testing: "0"
49eb97
         missing_static_pass: "true"
49eb97
         datatype: int
49eb97
diff --git a/shared/templates/sysctl/template.py b/shared/templates/sysctl/template.py
49eb97
index 2b779f99a62..9083a6a4185 100644
49eb97
--- a/shared/templates/sysctl/template.py
49eb97
+++ b/shared/templates/sysctl/template.py
49eb97
@@ -33,7 +33,7 @@ def preprocess(data, lang):
49eb97
             data["sysctl_wrong_value"] = "wrong_value"
49eb97
     elif isinstance(data["sysctlval"], list):
49eb97
         data["sysctl_correct_value"] = data["sysctlval"][0]
49eb97
-        data["sysctl_wrong_value"] = data["sysctlval_wrong"]
49eb97
+        data["sysctl_wrong_value"] = data["wrong_sysctlval_for_testing"]
49eb97
     else:
49eb97
         data["sysctl_correct_value"] = data["sysctlval"]
49eb97
         if data["datatype"] == "int":
49eb97
49eb97
From ed48698e95f96891889fa2c2039172015ae9f069 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Mon, 25 Jul 2022 15:56:26 +0200
49eb97
Subject: [PATCH 18/23] Rename parameter missing_static_pass
49eb97
49eb97
Rename the parameter missing_static_pass to missing_parameter_pass
49eb97
to make the naming consistent with other templates where a parameter
49eb97
with a similar meaning exist.
49eb97
---
49eb97
 docs/templates/template_reference.md                        | 2 +-
49eb97
 .../rule.yml                                                | 2 +-
49eb97
 .../tests/test_config.yml                                   | 2 +-
49eb97
 shared/templates/sysctl/oval.template                       | 6 +++---
49eb97
 4 files changed, 6 insertions(+), 6 deletions(-)
49eb97
49eb97
diff --git a/docs/templates/template_reference.md b/docs/templates/template_reference.md
49eb97
index 4e6357c1579..0fff58c0a23 100644
49eb97
--- a/docs/templates/template_reference.md
49eb97
+++ b/docs/templates/template_reference.md
49eb97
@@ -829,7 +829,7 @@ The selected value can be changed in the profile (consult the actual variable fo
49eb97
     -   **wrong_sysctlval_for_testing** - the value that is always wrong. This will be used
49eb97
         only in the templated test scenarios only if **sysctlval** is a list.
49eb97
 
49eb97
-    -   **missing_static_pass** - if set to `true` the check will pass if the
49eb97
+    -   **missing_parameter_pass** - if set to `true` the check will pass if the
49eb97
         setting for the given **sysctlvar** is not present in sysctl
49eb97
         configuration files. In other words, the check will pass if the system
49eb97
         default isn't overriden by configuration. Default value: `false`.
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
index b8af4f7560d..7d8769a913f 100644
49eb97
--- a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
@@ -78,5 +78,5 @@ template:
49eb97
         - '1'
49eb97
         - '2'
49eb97
         wrong_sysctlval_for_testing: "0"
49eb97
-        missing_static_pass: "true"
49eb97
+        missing_parameter_pass: "true"
49eb97
         datatype: int
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml
49eb97
index c379680e25c..5cf68074050 100644
49eb97
--- a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/tests/test_config.yml
49eb97
@@ -1,5 +1,5 @@
49eb97
 deny_templated_scenarios:
49eb97
-  # this rule uses missing_static_pass: true which means the check should pass
49eb97
+  # this rule uses missing_parameter_pass: true which means the check should pass
49eb97
   # if the configuration is missing (or commented out) therefore we disable
49eb97
   # line_not_there.fail.sh and comment.fail.sh test scenarios
49eb97
   - line_not_there.fail.sh
49eb97
diff --git a/shared/templates/sysctl/oval.template b/shared/templates/sysctl/oval.template
49eb97
index 8241c391ad2..1a7c4979bbe 100644
49eb97
--- a/shared/templates/sysctl/oval.template
49eb97
+++ b/shared/templates/sysctl/oval.template
49eb97
@@ -126,7 +126,7 @@
49eb97
 <def-group>
49eb97
   <definition class="compliance" id="{{{ rule_id }}}_static" version="3">
49eb97
     {{{ oval_metadata("The kernel '" + SYSCTLVAR + "' parameter should be set to " + COMMENT_VALUE + " in the system configuration.") }}}
49eb97
-{{% if MISSING_STATIC_PASS == "true" %}}
49eb97
+{{% if MISSING_PARAMETER_PASS == "true" %}}
49eb97
     <criteria operator="OR">
49eb97
 {{% endif %}}
49eb97
     <criteria operator="AND">
49eb97
@@ -147,13 +147,13 @@
49eb97
       <criterion comment="Check that {{{ SYSCTLID }}} is defined in only one file" test_ref="test_{{{ rule_id }}}_defined_in_one_file" />
49eb97
 {{% endif %}}
49eb97
     </criteria>
49eb97
-{{% if MISSING_STATIC_PASS == "true" %}}
49eb97
+{{% if MISSING_PARAMETER_PASS == "true" %}}
49eb97
       <criterion comment="Check that {{{ SYSCTLID }}} is not defined in any file" test_ref="test_{{{ rule_id }}}_not_defined" />
49eb97
     </criteria>
49eb97
 {{% endif %}}
49eb97
   </definition>
49eb97
 
49eb97
-{{% if MISSING_STATIC_PASS == "true" %}}
49eb97
+{{% if MISSING_PARAMETER_PASS == "true" %}}
49eb97
   
49eb97
                               check="all" check_existence="none_exist"
49eb97
                               comment="{{{ SYSCTLVAR }}} static configuration">
49eb97
49eb97
From f022f549c6d0b5bc0d24c5d1b7c606d23efbd6d2 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Mon, 25 Jul 2022 16:26:03 +0200
49eb97
Subject: [PATCH 19/23] Add a variable
49eb97
 sysctl_kernel_unprivileged_bpf_disabled_value
49eb97
49eb97
---
49eb97
 ..._kernel_unprivileged_bpf_disabled_value.var | 18 ++++++++++++++++++
49eb97
 1 file changed, 18 insertions(+)
49eb97
 create mode 100644 linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_value.var
49eb97
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_value.var b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_value.var
49eb97
new file mode 100644
49eb97
index 00000000000..b8bf965a255
49eb97
--- /dev/null
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_value.var
49eb97
@@ -0,0 +1,18 @@
49eb97
+documentation_complete: true
49eb97
+
49eb97
+title: kernel.unprivileged_bpf_disabled
49eb97
+
49eb97
+description: |-
49eb97
+    Prevent unprivileged processes from using the bpf() syscall.
49eb97
+
49eb97
+type: number
49eb97
+
49eb97
+operator: equals
49eb97
+
49eb97
+interactive: false
49eb97
+
49eb97
+options:
49eb97
+    default: 2
49eb97
+    0: "0"
49eb97
+    1: "1"
49eb97
+    2: "2"
49eb97
49eb97
From 4c8ef02cc91c821d56c061f6d8e2ba1675d0c414 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Tue, 26 Jul 2022 09:36:09 +0200
49eb97
Subject: [PATCH 20/23] Improve documentation of the sysctl template
49eb97
49eb97
---
49eb97
 docs/templates/template_reference.md | 10 +++++++---
49eb97
 1 file changed, 7 insertions(+), 3 deletions(-)
49eb97
49eb97
diff --git a/docs/templates/template_reference.md b/docs/templates/template_reference.md
49eb97
index 0fff58c0a23..e73b95450fe 100644
49eb97
--- a/docs/templates/template_reference.md
49eb97
+++ b/docs/templates/template_reference.md
49eb97
@@ -819,15 +819,19 @@ The selected value can be changed in the profile (consult the actual variable fo
49eb97
         specified, or an atomic value, eg. `'1'`, or a list of values,
49eb97
         eg. `['1','2']`.
49eb97
         -   If this parameter is not specified, an XCCDF Value is used instead
49eb97
-            in OVAL check and remediations.
49eb97
+            in OVAL check and remediations. The XCCDF Value should have a file
49eb97
+            name in the form `"sysctl_" + $escaped_sysctlvar + "_value.var"`,
49eb97
+            where the `escaped_sysctlvar` is a value of the **sysctlvar**
49eb97
+            parameter in which all characters that don't match the `\w` regular
49eb97
+            expression are replaced by an underscore (`_`).
49eb97
         -   If this parameter is set to an atomic value, this atomic value
49eb97
             will be used in OVAL check and remediations.
49eb97
         -   If this parameter is set to a list of values, the list will be used
49eb97
             in the OVAL check, but won't be used in the remediations.
49eb97
             All remediations will use an XCCDF value instead.
49eb97
 
49eb97
-    -   **wrong_sysctlval_for_testing** - the value that is always wrong. This will be used
49eb97
-        only in the templated test scenarios only if **sysctlval** is a list.
49eb97
+    -   **wrong_sysctlval_for_testing** - the value that is always wrong. This
49eb97
+        will be used in templated test scenarios when **sysctlval** is a list.
49eb97
 
49eb97
     -   **missing_parameter_pass** - if set to `true` the check will pass if the
49eb97
         setting for the given **sysctlvar** is not present in sysctl
49eb97
49eb97
From 0f89cab50807ecf75269acc49e0c290c139beea6 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Tue, 26 Jul 2022 09:36:34 +0200
49eb97
Subject: [PATCH 21/23] Remove RHEL 8 STIG ID
49eb97
49eb97
---
49eb97
 .../rule.yml                                                    | 2 --
49eb97
 1 file changed, 2 deletions(-)
49eb97
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
index 7d8769a913f..ec3b5aef82f 100644
49eb97
--- a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
@@ -33,8 +33,6 @@ references:
49eb97
     nist: AC-6,SC-7(10)
49eb97
     ospp: FMT_SMF_EXT.1
49eb97
     srg: SRG-OS-000132-GPOS-00067,SRG-OS-000480-GPOS-00227
49eb97
-    stigid@ol8: OL08-00-040281
49eb97
-    stigid@rhel8: RHEL-08-040281
49eb97
 
49eb97
 ocil: |-
49eb97
     The runtime status of the kernel.unprivileged_bpf_disabled
49eb97
49eb97
From 5c2116eb08b84c43d644f6ce51744732a63fb206 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Tue, 26 Jul 2022 09:36:47 +0200
49eb97
Subject: [PATCH 22/23] Fix a typo
49eb97
49eb97
---
49eb97
 .../rule.yml                                                    | 2 +-
49eb97
 1 file changed, 1 insertion(+), 1 deletion(-)
49eb97
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
index ec3b5aef82f..589deccb0c7 100644
49eb97
--- a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
@@ -62,7 +62,7 @@ ocil: |-
49eb97
 ocil_clause: "the kernel.unprivileged_bpf_disabled is not set to 1 or 2 or is configured to be 0"
49eb97
 
49eb97
 fixtext: |-
49eb97
-    Configure {{{ full_name }}} to prevent privilege escalation thru the kernel by disabling access to the bpf syscall.
49eb97
+    Configure {{{ full_name }}} to prevent privilege escalation through the kernel by disabling access to the bpf syscall.
49eb97
 
49eb97
 srg_requirement: '{{{ full_name }}} must disable access to network bpf syscall from unprivileged processes.'
49eb97
 
49eb97
49eb97
From 22e5a11f3232234a939dc6a806752b1fa5c69ce4 Mon Sep 17 00:00:00 2001
49eb97
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
49eb97
Date: Wed, 27 Jul 2022 10:36:04 +0200
49eb97
Subject: [PATCH 23/23] Mention both values 1 and 2 in the rule description
49eb97
49eb97
---
49eb97
 .../rule.yml                                                  | 4 +++-
49eb97
 1 file changed, 3 insertions(+), 1 deletion(-)
49eb97
49eb97
diff --git a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
index 589deccb0c7..259d1f901c6 100644
49eb97
--- a/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
+++ b/linux_os/guide/system/permissions/restrictions/sysctl_kernel_unprivileged_bpf_disabled_accept_default/rule.yml
49eb97
@@ -13,11 +13,13 @@ description: |-
49eb97
     disabled, calling bpf() without CAP_SYS_ADMIN or CAP_BPF will return -EPERM.
49eb97
     Once set to 1, this can't be cleared from the running kernel anymore.
49eb97
 
49eb97
+    {{{ describe_sysctl_option_value(sysctl="kernel.unprivileged_bpf_disabled", value="1") }}}
49eb97
+
49eb97
     Writing 2 to this entry will also disable unprivileged calls to bpf(),
49eb97
     however, an admin can still change this setting later on, if needed, by
49eb97
     writing 0 or 1 to this entry.
49eb97
 
49eb97
-    {{{ describe_sysctl_option_value(sysctl="kernel.unprivileged_bpf_disabled", value="1") }}}
49eb97
+    {{{ describe_sysctl_option_value(sysctl="kernel.unprivileged_bpf_disabled", value="2") }}}
49eb97
 
49eb97
 rationale: |-
49eb97
     Loading and accessing the packet filters programs and maps using the bpf()