From 5e19ae5ab3a99c1fa4438e88d46654d03075b96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=AD=90=E6=80=A1?= Date: Tue, 4 Mar 2025 08:15:48 +0000 Subject: [PATCH 1/4] update arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 石子怡 --- arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c b/arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c index db9a4f9a..fce75b89 100644 --- a/arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c +++ b/arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c @@ -74,6 +74,16 @@ OS_CMSE_NS_ENTRY OsSecureContext *HalSecureContextAlloc(UINT32 size) OS_CMSE_NS_ENTRY VOID HalSecureContextFree(OsSecureContext *secureContext) { + if (secureContext == NULL) { + return; + } + + SecureHeapInfo heapInfo = HalGetSecureHeapInfo(); + if (secureContext < heapInfo.start || + (secureContext + sizeof(OsSecureContext)) > (heapInfo.start + heapInfo.size)) { + return; + } + UINT32 ipsr; OS_IPSR_READ(ipsr); -- Gitee From 72d5391858a7b15338aeeb4ccac7c5bb0ad7ac9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=AD=90=E6=80=A1?= Date: Tue, 4 Mar 2025 08:16:29 +0000 Subject: [PATCH 2/4] update arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 石子怡 --- arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.c b/arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.c index 7f0077e0..11f7d3ff 100644 --- a/arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.c +++ b/arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.c @@ -228,3 +228,10 @@ OS_CMSE_NS_ENTRY VOID HalSecureFree(VOID *ptr) OsSecureHeapFreeNode(node); } +OS_CMSE_NS_ENTRY SecureHeapInfo HalGetSecureHeapInfo(void) +{ + SecureHeapInfo info; + info.start = g_secureHeap; + info.size = LOSCFG_SECURE_HEAP_SIZE; + return info; +} -- Gitee From 2c2bfa8d375c49b43cbc4465f95597e32c3d9ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=AD=90=E6=80=A1?= Date: Tue, 4 Mar 2025 08:17:07 +0000 Subject: [PATCH 3/4] update arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 石子怡 --- arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.h b/arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.h index d3ee1aad..2548a6e8 100644 --- a/arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.h +++ b/arch/arm/cortex-m33/iar/TZ/secure/los_secure_heap.h @@ -40,6 +40,12 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ +typedef struct { + UINT8 *start; + UINT32 size; +} SecureHeapInfo; + +OS_CMSE_NS_ENTRY SecureHeapInfo HalGetSecureHeapInfo(void); VOID *HalSecureMalloc(UINT32 size); VOID HalSecureFree(VOID *ptr); -- Gitee From 11e3a9e0de4067788956d5ed643848be10ced30f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=AD=90=E6=80=A1?= Date: Tue, 4 Mar 2025 08:52:04 +0000 Subject: [PATCH 4/4] update arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 石子怡 --- arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c b/arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c index fce75b89..7220107b 100644 --- a/arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c +++ b/arch/arm/cortex-m33/iar/TZ/secure/los_secure_context.c @@ -79,7 +79,7 @@ OS_CMSE_NS_ENTRY VOID HalSecureContextFree(OsSecureContext *secureContext) } SecureHeapInfo heapInfo = HalGetSecureHeapInfo(); - if (secureContext < heapInfo.start || + if (secureContext < heapInfo.start || (secureContext + sizeof(OsSecureContext)) > (heapInfo.start + heapInfo.size)) { return; } -- Gitee