Make kASLR mandatory
The requirement begins for devices launching with API 33+.
Test: atest KernelConfigTest
Change-Id: I360016a092f30fee550aa8f93c8b5ece8730e10b
diff --git a/hostsidetests/security/src/android/security/cts/KernelConfigTest.java b/hostsidetests/security/src/android/security/cts/KernelConfigTest.java
index 1a9ce61..48dcb48 100644
--- a/hostsidetests/security/src/android/security/cts/KernelConfigTest.java
+++ b/hostsidetests/security/src/android/security/cts/KernelConfigTest.java
@@ -416,4 +416,24 @@
                     getDevice().hasFeature("feature:android.hardware.security.model.compatible"));
         }
     }
+
+    /**
+     * Test that the kernel is using kASLR.
+     *
+     * @throws Exception
+     */
+    @CddTest(requirement="9.7")
+    @Test
+    public void testConfigRandomizeBase() throws Exception {
+        if (PropertyUtil.getFirstApiLevel(mDevice) < 33) {
+            return;
+        }
+
+        if (CpuFeatures.isArm32(mDevice)) {
+            return;
+        }
+
+        assertTrue("The kernel's base address must be randomized",
+                configSet.contains("CONFIG_RANDOMIZE_BASE=y"));
+    }
 }