The avb_ops.h header clearly indicates that it should be possible for the callers of the read_persistent_value interface to know that they provided too small a buffer, and the interface should also tell the callers how big a buffer would need to be.
However, that was never really implemented, neither here nor on the op-tee side. So if a too small buffer is passed, the caller simply gets a silently truncated result. I've proposed a fix on the op-tee side: https://github.com/OP-TEE/optee_os/pull/7959 . Since that is an ABI change (returning an error where it previously "succeeded", for some definition of succeed), the maintainer would like to see client side updates as well before that can be merged. So here are some of the changes that would be needed in U-Boot. I have not yet looked at any of the callers of the ->read_persistent_value method via the avb_ops structure, only the implementation of that method itself. Rasmus Villemoes (3): cmd: optee_rpmb: sanitize TEE_ERROR -> E* translations cmd: optee_rpmb: try to allocate large enough buffer when reading persistent value avb_verify: read_persistent_value: honour contract regarding too small buffer cmd/optee_rpmb.c | 45 ++++++++++++++++++++++++++++++--------------- common/avb_verify.c | 5 ++++- 2 files changed, 34 insertions(+), 16 deletions(-) -- 2.55.0
