mm/heap: add coloration after free to detect use after free issue

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1
2023-09-05 13:44:14 +08:00
committed by Alan Carvalho de Assis
parent a7d0b6c120
commit 36e3d32740
3 changed files with 20 additions and 0 deletions
+8
View File
@@ -273,6 +273,10 @@ retry:
}
}
#ifdef CONFIG_MM_FILL_ALLOCATIONS
memset(blk, 0xaa, pool->blocksize);
#endif
#if CONFIG_MM_BACKTRACE >= 0
mempool_add_backtrace(pool, (FAR struct mempool_backtrace_s *)
((FAR char *)blk + pool->blocksize));
@@ -312,6 +316,10 @@ void mempool_free(FAR struct mempool_s *pool, FAR void *blk)
pool->nalloc--;
#endif
#ifdef CONFIG_MM_FILL_ALLOCATIONS
memset(blk, 0x55, pool->blocksize);
#endif
if (pool->interruptsize > blocksize)
{
if ((FAR char *)blk >= pool->ibase &&