From 1cc26f1ca4d407047a5e2ca046c400580dfde3e5 Mon Sep 17 00:00:00 2001 From: wangmingrong1 Date: Tue, 14 Jan 2025 21:09:44 +0800 Subject: [PATCH] mm: mm_malloc_size Switching using kasan_bypass_save Because it will be called in mm_lock and outside mm_unlock, it needs to keep the same state as before closing. Signed-off-by: wangmingrong1 --- mm/mm_heap/mm_malloc_size.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mm/mm_heap/mm_malloc_size.c b/mm/mm_heap/mm_malloc_size.c index bb8ed7dcf510f..0c463b3b99733 100644 --- a/mm/mm_heap/mm_malloc_size.c +++ b/mm/mm_heap/mm_malloc_size.c @@ -29,6 +29,7 @@ #include #include +#include #include #include "mm_heap/mm.h" @@ -40,10 +41,14 @@ size_t mm_malloc_size(FAR struct mm_heap_s *heap, FAR void *mem) { FAR struct mm_freenode_s *node; + size_t size; + bool mte; + + mte = kasan_bypass_save(); #ifdef CONFIG_MM_HEAP_MEMPOOL if (heap->mm_mpool) { - ssize_t size = mempool_multiple_alloc_size(heap->mm_mpool, mem); + size = mempool_multiple_alloc_size(heap->mm_mpool, mem); if (size >= 0) { return size; @@ -66,5 +71,8 @@ size_t mm_malloc_size(FAR struct mm_heap_s *heap, FAR void *mem) DEBUGASSERT(MM_NODE_IS_ALLOC(node)); - return MM_SIZEOF_NODE(node) - MM_ALLOCNODE_OVERHEAD; + size = MM_SIZEOF_NODE(node) - MM_ALLOCNODE_OVERHEAD; + + kasan_bypass_restore(mte); + return size; }