kasan: add new API kasan_init_early()

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2024-01-08 15:46:50 +08:00 committed by Xiang Xiao
parent 64cbafeaa0
commit c75886b8f8
2 changed files with 24 additions and 0 deletions

View File

@ -324,6 +324,11 @@ void kasan_register(FAR void *addr, FAR size_t *size)
*size -= KASAN_REGION_SIZE(*size);
}
void kasan_init_early(void)
{
g_region_init = 0;
}
/* Exported functions called from the compiler generated code */
void __sanitizer_annotate_contiguous_container(FAR const void *beg,

View File

@ -35,6 +35,7 @@
# define kasan_poison(addr, size)
# define kasan_unpoison(addr, size)
# define kasan_register(addr, size)
# define kasan_init_early()
#endif
/****************************************************************************
@ -105,6 +106,24 @@ void kasan_unpoison(FAR const void *addr, size_t size);
void kasan_register(FAR void *addr, FAR size_t *size);
/****************************************************************************
* Name: kasan_init_early
*
* Description:
* Initialize the kasan early, setup g_region_init variable.
* This used for some platfroms clear bss late, and error use kasan before
* called kasan_register().
*
* Input Parameters:
* None.
*
* Returned Value:
* None.
*
****************************************************************************/
void kasan_init_early(void);
#endif /* CONFIG_MM_KASAN */
#undef EXTERN