misc: address sanitizer: fix vm instrumentation

Type: fix

Change-Id: Ifd61c0683c85fe7340965c225ed23e46ec88e01a
Signed-off-by: Benoît Ganne <bganne@cisco.com>
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c
index 407e923..69ac871 100644
--- a/src/vppinfra/linux/mem.c
+++ b/src/vppinfra/linux/mem.c
@@ -321,6 +321,7 @@
   a->n_pages = n_pages;
   a->addr = addr;
   a->fd = fd;
+  CLIB_MEM_UNPOISON (addr, a->size);
   goto done;
 
 error:
@@ -398,6 +399,7 @@
     return clib_error_return_unix (0, "mmap");
 
   a->addr = addr;
+  CLIB_MEM_UNPOISON (addr, a->size);
   return 0;
 }
 
diff --git a/src/vppinfra/mem.h b/src/vppinfra/mem.h
index 5492e10..c00c78a 100644
--- a/src/vppinfra/mem.h
+++ b/src/vppinfra/mem.h
@@ -363,6 +363,8 @@
   mmap_addr = mmap (0, size, PROT_READ | PROT_WRITE, flags, -1, 0);
   if (mmap_addr == (void *) -1)
     mmap_addr = 0;
+  else
+    CLIB_MEM_UNPOISON (mmap_addr, size);
 
   return mmap_addr;
 }
@@ -371,6 +373,7 @@
 clib_mem_vm_free (void *addr, uword size)
 {
   munmap (addr, size);
+  CLIB_MEM_POISON (addr, size);
 }
 
 always_inline void *
@@ -386,6 +389,8 @@
   mmap_addr = mmap (addr, size, PROT_NONE, flags, -1, 0);
   if (mmap_addr == (void *) -1)
     mmap_addr = 0;
+  else
+    CLIB_MEM_UNPOISON (mmap_addr, size);
 
   return mmap_addr;
 }
@@ -399,6 +404,8 @@
   mmap_addr = mmap (addr, size, (PROT_READ | PROT_WRITE), flags, -1, 0);
   if (mmap_addr == (void *) -1)
     mmap_addr = 0;
+  else
+    CLIB_MEM_UNPOISON (mmap_addr, size);
 
   return mmap_addr;
 }