aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2019-12-16 15:37:28 +0100
committerDamjan Marion <dmarion@me.com>2019-12-17 17:58:47 +0000
commitb2f09146c957f87edd431e75a24f8a456d539a02 (patch)
treec2d5701a7d1c88802972845d11588e3ddeff5547 /src
parent8d27fa73f22803d518993090804724f76350cfcc (diff)
misc: address sanitizer: fix instrumentation
Type: fix Change-Id: I99e3951f8cfb7ab9d2f0a7dcee92199eab29043c Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/vlibmemory/vlib_api_cli.c8
-rw-r--r--src/vppinfra/dlmalloc.c2
-rw-r--r--src/vppinfra/mem_dlmalloc.c3
3 files changed, 12 insertions, 1 deletions
diff --git a/src/vlibmemory/vlib_api_cli.c b/src/vlibmemory/vlib_api_cli.c
index 3f8e1c9b0be..db4871179d6 100755
--- a/src/vlibmemory/vlib_api_cli.c
+++ b/src/vlibmemory/vlib_api_cli.c
@@ -442,6 +442,8 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
}
close (fd);
+ CLIB_MEM_UNPOISON (hp, file_size);
+
nitems = ntohl (hp->nitems);
if (last_index == (u32) ~ 0)
@@ -454,6 +456,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
vlib_cli_output (vm, "Range (%d, %d) outside file range (0, %d)\n",
first_index, last_index, nitems - 1);
munmap (hp, file_size);
+ CLIB_MEM_POISON (hp, file_size);
return;
}
if (hp->wrapped)
@@ -465,6 +468,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
saved_print_handlers = (void **) vec_dup (am->msg_print_handlers);
vl_msg_api_custom_dump_configure (am);
}
+
msg = (u8 *) (hp + 1);
u16 *msgid_vec = 0;
@@ -503,6 +507,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
{
vlib_cli_output (vm, "Ugh: msg id %d no trace config\n", msg_id);
munmap (hp, file_size);
+ CLIB_MEM_POISON (hp, file_size);
return;
}
msg += size;
@@ -534,6 +539,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
{
vlib_cli_output (vm, "Ugh: msg id %d no trace config\n", msg_id);
munmap (hp, file_size);
+ CLIB_MEM_POISON (hp, file_size);
vec_free (tmpbuf);
am->replay_in_progress = 0;
return;
@@ -557,6 +563,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
{
vlib_cli_output (vm, "Ugh: msg id %d no endian swap\n", msg_id);
munmap (hp, file_size);
+ CLIB_MEM_POISON (hp, file_size);
vec_free (tmpbuf);
am->replay_in_progress = 0;
return;
@@ -659,6 +666,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
}
munmap (hp, file_size);
+ CLIB_MEM_POISON (hp, file_size);
vec_free (tmpbuf);
am->replay_in_progress = 0;
}
diff --git a/src/vppinfra/dlmalloc.c b/src/vppinfra/dlmalloc.c
index 451666e4c9c..13f0dff8203 100644
--- a/src/vppinfra/dlmalloc.c
+++ b/src/vppinfra/dlmalloc.c
@@ -4139,6 +4139,7 @@ int mspace_is_heap_object (mspace msp, void *p)
return 0;
}
+CLIB_NOSANITIZE_ADDR
void *mspace_least_addr (mspace msp)
{
mstate ms = (mstate) msp;
@@ -4152,6 +4153,7 @@ void mspace_disable_expand (mspace msp)
disable_expand (ms);
}
+CLIB_NOSANITIZE_ADDR
int mspace_enable_disable_trace (mspace msp, int enable)
{
mstate ms = (mstate)msp;
diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c
index 5628e2714c7..68901a5530a 100644
--- a/src/vppinfra/mem_dlmalloc.c
+++ b/src/vppinfra/mem_dlmalloc.c
@@ -215,12 +215,13 @@ clib_mem_init (void *memory, uword memory_size)
else
heap = create_mspace (memory_size, 1 /* locked */ );
+ CLIB_MEM_POISON (mspace_least_addr (heap), mspace_footprint (heap));
+
clib_mem_set_heap (heap);
if (mheap_trace_main.lock == 0)
clib_spinlock_init (&mheap_trace_main.lock);
- CLIB_MEM_POISON (mspace_least_addr (heap), mspace_footprint (heap));
return heap;
}