Repository navigation
soc: apple: aurora-boot-security: add KUnit tests - #2940
RyanTheTide wants to merge 5 commits into
Conversation
The boot security record decides what /sys/firmware/aurora/boot-security reports and whether the chain counts as verified. Add suites that build the record in the live devicetree with an of_changeset and call the driver's own functions: - the Stage 1 decision for every combination of stage, policy and verdict, one valid entry among many, none among many, values without a NUL terminator and string lists; - the effective chain state: "verified" only when the record says exactly that and an enforcing Stage 1 verified it, demoted otherwise; - what each sysfs attribute shows for absent, empty, unterminated, short, long and over-a-page values, with a guard area after the buffer; - init on a real /chosen record: none, a compatible that is not v1, a verified chain, a verified claim over an auditing Stage 1, and v1 listed second. Tests only, no functional change. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Review at 3539f5d. The only driver change is the
|
Check for live state before initializing either fixture and only tear down resources owned by the test. Skip the IMA submission case when IMA is enabled, and let the changeset own the fixture nodes. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The policy formatting case does not call IMA. Only skip the case that calls the measurement submission path. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at c283241f8ad80cced13c086e79f3b8b7eff38a04 (Draft PR — posting COMMENT).
Verified Fixes in 0935b9d9..c283241f
- Live-state isolation is solid:
bs_init()skips wheneverrec || aurora_kobj || bs_kobjis already populated and saves/restoreschain_state,lockdown_reason, andstage1_enforced;bs_exit()andbs_init_exit()guardif (!test->priv) return;. - Fixture nodes now attach under
/choseninstead ofof_root,bs_create_node()drops the extra refcount fromof_changeset_create_node()so the changeset cleanly owns lifetime,bs_raw()frees on allocation/of_changeset_add_property()failure, andbs_run_driver_init()clearsaurora_kobj/bs_kobjon init failure to prevent double-kobject_put(). bs_measure_record_full_page()skips whenCONFIG_IMA=ywhile keeping policy formatting coverage active, and Kconfig help text now documents theLOCKDOWN, live-state, andIMAskip conditions (thread item #3 resolved).
Remaining Blockers Before Undrafting / Merge
bs_page()is notPAGE_ALIGNED-safe underCONFIG_KASAN/CONFIG_SLUB_DEBUG(drivers/soc/apple/aurora-boot-security-test.c:197-205):kunit_kzalloc(test, 2 * PAGE_SIZE, GFP_KERNEL)hits thekmalloc-2*PAGE_SIZEslab cache (KMALLOC_MAX_CACHE_SIZE == 2 * PAGE_SIZE), not the page allocator. With slab redzoning enabled (CONFIG_KASANorslub_debug=FZ), the returned pointer is notPAGE_ALIGNED, causingKUNIT_ASSERT_TRUE(test, PAGE_ALIGNED(buf))(andsysfs_emit()'sWARN(offset_in_page(buf))) to fail on every sysfs show test. Allocate via__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1)(with akunit_add_action_or_reset()free wrapper) orvzalloc(2 * PAGE_SIZE)so the buffer is unconditionally page-aligned.- Kconfig blocks modular
KUNIT=mfleet builds (drivers/soc/apple/Kconfig:436-438, open from thread item #1):bool+depends on APPLE_AURORA_BOOT_SECURITY=y && KUNIT=y && OF_DYNAMIC+#include "aurora-boot-security-test.c"cannot build on fleet/distro kernels (APPLE_AURORA_BOOT_SECURITY=y,KUNIT=m). Convert the non-__initsuite to atristatetest module (VISIBLE_IF_KUNIT/EXPORT_SYMBOL_IF_KUNIT, keeping the__initsuite built-in-only), or document why built-in-only is intended. - Test-key /
stage1-flavour = "dev"coverage gap (open from thread item #2):bs_one_casesstill lacksBS_M("stage1", "enforce", "test-key")->false(pinning theaura#472contract), and there is still no explicit case stating the expected result for an enforcingstage1-flavour = "dev"record.
Non-blocking notes & CI
drivers/soc/apple/aurora-boot-security-test.c:83-110(bs_raw()): if an assertion aborts a test beforebs_apply()runs,p/p->name/p->valueare never linked ontonp->propertiesornp->deadpropsand will leak onof_changeset_destroy()(unlikeof_changeset_add_prop_helper(), which linksnew_ppontonp->deadpropsimmediately).- Production
drivers/soc/apple/aurora-boot-security.cis untouched aside from the#if IS_ENABLED(CONFIG_APPLE_AURORA_BOOT_SECURITY_KUNIT_TEST)include guard. - CI: All 7/7 checks are green (
SUCCESS), though note.github/workflows/sep-source.yml'skunitjob only executesapple_sep*, notaurora-boot-security.
Checklist (§1–§6)
- §1, §3, §6: Pass (synthetic OF changesets, no hardware MMIO, no keys, no model gates).
- §2: Open blockers #1–#3 above before undrafting.
- §4: Pass (all 3 commits carry human author/committer + human
Signed-off-by:, zero AI trailers in commits; PR bodyAssisted-by:present). - §5: Pass (81/81 arm64 QEMU + 75 pass / 6 skip with IMA+LOCKDOWN + negative controls + 7/7 CI green; test-only change).
Assisted-by: LLM (Gemini 4 Neon)
Keep init-section tests built in and let modular KUnit exercise the record reader. Allocate page-aligned sysfs fixtures and cover test-key verdicts and enforcing dev-flavour records. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
The record-reader suite can now load with The new cases check that an enforcing Stage 1 with a arm64 QEMU passed 83/83 built in with KASAN and Assisted-by: LLM (Codex) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-checked at 166c4b6. All three points from my 11-23 review are fixed:
- the sysfs page comes from
vzalloc(), so it is page-aligned under KASAN and slub_debug; - the record-reader suite builds as a module with
KUNIT=mthroughEXPORT_SYMBOL_IF_KUNIT, and only the init suite stays built in; - the new cases pin
test-keyas not verified, and an enforcingdevrecord as verified with flavourdev.
The leak note is fixed too: bs_raw() now puts the property on the node's deadprops, as of_changeset_add_prop_helper() does. Nothing more from me. It's test-only, so no hardware row is needed. The hosted run at this head was cancelled on 11-30 before it got runners, so it needs a fresh run when this comes out of draft.
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Forward-merged main f02bd68 as 0f33462 (clean merge, the four commits unchanged) so the hosted CI that was cancelled on 11-30 runs again. Local: arm64 LLVM W=1 with KUNIT=y, OF_DYNAMIC=y and the test as a module: |
Problem.
aurora-boot-securityturns the boot security record that the bootloader hands over in/choseninto what/sys/firmware/aurora/boot_securityreports, including whether the boot chain counts as verified. It had no test.Change. New suites
aurora-boot-securityandaurora-boot-security-initlive indrivers/soc/apple/aurora-boot-security-test.c. The record-reader suite can run as a module. The init suite is built in. Each case builds the record in the live devicetree with anof_changesetand calls the driver's own functions:state,advisory,lockdown,policy,stage1_flavour,uefi_secure_boot,lp_coih,measurements) shows for absent, empty, unterminated, short, long and over-a-page values, with a guard area after the buffer that must stay untouched;/chosen/aurora,boot-security: no record, a compatible that is not v1, a verified chain, a "verified" claim over an auditing Stage 1 (reported as partial/advisory), and v1 listed second.Plus a standalone
drivers/soc/apple/aurora-boot-security.kunitconfig. Both suites leave existing boot-security state alone. The synthetic measurement case skips when IMA is enabled.Testing.
kunit.py run --arch=arm64(QEMU, gcc): 81/81, standalone kunitconfig 81/81, and again with this wave's three branches merged on the integration/aurora tip.After review fixes, the suite passed again on the integration tip.
With IMA and boot-security lockdown enabled, arm64 QEMU passed 75 tests and skipped 6 as expected. The IMA submission and the init fixture were skipped.
Negative controls: the Stage 1 decision ignoring the policy (9 failures); the sha256 printed for
len >= 32instead of== 32(1); the "verified" demotion inverted (7).checkpatch --strict: 0 errors; the warning is the MAINTAINERS reminder for new files.
Follow-up arm64 QEMU with
slub_debug=FZpassed 83/83 built in, including five init cases, with both the standard and KASAN builds, and 78/78 withKUNIT=mand the record-reader suite loaded as a module. Both runs cover thetest-keyverdict and an enforcingdevrecord.Notes for reviewers
statestring (e.g. "Verified" or "verified\n") is passed through to sysfs as is. Kernel decisions don't change, and the tests check it is never reported as "verified". Mapping anything else to "unverified" would be tidier for userspace.Still to run. Nothing on hardware: the change is test-only.