Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The host-based OP-TEE test additions have no active review issues.
No open issues 🎉
What changed in this PR
Adds host-based tests for the fwTPM OP-TEE trusted application port introduced in #659, extending coverage beyond hardware testing with a mock TEE.
Changes:
- Adds RAM-backed secure storage and injectable TEE failures.
- Integrates stubbed-core port tests into
make checkand adds real-core tests for session ownership and NV persistence. - Adds standard and sanitizer CI runs against pinned wolfSSL, with nightly runs against master.
| File | Description |
|---|---|
tests/optee/user_settings.h |
Configures wolfCrypt and fwTPM for host core tests. |
tests/optee/tee_internal_api.h |
Declares the mocked TEE API subset. |
tests/optee/tee_internal_api_extensions.h |
Provides the port-compatible extension header. |
tests/optee/README.md |
Documents both suites and build commands. |
tests/optee/pta_system.h |
Defines the mock system PTA interface. |
tests/optee/optee_core.mk |
Builds the port with real fwTPM and wolfCrypt sources. |
tests/optee/optee_core_tests.c |
Tests ownership, persistence, MAC rejection and INOUT responses. |
tests/optee/mock_tee.h |
Exposes mock storage controls and fault injection. |
tests/optee/mock_tee.c |
Implements the RAM-backed TEE stand-in. |
tests/optee/fwtpm_optee_port_tests.c |
Tests key selection, storage, sessions and buffer handling. |
tests/include.am |
Registers port tests and distributes supporting files. |
.gitignore |
Ignores generated test binaries and logs. |
.github/workflows/optee-mock.yml |
Runs real-core tests in standard and sanitizer configurations. |
Review effort: Balanced
167db15 to
684700e
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #674
Scan targets checked: wolftpm-src, wolftpm-bugs
Not reviewed (no scan target covers them): .github/workflows/optee-mock.yml, .gitignore, tests/include.am, tests/optee/README.md, tests/optee/mock_tee.h, tests/optee/optee_core.mk, tests/optee/pta_system.h, tests/optee/tee_internal_api.h, tests/optee/tee_internal_api_extensions.h, tests/optee/user_settings.h
Coverage: 4 of 4 in-scope changed file(s) opened by the reviewer
Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Max
| mockTeeFaults.deriveFail = 1; | ||
| CHECK(TA_CreateEntryPoint() != TEE_SUCCESS, | ||
| "PTA unavailable: TA refuses to start"); | ||
| journal = MockTee_ObjectData(FWTPM_OPTEE_NV_OBJECT_ID, NULL); |
There was a problem hiding this comment.
"journal left untouched" check cannot detect a truncated or erased journal · Weak or missing assertions
The test calls MockTee_ObjectData with a NULL size, and the mock's TEE_TruncateObjectData only lowers size without clearing bytes. A failed start that truncates or erases the journal through FwOpteeNvErase still passes "journal left untouched".
Suggested fix: Read the current size through MockTee_ObjectData's size argument and require it to equal the saved size before the XMEMCMP.
Basis: tests/optee/mock_tee.c MockTee_ObjectData() returns the object's current data stream size through its size argument, and TEE_TruncateObjectData() in the same mock changes only that size.
| res = Submit(s, rsp, FWTPM_OPTEE_MIN_RSP_SIZE, | ||
| TEE_PARAM_TYPE_MEMREF_INOUT, &out); | ||
| CHECK(res == TEE_SUCCESS && stubProcessCalls == before + 1 && out == 64 && | ||
| rsp[0] == 0x5A, "kernel driver shape (4096, INOUT) works"); |
There was a problem hiding this comment.
INOUT response check passes on stale buffer contents · Weak or missing assertions
rsp still holds 0x5A from the test_ta_sessions submits, so rsp[0] == 0x5A passes even if the INOUT response is never copied. test_kernel_driver_shape in optee_core_tests.c has the same gap: the status it checks is stale data from the earlier Startup response.
Description
The OP-TEE trusted application port from #659 was only exercised on a Jetson Orin. This adds a mock TEE so the port is tested on the host in
make checkand CI. Everything lives undertests/optee.What it adds
tests/optee/tee_internal_api.h,pta_system.h,mock_tee.c- RAM-backed stand-in for the TEE Internal Core API subset the port and wolfCrypt'sWOLFSSL_OPTEEsupport use, with injectable failures (system PTA missing, key object unreadable, storage unavailable)tests/optee/fwtpm_optee_port_tests.c-tests/fwtpm_optee_port.testinmake checkfor every fwTPM configuration; stubs the fwTPM core and covers NV integrity key selection, secure storage access, session to client mapping and command/response buffer handlingtests/optee/optee_core_tests.c,optee_core.mk,user_settings.h- the port with the real fwTPM core and wolfCrypt compiled from source asWOLFSSL_OPTEE, driven through the TA entry points; covers per-session ownership of transient objects and the NV journal in secure storage across TA instances, including a missing PTA and a journal that fails its MAC.github/workflows/optee-mock.yml- runs the core tests, plain and under ASan/UBSan, against a pinned wolfSSL commit on pushes and pull requests that touch the fwTPM, and against wolfSSL master on the nightly triggertests/optee/README.md- how the two suites are built and runTouches port code
src/fwtpm/ports/optee/fwtpm_optee_ta.c- check the command buffer size before narrowing it touint32_t; on a 64-bit TA a size above 4 GiB was truncated and could pass the buffer size checkTesting
Both suites pass locally, under ASan/UBSan, with clang and under scan-build. Each was checked against deliberate faults in the port and core (no flush on session close, flush of every client, fallback key created over an existing journal, response staging buffer not cleared, short-buffer check after the command runs, gap filled with zeroes, uncached integrity key), and every fault fails at least one test.