<def-group>
  <definition class="compliance" id="grub2_page_alloc_shuffle_argument" version="2">
    <metadata>
        <title>Enable randomization of the page allocator</title>
        
    <affected family="unix">
    <platform>Ubuntu 22.04</platform>
    </affected>
        <description>Ensure page_alloc.shuffle=1 is configured in the kernel line in /etc/default/grub.</description>
    </metadata>
    <criteria operator="OR">
    <criteria operator="AND">
      
      
      
          <criterion test_ref="test_grub2_page_alloc_shuffle_argument_grub_cfg"
          comment="Check if page_alloc.shuffle=1 is present in the boot parameters in the /boot/grub/grub.cfg for all kernels" />
          
      <criteria operator="OR">
          <criteria operator="OR">
            <criterion test_ref="test_grub2_page_alloc_shuffle_argument"
            comment="check for page_alloc.shuffle=1 in /etc/default/grub via GRUB_CMDLINE_LINUX" />
            <criterion test_ref="test_grub2_page_alloc_shuffle_argument_configdir"
            comment="check for page_alloc.shuffle=1 in /etc/default/grub.d/*cfg via GRUB_CMDLINE_LINUX" />
          </criteria>
          <criteria operator="AND">
            <criteria operator="OR">
              <criterion test_ref="test_grub2_page_alloc_shuffle_argument_default"
              comment="check for page_alloc.shuffle=1 in /etc/default/grub via GRUB_CMDLINE_LINUX_DEFAULT" />
              <criterion test_ref="test_grub2_page_alloc_shuffle_argument_default_configdir"
              comment="check for page_alloc.shuffle=1 in /etc/default/grub.d/*cfg via GRUB_CMDLINE_LINUX_DEFAULT" />
            </criteria>
            <extend_definition definition_ref="bootloader_disable_recovery_set_to_true"
            comment="Check GRUB_DISABLE_RECOVERY=true in /etc/default/grub" />
          </criteria>
        </criteria>
    </criteria>
    
    </criteria>
  </definition>


  <ind:textfilecontent54_test id="test_grub2_page_alloc_shuffle_argument"
  comment="check for page_alloc.shuffle=1 in /etc/default/grub via GRUB_CMDLINE_LINUX"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_grub2_page_alloc_shuffle_argument" />
    <ind:state state_ref="state_grub2_page_alloc_shuffle_argument" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_grub2_page_alloc_shuffle_argument" version="1">
    <ind:filepath>/etc/default/grub</ind:filepath>
    <ind:pattern operation="pattern match">^\s*GRUB_CMDLINE_LINUX="(.*)"$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>

  <ind:textfilecontent54_test id="test_grub2_page_alloc_shuffle_argument_default"
  comment="check for page_alloc.shuffle=1 in /etc/default/grub via GRUB_CMDLINE_LINUX_DEFAULT"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_grub2_page_alloc_shuffle_argument_default" />
    <ind:state state_ref="state_grub2_page_alloc_shuffle_argument" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_grub2_page_alloc_shuffle_argument_default"
  version="1">
    <ind:filepath>/etc/default/grub</ind:filepath>
    <ind:pattern operation="pattern match">^\s*GRUB_CMDLINE_LINUX_DEFAULT="(.*)"$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>

<ind:textfilecontent54_test id="test_grub2_page_alloc_shuffle_argument_configdir"
  comment="check for page_alloc.shuffle=1 in /etc/default/grub.d/*cfg via GRUB_CMDLINE_LINUX"
  check="at least one" check_existence="all_exist" version="1">
    <ind:object object_ref="object_grub2_page_alloc_shuffle_argument_configdir" />
    <ind:state state_ref="state_grub2_page_alloc_shuffle_argument" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_test id="test_grub2_page_alloc_shuffle_argument_default_configdir"
  comment="check for page_alloc.shuffle=1 in /etc/default/grub via GRUB_CMDLINE_LINUX_DEFAULT"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_grub2_page_alloc_shuffle_argument_default_configdir" />
    <ind:state state_ref="state_grub2_page_alloc_shuffle_argument" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_grub2_page_alloc_shuffle_argument_configdir" version="1">
    <ind:filepath operation="pattern match">/etc/default/grub.d/[^/]+\.cfg</ind:filepath>
    <ind:pattern operation="pattern match">^\s*GRUB_CMDLINE_LINUX="(.*)"$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>

  <ind:textfilecontent54_object id="object_grub2_page_alloc_shuffle_argument_default_configdir"
  version="1">
    <ind:filepath>/etc/default/grub.d/*.cfg</ind:filepath>
    <ind:pattern operation="pattern match">^\s*GRUB_CMDLINE_LINUX_DEFAULT="(.*)"$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>


  <ind:textfilecontent54_test id="test_grub2_page_alloc_shuffle_argument_grub_cfg"
  comment="check kernel command line parameters for page_alloc.shuffle=1 in /boot/grub/grub.cfg for all kernels"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_grub2_page_alloc_shuffle_argument_grub_cfg" />
    <ind:state state_ref="state_grub2_page_alloc_shuffle_argument" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_grub2_page_alloc_shuffle_argument_grub_cfg"
  version="1">
    <ind:filepath>/boot/grub/grub.cfg</ind:filepath>
    
      <ind:pattern operation="pattern match">^.*/vmlinuz.*(root=.*)$</ind:pattern>
    
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>





  <ind:textfilecontent54_state id="state_grub2_page_alloc_shuffle_argument"
  version="1">
    <ind:subexpression datatype="string" operation="pattern match">^(?:.*\s)?page_alloc\.shuffle=1(?:\s.*)?$</ind:subexpression>
  </ind:textfilecontent54_state>




</def-group>