diff options
author | Benoît Ganne <bganne@cisco.com> | 2019-04-15 15:28:21 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2019-11-27 10:50:28 +0000 |
commit | 9fb6d40eb3d4a2da8f45187de773498b784596e6 (patch) | |
tree | e785ebfbe73b847146debb2dae4a4304c51aa9cf /src/vlibmemory/memory_shared.c | |
parent | 99fbf0574f099f09b7b46dcabe5bb50d78091dce (diff) |
misc: add address sanitizer heap instrumentation
Introduce AddressSanitizer support: https://github.com/google/sanitizers/
This starts with heap instrumentation. vlib_buffer, bihash and stack
instrumentation should follow.
Type: feature
Change-Id: I7f20e235b2f79db72efd0e756f22c75f717a9884
Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vlibmemory/memory_shared.c')
-rw-r--r-- | src/vlibmemory/memory_shared.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/vlibmemory/memory_shared.c b/src/vlibmemory/memory_shared.c index f44ab7c4106..6c8ec3092f1 100644 --- a/src/vlibmemory/memory_shared.c +++ b/src/vlibmemory/memory_shared.c @@ -42,7 +42,7 @@ #define DEBUG_MESSAGE_BUFFER_OVERRUN 0 -static inline void * +CLIB_NOSANITIZE_ADDR static inline void * vl_msg_api_alloc_internal (int nbytes, int pool, int may_return_null) { int i; @@ -192,6 +192,7 @@ out: #endif rv->data_len = htonl (nbytes - sizeof (msgbuf_t)); + VL_MSG_API_UNPOISON (rv->data); return (rv->data); } @@ -296,6 +297,7 @@ vl_msg_api_free (void *a) ASSERT (*overrun == 0x1badbabe); } #endif + VL_MSG_API_POISON (rv->data); return; } @@ -331,6 +333,7 @@ vl_msg_api_free_nolock (void *a) if (rv->q) { rv->q = 0; + VL_MSG_API_POISON (rv->data); return; } @@ -753,10 +756,10 @@ void vl_msg_api_send_shmem (svm_queue_t * q, u8 * elem) { api_main_t *am = &api_main; - uword *trace = (uword *) elem; + void *msg = (void *) *(uword *) elem; if (am->tx_trace && am->tx_trace->enabled) - vl_msg_api_trace (am, am->tx_trace, (void *) trace[0]); + vl_msg_api_trace (am, am->tx_trace, msg); /* * Announce a probable binary API client bug: @@ -786,6 +789,7 @@ vl_msg_api_send_shmem (svm_queue_t * q, u8 * elem) q); } } + VL_MSG_API_POISON (msg); (void) svm_queue_add (q, elem, 0 /* nowait */ ); } @@ -799,12 +803,13 @@ void vl_msg_api_send_shmem_nolock (svm_queue_t * q, u8 * elem) { api_main_t *am = &api_main; - uword *trace = (uword *) elem; + void *msg = (void *) *(uword *) elem; if (am->tx_trace && am->tx_trace->enabled) - vl_msg_api_trace (am, am->tx_trace, (void *) trace[0]); + vl_msg_api_trace (am, am->tx_trace, msg); (void) svm_queue_add_nolock (q, elem); + VL_MSG_API_POISON (msg); } /* |