Commit 7d41b40
fix(tee): harden entry_std parameter handling
Three independent defects on the Non-Secure entry path, found while
investigating the HOTP key-size overflow. None is HOTP-specific, so they
are split out from that fix.
1. pt[] is used uninitialised. copy_in_params() declares
uint8_t pt[TEE_NUM_PARAMS] and assigns only pt[0..num_params-1], but
all four entries are read when building ta_param->types. num_params is
Non-Secure controlled, so a caller sending num_params < 4 hands the TA
stale secure-stack bytes as parameter types; ta_param->u[] is zeroed,
so a TA can observe e.g. MEMREF_INOUT with {buffer = NULL, size = 0}.
Not reachable from the stock client, which always sends 4, but it is
the hostile-caller model 27e314c addressed. Initialise to
TEE_PARAM_TYPE_NONE (0).
2. Zero-length validation bypass in nsec_check(). The function returned
its pointer unvalidated when len == 0, so a memref of
{buffer = <secure address>, size = 0} reached a TA with a secure
pointer intact. The kernel does not dereference it, but the TA might,
if it does not consult the size. Attribution-check non-NULL pointers
one byte at a time; NULL and legitimate zero-length Non-Secure memrefs
still pass.
3. Dead func snapshot. tee_ioctl_invoke() snapshots func = arg->func then
passes arg->func, re-reading Non-Secure memory after validation.
Harmless today, but it defeats the single-fetch discipline of 27e314c
and leaves an unused variable. Pass the snapshot.
Verified under QEMU (mps2-an505, cortex-m33): the NS->S attribution
negative test still rejects all five crafted secure-pointer cases with
ACCESS_DENIED, and the AES example still completes ("Clear text and
decoded text match"), which is the guard against 2 over-tightening
nsec_check. numaker_pfm_m2351 (armv8-m.base) builds clean.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent d71301d commit 7d41b40
1 file changed
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
98 | 103 | | |
99 | 104 | | |
100 | 105 | | |
101 | 106 | | |
102 | 107 | | |
103 | 108 | | |
104 | | - | |
| 109 | + | |
105 | 110 | | |
106 | 111 | | |
107 | 112 | | |
| |||
283 | 288 | | |
284 | 289 | | |
285 | 290 | | |
286 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
287 | 298 | | |
288 | 299 | | |
289 | 300 | | |
| |||
577 | 588 | | |
578 | 589 | | |
579 | 590 | | |
580 | | - | |
| 591 | + | |
581 | 592 | | |
582 | 593 | | |
583 | 594 | | |
| |||
0 commit comments