| 6e1990d7 | 03-Nov-2025 |
Ox Yeh <ox.yeh@mediatek.com> |
core: fs_htree: fix incorrect data type in create_and_sync
Fixes an incorrect data type used in the create_and_sync function. When this function calls tee_fs_htree_sync_to_storage, it may invoke tee
core: fs_htree: fix incorrect data type in create_and_sync
Fixes an incorrect data type used in the create_and_sync function. When this function calls tee_fs_htree_sync_to_storage, it may invoke tee_fs_htree_close to free the input hash tree in error cases. Therefore, the input type should be struct tee_fs_htree **ht_arg to handle these scenarios correctly.
Link: https://github.com/OP-TEE/optee_os/issues/7512 Fixes: 5a9d570a8d7f ("core: fs_htree: re-init hash tree when both tag and counter are zero")
Signed-off-by: Ox Yeh <ox.yeh@mediatek.com> Reviewed-by: Menson Chen <menson.chen@mediatek.com> Reviewed-by: Rayan Hu <rayan.hu@mediatek.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 00338334 | 31-Oct-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: support dynamic protected memory lending
With CFG_CORE_DYN_PROTMEM=y support dynamic protected memory lending.
A new internal struct mobj_ffa_rsm is added to handle dynamic protected memory f
core: support dynamic protected memory lending
With CFG_CORE_DYN_PROTMEM=y support dynamic protected memory lending.
A new internal struct mobj_ffa_rsm is added to handle dynamic protected memory for FF-A.
A new internal struct mobj_protmem is add to handle dynamic protected memory without FF-A.
Lending non-secure memory to OP-TEE to use it as protected memory means that it should to become inaccessible by the normal world as part of the process. This part is currently not supported, since it must be done in a platform specific way for platforms that support that. QEMU don't support that.
Adding two platform specific functions, plat_get_protmem_config() and plat_set_protmem_range() for dynamic protected memory. The functions has __weak implementation to allow easier testing. However, plat_set_protmem_range() requires CFG_INSECURE=y since it doesn't change memory protection.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| 5a9d570a | 03-Oct-2025 |
Ox Yeh <ox.yeh@mediatek.com> |
core: fs_htree: re-init hash tree when both tag and counter are zero
Creating and update a hash tree involves several RPC commands. If a power loss occurs during the creation flow, it may result in
core: fs_htree: re-init hash tree when both tag and counter are zero
Creating and update a hash tree involves several RPC commands. If a power loss occurs during the creation flow, it may result in a hash tree with an incomplete header and a counter value of 0. If attempting to read this file subsequently leads to a TEE_ERROR_CORRUPT_OBJECT error.
Instead of returning TEE_ERROR_CORRUPT_OBJECT, continue the initialization flow to support subsequent functionality.
Link: https://github.com/OP-TEE/optee_os/issues/7512 Fixes: 50a814981d8b ("core: provide a hash tree for secure storage")
Signed-off-by: Ox Yeh <ox.yeh@mediatek.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| d0ea0f9f | 23-Apr-2025 |
Etienne Carriere <etienne.carriere@foss.st.com> |
core: fs_htree: Fix AAD length when CFG_REE_FS_HTREE_HASH_SIZE_COMPAT=y
Correct the hash size declared in AAD length declared in REE FS hash tree authentication sequence when CFG_REE_FS_HTREE_HASH_S
core: fs_htree: Fix AAD length when CFG_REE_FS_HTREE_HASH_SIZE_COMPAT=y
Correct the hash size declared in AAD length declared in REE FS hash tree authentication sequence when CFG_REE_FS_HTREE_HASH_SIZE_COMPAT is enabled in which case the hash is truncated to the size of the FEK key (TEE_FS_HTREE_FEK_SIZE).
The issue has currently no impact since REE FS hash tree authentication is based on AES-GCM but it would be of importance if, for example, one moves to an AES-CCM scheme while still enabling CFG_REE_FS_HTREE_HASH_SIZE_COMPAT (even if unlikely to happen). To prevent such issue in the future, let's declare the effectively used hash size.
Suggested-by: Jens Wiklander <jens.wiklander@linaro.org> Link: https://github.com/OP-TEE/optee_os/pull/7340/commits/087325faec7c057a638cca80f0549e9abe49f190#r2024716984 Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 89da7ffe | 31-Mar-2025 |
Anil Kumar Reddy <areddy3@marvell.com> |
core: fs_htree: Fix wrong AAD length in authenc_init()
In authenc_init(), AAD length field passed to crypto_authenc_init() does not match with the total AAd data passed via crypto_authenc_update_aad
core: fs_htree: Fix wrong AAD length in authenc_init()
In authenc_init(), AAD length field passed to crypto_authenc_init() does not match with the total AAd data passed via crypto_authenc_update_aad() for lower layer crypto computation.
To fix this issue and to support the legacy without breaking existing REE file system content, introduce a config CFG_REE_FS_HTREE_HASH_SIZE_COMPAT.
By default this config is enabled to support the legacy REE FS hash tree that uses truncated hash implementation.
Link: https://github.com/OP-TEE/optee_os/issues/7331 Signed-off-by: Anil Kumar Reddy <areddy3@marvell.com> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| fbffc8ad | 24-Jan-2025 |
Sascha Hauer <s.hauer@pengutronix.de> |
core: fail build when CFG_INSECURE=n used with unsafe RNG seed
A production build needs a proper RNG seed. Fail the build when CFG_INSECURE=n is used in conjunction with the default weak stub implem
core: fail build when CFG_INSECURE=n used with unsafe RNG seed
A production build needs a proper RNG seed. Fail the build when CFG_INSECURE=n is used in conjunction with the default weak stub implementation of plat_rng_init().
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| dc2cf47a | 16-Jan-2025 |
Etienne Carriere <etienne.carriere@foss.st.com> |
core: rpmb: get RPMB storage space allocation stats
Add rpmb_mem_stats() to get the RPMB secure storage space allocation statistics.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> A
core: rpmb: get RPMB storage space allocation stats
Add rpmb_mem_stats() to get the RPMB secure storage space allocation statistics.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b565152e | 16-Jan-2025 |
Etienne Carriere <etienne.carriere@foss.st.com> |
core: rpmb: fix mutex in directory populate
Fix mutex unlocking in rpmb_fs_dir_populate() that should protect fat_entry_dir_deinit() execution.
Fixes: 5f68d7848fe8 ("core: RPMB FS: Caching for FAT
core: rpmb: fix mutex in directory populate
Fix mutex unlocking in rpmb_fs_dir_populate() that should protect fat_entry_dir_deinit() execution.
Fixes: 5f68d7848fe8 ("core: RPMB FS: Caching for FAT FS entries") Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 96e8f740 | 09-Jan-2025 |
Etienne Carriere <etienne.carriere@foss.st.com> |
core: rpmb: handle not-implemented error code on device probing
Consider that non-secure world may report TEE_ERROR_NOT_IMPLEMENTED error code on OPTEE_RPC_CMD_RPMB_PROBE_RESET RPC command when that
core: rpmb: handle not-implemented error code on device probing
Consider that non-secure world may report TEE_ERROR_NOT_IMPLEMENTED error code on OPTEE_RPC_CMD_RPMB_PROBE_RESET RPC command when that RPC command is not supported. This is needed to support U-Boot that provides this return code, at least up to its release tag v2025.01 [1].
Without this change, OP-TEE fails to communicate with U-Boot RPMB RPC service since RPMB probe capability was merged in OP-TEE (Fixes: tag below).
Link: https://source.denx.de/u-boot/u-boot/-/blame/v2025.01/drivers/tee/optee/supplicant.c?ref_type=tags#L96 [1] Reported-by: Gavin Liu <gavin.liu@mediatek.com> Closes: https://github.com/OP-TEE/optee_os/issues/7200 Fixes: 8dfdf3927214 ("core: rpmb: probe for kernel RPMB driver") Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 04e46975 | 16-Dec-2024 |
Etienne Carriere <etienne.carriere@foss.st.com> |
tree-wide: use ROUNDUP_DIV() where applicable
Use ROUNDUP_DIV() instead of ROUNDUP(..., size) / size where applicable.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Je
tree-wide: use ROUNDUP_DIV() where applicable
Use ROUNDUP_DIV() instead of ROUNDUP(..., size) / size where applicable.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| dcb51b21 | 19-Sep-2024 |
Thomas Bourgoin <thomas.bourgoin@foss.st.com> |
core: define plat_rng_init() as a weak alias of __plat_rng_init()
Rename the function plat_rng_init() to __plat_rng_init() and define plat_rng_init() as a weak alias of __plat_rng_init(). This allow
core: define plat_rng_init() as a weak alias of __plat_rng_init()
Rename the function plat_rng_init() to __plat_rng_init() and define plat_rng_init() as a weak alias of __plat_rng_init(). This allow to use the default RNG initialization in the platform plat_rng_init() function.
Signed-off-by: Thomas Bourgoin <thomas.bourgoin@foss.st.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 8dfdf392 | 19-Jan-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: rpmb: probe for kernel RPMB driver
Three RPC functions are added to support RPMB probing and properly align RPMB frames, OPTEE_RPC_CMD_RPMB_PROBE_RESET, OPTEE_RPC_CMD_RPMB_PROBE_NEXT, and OPTE
core: rpmb: probe for kernel RPMB driver
Three RPC functions are added to support RPMB probing and properly align RPMB frames, OPTEE_RPC_CMD_RPMB_PROBE_RESET, OPTEE_RPC_CMD_RPMB_PROBE_NEXT, and OPTEE_RPC_CMD_RPMB_FRAMES.
OPTEE_RPC_CMD_RPMB_PROBE_RESET resets probing to a well known state and returns the shared memory type needed when allocating shared memory for communication with later RPMB functions.
OPTEE_RPC_CMD_RPMB_PROBE_NEXT selects the next RPMB device and returns its device information. Later calls to OPTEE_RPC_CMD_RPMB will use this selected device.
OPTEE_RPC_CMD_RPMB_FRAMES sends the raw RPMB frames to normal world for further routing to the RPMB device.
tee_rpmb_reinit() is added to allow re-initializing the RPMB FS if a boot stage has used RPMB.
Backwards compatibility is maintained by falling back to the old type of initialization if OPTEE_RPC_CMD_RPMB_PROBE_RESET returns TEE_ERROR_NOT_SUPPORTED.
Whether RPMB devices are probed by the kernel or tee-supplicant is decided by the kernel driver where the shared memory type returned by OPTEE_RPC_CMD_RPMB_PROBE_RESET plays a vital role.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| e94194d4 | 19-Jan-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: rpmb: use thread_rpc_shm_cache_alloc()
Use thread_rpc_shm_cache_alloc() to cache shared memory allocations to simplify and make the code slightly more efficient.
Signed-off-by: Jens Wiklander
core: rpmb: use thread_rpc_shm_cache_alloc()
Use thread_rpc_shm_cache_alloc() to cache shared memory allocations to simplify and make the code slightly more efficient.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 3be2f85a | 19-Jan-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: rpmb: set device ID in tee_rpmb_init()
Until now, when initializing RPMB the devices ID has been passed to tee_rpmb_init(), but there isn't any flexibility since it's always CFG_RPMB_FS_DEV_ID
core: rpmb: set device ID in tee_rpmb_init()
Until now, when initializing RPMB the devices ID has been passed to tee_rpmb_init(), but there isn't any flexibility since it's always CFG_RPMB_FS_DEV_ID passed along. So simplify the code a bit and use CFG_RPMB_FS_DEV_ID directly in tee_rpmb_init().
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 71ecb9fa | 08-Aug-2024 |
Pengguang Zhu <pengguang.zhu@amlogic.com> |
core: fix error handling in tee_svc_storage_read_head()
Prior to this all errors except TEE_ERROR_OUT_OF_MEMORY from fops->read() was reported as TEE_ERROR_CORRUPT_OBJECT leading to removal of the o
core: fix error handling in tee_svc_storage_read_head()
Prior to this all errors except TEE_ERROR_OUT_OF_MEMORY from fops->read() was reported as TEE_ERROR_CORRUPT_OBJECT leading to removal of the object. We should not treat all errors as corrupt, so remove the error code translation.
Signed-off-by: Pengguang Zhu <pengguang.zhu@amlogic.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 420f1125 | 12-Aug-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add and use service_init_crypto() macro
Add the service_init_crypto() used to initialize the internal crypto API before the rest of the registered service_init functions are called.
Signed-of
core: add and use service_init_crypto() macro
Add the service_init_crypto() used to initialize the internal crypto API before the rest of the registered service_init functions are called.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 86ee543b | 07-Mar-2024 |
Sami Tolvanen <samitolvanen@google.com> |
core: pass TEE_ATTR_RSA_OAEP_MGF_HASH to RSA-OAEP implementations
OP-TEE currently doesn't support using a different hash for MGF1 with RSA-OAEP. However, this is required for AOSP compatibility (e.
core: pass TEE_ATTR_RSA_OAEP_MGF_HASH to RSA-OAEP implementations
OP-TEE currently doesn't support using a different hash for MGF1 with RSA-OAEP. However, this is required for AOSP compatibility (e.g. in EncryptionOperationsTest.RsaOaepWithMGFDigestSuccess [1]).
Pass the MGF1 attribute to crypto implementations. Note that only libtomcrypt supports this feature at the moment, so other implementations will either fail or fall back to libtomcrypt when passed a different MGF1 hash.
Link: https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/main/security/keymint/aidl/vts/functional/KeyMintTest.cpp#5552 [1] Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 7ae15736 | 18-Jun-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: ree_fs: fix dirfile handle refcount
The counter ree_fs_dirh_refcount is used to determine when ree_fs_dirh should be free, not as a guarantee that ree_fs_dirh is still valid. This wasn't the a
core: ree_fs: fix dirfile handle refcount
The counter ree_fs_dirh_refcount is used to determine when ree_fs_dirh should be free, not as a guarantee that ree_fs_dirh is still valid. This wasn't the assumption in ree_fs_readdir_rpc(), ree_fs_closedir_rpc(), and ree_fs_opendir_rpc(). So fix that by using get_dirh() in ree_fs_readdir_rpc as needed.
Reported-by: Gavin Liu <gavin.liu@mediatek.com> Closes: https://github.com/OP-TEE/optee_os/issues/6895 Fixes: ace6039fd434 ("core: REE_FS: refcount dirfile handle") Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| 68ac62ef | 03-Apr-2024 |
Sami Tolvanen <samitolvanen@google.com> |
core: add CFG_RSA_PUB_EXPONENT_3
When generating RSA key pairs, OP-TEE currently enforces a minimum public exponent size of 65537 per NIST SP800-56B recommendations. However, AOSP KeyMint VTS (Encry
core: add CFG_RSA_PUB_EXPONENT_3
When generating RSA key pairs, OP-TEE currently enforces a minimum public exponent size of 65537 per NIST SP800-56B recommendations. However, AOSP KeyMint VTS (EncryptionOperationsTest.RsaNoPaddingSuccess [1]) requires implementations to support public exponent 3 for backwards compatibility. Add CFG_RSA_PUB_EXPONENT_3 to allow public exponents >= 3.
Link: https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/main/security/keymint/aidl/vts/functional/KeyMintTest.cpp#5258 [1] Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 59fea683 | 16-Jan-2024 |
Igor Opaniuk <igor.opaniuk@foundries.io> |
core: pta: drop benchmark
Drop Benchmark PTA as current implementation is non-function and obsolete, and it's not supported anymore.
Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: E
core: pta: drop benchmark
Drop Benchmark PTA as current implementation is non-function and obsolete, and it's not supported anymore.
Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com> Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
show more ...
|
| 239fae35 | 08-Jan-2024 |
Clement Faure <clement.faure@nxp.com> |
core: tee: initialize dirfile|tadb_entry objects
Coverity reports many errors where dirfile_entry{} and tadb_entry{} objects are used un-initialized. Resolve these errors by setting these objects to
core: tee: initialize dirfile|tadb_entry objects
Coverity reports many errors where dirfile_entry{} and tadb_entry{} objects are used un-initialized. Resolve these errors by setting these objects to zero on declaration.
Signed-off-by: Clement Faure <clement.faure@nxp.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 2cc2a44c | 05-Jan-2024 |
Clement Faure <clement.faure@nxp.com> |
core: check if binary to bignum conversion succeed
Check return value of crypto_bignum_bin2bn().
Signed-off-by: Clement Faure <clement.faure@nxp.com> Reviewed-by: Jerome Forissier <jerome.forissier
core: check if binary to bignum conversion succeed
Check return value of crypto_bignum_bin2bn().
Signed-off-by: Clement Faure <clement.faure@nxp.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 5ca2c365 | 10-Jan-2024 |
Clement Faure <clement.faure@nxp.com> |
core: remove unnecessary includes
Remove unnecessary includes.
Signed-off-by: Clement Faure <clement.faure@nxp.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander
core: remove unnecessary includes
Remove unnecessary includes.
Signed-off-by: Clement Faure <clement.faure@nxp.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| e92de4ca | 06-Dec-2023 |
Jerome Forissier <jerome.forissier@linaro.org> |
core: rpmb: cleanup useless write_counter in struct rpmb_fat_entry
The write_counter field of the rpmb_fat_entry struct is set from the RPMB device but never used. Rename it to 'unused' and cleanup
core: rpmb: cleanup useless write_counter in struct rpmb_fat_entry
The write_counter field of the rpmb_fat_entry struct is set from the RPMB device but never used. Rename it to 'unused' and cleanup the associated code.
Tested on QEMUv8 with:
$ make CFG_RPMB_FS=y CFG_RPMB_WRITE_KEY=y CFG_RPMB_TESKEY=y check
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com> Tested-by: Etienne Carriere <etienne.carriere@foss.st.com> (stm32mp157c-ev1 w/ RPMB)
show more ...
|
| 0f50ba5a | 28-Nov-2023 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: fix objectUsage handling for persistent objects
Before this patch was the object usage field stored in the non-persistent part of an object handle, regardless of whether the storage object was
core: fix objectUsage handling for persistent objects
Before this patch was the object usage field stored in the non-persistent part of an object handle, regardless of whether the storage object was persistent. This prevents updates to this field from being restored the next time the persistent object is opened. Updates to the field are also not replicated to eventual other open handles for the object. Fix this by storing the "usage" bits in a new obj_info_usage field in struct tee_pobj for persistent objects. Updates to the field are also written into secure storage to preserve the content the next time the object is opened.
Fixes: b01047730e77 ("Open-source the TEE Core") Closes: https://github.com/OP-TEE/optee_os/issues/6495 Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|