mm: add kasan_unregister implementaion
In mm_uninitialize should unregister kasan Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
1771d233c9
commit
5ee7c563a5
@ -39,6 +39,7 @@
|
||||
# define kasan_poison(addr, size)
|
||||
# define kasan_unpoison(addr, size) addr
|
||||
# define kasan_register(addr, size)
|
||||
# define kasan_unregister(addr)
|
||||
# define kasan_init_early()
|
||||
# define kasan_reset_tag(addr) addr
|
||||
#else
|
||||
@ -126,6 +127,22 @@ FAR void *kasan_unpoison(FAR const void *addr, size_t size);
|
||||
|
||||
void kasan_register(FAR void *addr, FAR size_t *size);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: kasan_unregister
|
||||
*
|
||||
* Description:
|
||||
* Stop monitoring the memory range
|
||||
*
|
||||
* Input Parameters:
|
||||
* addr - range start address
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void kasan_unregister(FAR void *addr);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: kasan_init_early
|
||||
*
|
||||
|
@ -274,6 +274,35 @@ void kasan_register(FAR void *addr, FAR size_t *size)
|
||||
*size -= KASAN_REGION_SIZE(*size);
|
||||
}
|
||||
|
||||
void kasan_unregister(FAR void *addr)
|
||||
{
|
||||
FAR struct kasan_region_s *prev = NULL;
|
||||
FAR struct kasan_region_s *region;
|
||||
irqstate_t flags;
|
||||
|
||||
flags = spin_lock_irqsave(&g_lock);
|
||||
for (region = g_region; region != NULL; region = region->next)
|
||||
{
|
||||
if (region->begin == (uintptr_t)addr)
|
||||
{
|
||||
if (region == g_region)
|
||||
{
|
||||
g_region = region->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev->next = region->next;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
prev = region;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&g_lock, flags);
|
||||
}
|
||||
|
||||
void kasan_init_early(void)
|
||||
{
|
||||
g_region_init = 0;
|
||||
|
@ -357,10 +357,17 @@ mm_initialize_pool(FAR const char *name,
|
||||
|
||||
void mm_uninitialize(FAR struct mm_heap_s *heap)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef CONFIG_MM_HEAP_MEMPOOL
|
||||
mempool_multiple_deinit(heap->mm_mpool);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < CONFIG_MM_REGIONS; i++)
|
||||
{
|
||||
kasan_unregister(heap->mm_heapstart[i]);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
# if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
procfs_unregister_meminfo(&heap->mm_procfs);
|
||||
|
@ -1416,10 +1416,17 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
|
||||
|
||||
void mm_uninitialize(FAR struct mm_heap_s *heap)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef CONFIG_MM_HEAP_MEMPOOL
|
||||
mempool_multiple_deinit(heap->mm_mpool);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < CONFIG_MM_REGIONS; i++)
|
||||
{
|
||||
kasan_unregister(heap->mm_heapstart[i]);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
# if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
procfs_unregister_meminfo(&heap->mm_procfs);
|
||||
|
Loading…
Reference in New Issue
Block a user