[PATCH] eal/linux: clear asan after allocation and before prefaulting

Alex Michon amichon at kalrayinc.com
Tue Jul 23 10:34:19 CEST 2024


Prefaulting may generate asan error.

Signed-off-by: Alex Michon <amichon at kalrayinc.com>
---
 .mailmap                     | 1 +
 lib/eal/linux/eal_memalloc.c | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/.mailmap b/.mailmap
index 3f3f0442e5..b1655a4080 100644
--- a/.mailmap
+++ b/.mailmap
@@ -60,6 +60,7 @@ Alexey Kardashevskiy <aik at ozlabs.ru>
 Alex Kiselev <alex at bisonrouter.com> <alex at therouter.net>
 Alex Marginean <alexandru.marginean at nxp.com>
 Alex Markuze <alex at weka.io>
+Alex Michon <amichon at kalrayinc.com>
 Alex Porosanu <alexandru.porosanu at nxp.com>
 Alex Rosenbaum <alexr at nvidia.com> <alexr at mellanox.com>
 Alex Vesker <valex at nvidia.com>
diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c
index e354efc95d..b9c631ea88 100644
--- a/lib/eal/linux/eal_memalloc.c
+++ b/lib/eal/linux/eal_memalloc.c
@@ -38,6 +38,8 @@
 #include "eal_memcfg.h"
 #include "eal_private.h"
 
+#include "malloc_elem.h"
+
 const int anonymous_hugepages_supported =
 #ifdef MAP_HUGE_SHIFT
 		1;
@@ -636,6 +638,9 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 		goto mapped;
 	}
 
+	/* Ensure the prefault doesn't trigger ASAN errors */
+	asan_set_zone(addr, alloc_sz, 0);
+
 	/* we need to trigger a write to the page to enforce page fault and
 	 * ensure that page is accessible to us, but we can't overwrite value
 	 * that is already there, so read the old value, and write itback.
-- 
2.17.1







More information about the dev mailing list