| #
b2f0c846 |
| 17-Sep-2025 |
Ox Yeh <ox.yeh@mediatek.com> |
core: ree_fs: initialize ta_ver.db when its size is zero
Creating and writing db_hdr involves several RPC commands. If a power loss occurs during the creation flow, it may result in a db file with a
core: ree_fs: initialize ta_ver.db when its size is zero
Creating and writing db_hdr involves several RPC commands. If a power loss occurs during the creation flow, it may result in a db file with an empty db_hdr. Attempting to read this file subsequently leads to a TEE_ERROR_BAD_STATE error.
Instead of returning TEE_ERROR_BAD_STATE, continue the db_hdr initialization flow to support subsequent functionality.
Link: https://github.com/OP-TEE/optee_os/issues/7513 Fixes: 183398139c9c ("core: enable rollback protection for REE-FS TAs")
Signed-off-by: Ox Yeh <ox.yeh@mediatek.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
41a624da |
| 23-Jun-2025 |
Gavin Liu <gavin.liu@mediatek.com> |
core: ree_fs: initialize ta_ver.db in one operation
Combined the object creation and data writing operations into a single step to enhance reliability. This change addresses the situation where, if
core: ree_fs: initialize ta_ver.db in one operation
Combined the object creation and data writing operations into a single step to enhance reliability. This change addresses the situation where, if object creation occurs but the data writing fails, an empty object would be left behind, leading to potential issues during the next boot.
Link: https://github.com/OP-TEE/optee_os/issues/7438 Fixes: 183398139c9c ("core: enable rollback protection for REE-FS TAs") Signed-off-by: Gavin Liu <gavin.liu@mediatek.com> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
2f2f69df |
| 13-Sep-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: mm: replace MEM_AREA_TA_RAM
Replace MEM_AREA_TA_RAM with MEM_AREA_SEC_RAM_OVERALL.
All read/write secure memory is covered by MEM_AREA_SEC_RAM_OVERALL, sometimes using an aliased map. But sec
core: mm: replace MEM_AREA_TA_RAM
Replace MEM_AREA_TA_RAM with MEM_AREA_SEC_RAM_OVERALL.
All read/write secure memory is covered by MEM_AREA_SEC_RAM_OVERALL, sometimes using an aliased map. But secure read-only or execute core memory is not covered as that would defeat the purpose of CFG_CORE_RWDATA_NOEXEC.
Since the partition TA memory isn't accessed via MEM_AREA_TA_RAM any longer, don't map it using the partition specific map.
This is needed later where unification of OP-TEE core and physical TA memory is possible.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| #
de19cacb |
| 08-May-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: replace tee_mm_sec_ddr with phys_mem functions
Replace the tee_mm_sec_ddr mm pool with the phys_mem functions. This doesn't change the behaviour.
Signed-off-by: Jens Wiklander <jens.wiklander
core: replace tee_mm_sec_ddr with phys_mem functions
Replace the tee_mm_sec_ddr mm pool with the phys_mem functions. This doesn't change the behaviour.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-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 ...
|
| #
ef44161f |
| 25-Aug-2023 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: update ts_store API with user space buffer
Updates the read() function pointer in struct ts_store_ops to take an user space buffer in addition to the previous core buffer. Core buffers are nor
core: update ts_store API with user space buffer
Updates the read() function pointer in struct ts_store_ops to take an user space buffer in addition to the previous core buffer. Core buffers are normal secure memory while user space buffers should only be accessed using the user_access.h functions.
The different TA storage implementations are updated accordingly.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| #
b2284b11 |
| 17-Jul-2023 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: update FS storage API with user space buffer
Updates the create(), read(), and write() function pointers in struct ts_store_ops to take a user space buffer in addition to the previous core buf
core: update FS storage API with user space buffer
Updates the create(), read(), and write() function pointers in struct ts_store_ops to take a user space buffer in addition to the previous core buffer. Core buffers are normal secure memory while user space buffers should only be accessed using the user_access.h functions.
The different FS storage implementations are updated accordingly.
Note that the RPMB FS storage implementation resorts to using enter_user_access() and exit_user_access() due to internal complexities.
Fixes: 4e154320e47c ("core: Apply finer-grained PAN") Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| #
9eabc2b4 |
| 03-Apr-2023 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: fix loading of encrypted TA
The total size of headers for TAs signed with a subkey varies, take that into account when sanity checking the img_size field of the signed header.
Fixes: 19b1ce2b
core: fix loading of encrypted TA
The total size of headers for TAs signed with a subkey varies, take that into account when sanity checking the img_size field of the signed header.
Fixes: 19b1ce2b2b2b ("core: ree_fs: check ta size before use") Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_armv8a)
show more ...
|
| #
2d7720f1 |
| 11-Nov-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add fault mitigations in ree_fs_ta_open()
Adds and enables fault mitigation in ree_fs_ta_open() to check the signature of the TA before returning success.
Acked-by: Jerome Forissier <jerome.f
core: add fault mitigations in ree_fs_ta_open()
Adds and enables fault mitigation in ree_fs_ta_open() to check the signature of the TA before returning success.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
c8219657 |
| 01-Apr-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add fault mitigations in buf_ta_open()
Adds and enables fault mitigation in buf_ta_open() to check both the signature of the TA and then also the hash of the TA before returning success.
Acke
core: add fault mitigations in buf_ta_open()
Adds and enables fault mitigation in buf_ta_open() to check both the signature of the TA and then also the hash of the TA before returning success.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
827c9002 |
| 10-Nov-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: ree_fs: copy in encrypted TA header only once
In ree_fs_ta_open() when an encrypted TA is loaded there is an encrypted TA sub-header. Prior to this patch it was copied in from non-secure share
core: ree_fs: copy in encrypted TA header only once
In ree_fs_ta_open() when an encrypted TA is loaded there is an encrypted TA sub-header. Prior to this patch it was copied in from non-secure shared memory twice, first one time to read the total size of the header, and then a second time to copy in the entire header. Fix this by only copying in what wasn't copied the first time.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
19b1ce2b |
| 10-Nov-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: ree_fs: check ta size before use
Check that the total loaded size of a TA matches what is in the sign header. This prevents an eventual attacker from providing arbitrary values in the img_size
core: ree_fs: check ta size before use
Check that the total loaded size of a TA matches what is in the sign header. This prevents an eventual attacker from providing arbitrary values in the img_size field of the signed header.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Suggested-by: Asaf Modelevsky <amodele@amazon.com> Reported-by: Asaf Modelevsky <amodele@amazon.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
c34d0d91 |
| 05-Sep-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: support loading TAs signed with a subkey
Adds support to load TAs signed with subkey or a chain of subkeys. This allows delegation of TA signing without distributing the root key. TAs signed w
core: support loading TAs signed with a subkey
Adds support to load TAs signed with subkey or a chain of subkeys. This allows delegation of TA signing without distributing the root key. TAs signed with a subkey are confined to the UUID-V5 namespace of the subkey to avoid TA UUID clashes with different subkeys.
SHDR_SUBKEY is a type of header which enables chains of public keys. The public root key is used to verify the first public subkey, which then is used to verify the next public subkey and so on.
The TA is finally verified using the last subkey. All these headers are added in front of the TA binary so everything needed to verify the TA is available when it's loaded into memory.
For example: Subkey struct shdr magic: 0x4f545348 img_type: 3 (SHDR_SUBKEY) img_size: 320 bytes algo: 0x70414930 (TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256) hash_size: 32 bytes sig_size: 256 bytes hash: f573f329fe77be686ce71647909c4ea35b5e1cd7de86369bd7d9fca31f6a4d65 struct shdr_subkey uuid: f04fa996-148a-453c-b037-1dcfbad120a6 name_size: 64 subkey_version: 1 max_depth: 4 algo: 0x70414930 (TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256) attr_count: 2 next name: "mid_level_subkey" Next header at offset: 692 (0x2b4) Subkey struct shdr magic: 0x4f545348 img_type: 3 (SHDR_SUBKEY) img_size: 320 bytes algo: 0x70414930 (TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256) hash_size: 32 bytes sig_size: 256 bytes hash: 233a6dcf1a2cf69e50cde8e20c4129157da707c76fa86ce12ee31037edef02d7 struct shdr_subkey uuid: 1a5948c5-1aa0-518c-86f4-be6f6a057b16 name_size: 64 subkey_version: 1 max_depth: 3 algo: 0x70414930 (TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256) attr_count: 2 next name: "subkey1_ta" Next header at offset: 1384 (0x568) Bootstrap TA struct shdr magic: 0x4f545348 img_type: 1 (SHDR_BOOTSTRAP_TA) img_size: 84576 bytes algo: 0x70414930 (TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256) hash_size: 32 bytes sig_size: 256 bytes hash: ea31ac7dc2cc06a9dc2853cd791dd00f784b5edc062ecfa274deeb66589b4ca5 struct shdr_bootstrap_ta uuid: 5c206987-16a3-59cc-ab0f-64b9cfc9e758 ta_version: 0 TA offset: 1712 (0x6b0) bytes TA size: 84576 (0x14a60) bytes
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_virt) Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
ce20b8ec |
| 05-Sep-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: ree_fs: refactor check_update_version()
Refactors check_update_version() to support more than one version database.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etien
core: ree_fs: refactor check_update_version()
Refactors check_update_version() to support more than one version database.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
ec1aa4fa |
| 05-Sep-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add offset argument to shdr_alloc_and_copy()
Adds an offset argument to shdr_alloc_and_copy() to make it easier to copy a signed header located further into a non-secure buffer.
Reviewed-by:
core: add offset argument to shdr_alloc_and_copy()
Adds an offset argument to shdr_alloc_and_copy() to make it easier to copy a signed header located further into a non-secure buffer.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
9c4aaf67 |
| 11-Jan-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: make mobj_get_va() more secure
Adds a length parameter to allow mobj_get_va() to check that the entire va range requested is available.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.
core: make mobj_get_va() more secure
Adds a length parameter to allow mobj_get_va() to check that the entire va range requested is available.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
c2e4eb43 |
| 23-May-2021 |
Anton Rybakov <a.rybakov@omp.ru> |
core_mmu: fix phys_to_virt() to check length
phys_to_virt() function without length parameter doesn`t always have ability to find the correct mapping for requested physical address. This is because
core_mmu: fix phys_to_virt() to check length
phys_to_virt() function without length parameter doesn`t always have ability to find the correct mapping for requested physical address. This is because physical address can be mapped in the same time in different virtual regions with different length. So the first found region which contains the requested physical address possibly doesn`t have enough mapped data. This is fixed by adding the length parameter to phys_to_virt() function. Length parameter can be set to 1 if caller knows that requested (pa + len) doesn`t cross mapping granule boundary.
core_mmu_get_va() and io_pa_or_va() functions now are take length parameter too as they based on phys_to_virt() in case of MMU enabled.
Signed-off-by: Anton Rybakov <a.rybakov@omp.ru> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Tested-by: Etienne Carriere <etienne.carriere@linaro.org> (stm32mp1-157C_DK2) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx6dlsabreauto) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx6dlsabresd) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx6qpsabreauto) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx6sllevk) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx6ulevk) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx6ullevk) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx6ulzevk) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx7dsabresd) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx7ulpevk) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx8mmevk) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx8mnevk) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx8mqevk) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx8mpevk) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx8qmmek) Tested-by: Clement Faure <clement.faure@nxp.com> (imx-mx8qxpmek)
show more ...
|
| #
49a87500 |
| 21-Jun-2021 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add more overflow checks in ree_fs_ta_open()
Adds more overflow checks in ree_fs_ta_open() and also checks that the encrypted header (struct shdr_encrypted_ta) also fits in the size of the TA
core: add more overflow checks in ree_fs_ta_open()
Adds more overflow checks in ree_fs_ta_open() and also checks that the encrypted header (struct shdr_encrypted_ta) also fits in the size of the TA binary.
The latter check is needed to guard against fabricated values in struct shdr_encrypted_ta for iv_size and/or tag_size which could trick OP-TEE to read beyond the end of the buffer where the TA was loaded.
Reading beyond the end of the TA buffer would normally result in a crash or if there's a valid mappings just after just a failure to load the TA. No unchecked code will be executed, but it may result in a secure world crash.
So this commit will check that the iv_size and tag_size values can point to a valid buffer before attempting to read and thus prevent a crash.
Reviewed-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Ruchika Gupta <ruchika.gupta@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reported-by: Patrik Lantz <Patrik.Lantz@axis.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
3cc2413a |
| 11-May-2021 |
Jerome Forissier <jerome@forissier.org> |
core: allow configuration without any secure storage
Support a configuration with no secure storage (CFG_REE_FS=n and CFG_RPMB_FS=n). In such a case, user TAs will get error code TEEC_ERROR_ITEM_NOT
core: allow configuration without any secure storage
Support a configuration with no secure storage (CFG_REE_FS=n and CFG_RPMB_FS=n). In such a case, user TAs will get error code TEEC_ERROR_ITEM_NOT_FOUND when trying to access persistent objects.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| #
c34c183a |
| 29-Mar-2021 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
core: kernel: move ree_fs_ta.c to core/tee
ree_fs_ta.c is not architecture-specific code, therefore move it to core/tee.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Je
core: kernel: move ree_fs_ta.c to core/tee
ree_fs_ta.c is not architecture-specific code, therefore move it to core/tee.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|