eal/linux: clear asan after allocation and before prefaulting

Message ID 20240723083419.12435-1-amichon@kalrayinc.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series eal/linux: clear asan after allocation and before prefaulting |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing pending Testing pending
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Alex Michon July 23, 2024, 8:34 a.m. UTC
Prefaulting may generate asan error.

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

Patch

diff --git a/.mailmap b/.mailmap
index 3f3f0442e5..b1655a4080 100644
--- a/.mailmap
+++ b/.mailmap
@@ -60,6 +60,7 @@  Alexey Kardashevskiy <aik@ozlabs.ru>
 Alex Kiselev <alex@bisonrouter.com> <alex@therouter.net>
 Alex Marginean <alexandru.marginean@nxp.com>
 Alex Markuze <alex@weka.io>
+Alex Michon <amichon@kalrayinc.com>
 Alex Porosanu <alexandru.porosanu@nxp.com>
 Alex Rosenbaum <alexr@nvidia.com> <alexr@mellanox.com>
 Alex Vesker <valex@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.