From 0363e18ba9b6294216ce7318c2852297e079a1d1 Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Wed, 11 Nov 2026 10:50:53 -0500 Subject: [PATCH] soc: apple: sep: policy window test: admit the initrd ref-key unseal test_no_other_path_designates_outside_a_window fails on integration/aurora since #1340 merged, which fails the source check of every pull request. The test was written on a branch without 519d09bb ("support a trusted-key-only initrd attach"). That commit builds the ref-key unlock as a closure in refkey_unseal_cached and runs it inside crate::xart_guard::policy_window on the real root, but bare in the trusted-key-only initrd (keystore_only), on purpose: "Do not consume the real root's one policy window in the initrd". With the window shut the guard lets no existing session record be rewritten, so that path cannot make the rewrite the test protects against. Accept exactly that shape: the one deferred call in refkey_unseal_cached, whose closure is used twice, bare under keystore_only and in the window otherwise. Any other caller still has to open or close the window before the call. No runtime change. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Satya Benson --- tools/aurora-sep/tests/test_policy_window.py | 31 ++++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/tools/aurora-sep/tests/test_policy_window.py b/tools/aurora-sep/tests/test_policy_window.py index fda87d68a3f0c..d233b8c6ebd7a 100644 --- a/tools/aurora-sep/tests/test_policy_window.py +++ b/tools/aurora-sep/tests/test_policy_window.py @@ -97,12 +97,37 @@ def test_no_other_path_designates_outside_a_window(self): # after a ref-key create has closed the window for the boot. callers = calls(PREPARE) self.assertTrue(callers) + deferred = 0 for f, outer, body, at in callers: with self.subTest(caller=outer): before = body[:at] - self.assertTrue("crate::xart_guard::policy_window(" in before - or "crate::xart_guard::close_policy_window(" in before, - f"{f}: {outer}") + if ("crate::xart_guard::policy_window(" in before + or "crate::xart_guard::close_policy_window(" in before): + continue + # The call sits in a closure that is run later. + self.assertEqual((f, outer), ("refkey.rs", "refkey_unseal_cached")) + self.assertIn("let unlock = || {", before) + deferred += 1 + self.assert_unlock_runs_in_the_window_or_the_initrd(body[at:]) + self.assertEqual(deferred, 1) + + def assert_unlock_runs_in_the_window_or_the_initrd(self, after): + """`unlock` is run twice: in the window, or bare in the initrd. + + The trusted-key-only initrd attach (keystore_only) leaves the boot's + one window to the real root: "Do not consume the real root's one + policy window in the initrd". Its designate runs with the window + shut, where the guard lets no existing session record be rewritten. + """ + uses = re.findall(r"\bunlock\b(?!\s*=)", after) + self.assertEqual(len(uses), 2) + self.assertRegex( + after, + r"if self\.keystore_only\.load\(Relaxed\) \{\s*" + r"unlock\(\)\s*" + r"\} else \{\s*" + r"crate::xart_guard::policy_window\(unlock\)\s*" + r"\}") if __name__ == "__main__":