From f7e5cd952b3ea70ef9fec5eac5042b614ff002b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=AD=90=E6=80=A1?= Date: Tue, 25 Mar 2025 07:24:00 +0000 Subject: [PATCH 1/3] =?UTF-8?q?HalSecureContextFree=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=20=E5=85=A5=E5=8F=82secure?= =?UTF-8?q?Context=E7=9A=84=E5=9C=B0=E5=9D=80=E8=8C=83=E5=9B=B4=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= 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..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 @@ -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 511e2b430dc7c56a5a8bc14775a0f687f60ae0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=AD=90=E6=80=A1?= Date: Tue, 25 Mar 2025 07:24:57 +0000 Subject: [PATCH 2/3] =?UTF-8?q?HalSecureContextFree=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=20=E5=85=A5=E5=8F=82secure?= =?UTF-8?q?Context=E7=9A=84=E5=9C=B0=E5=9D=80=E8=8C=83=E5=9B=B4=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= 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..78e2267d 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; +} \ No newline at end of file -- Gitee From 66e62882fb24d07064cb6a73f7fd461f47e8b0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=AD=90=E6=80=A1?= Date: Tue, 25 Mar 2025 07:25:42 +0000 Subject: [PATCH 3/3] =?UTF-8?q?HalSecureContextFree=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=20=E5=85=A5=E5=8F=82secure?= =?UTF-8?q?Context=E7=9A=84=E5=9C=B0=E5=9D=80=E8=8C=83=E5=9B=B4=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= 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