From f017b81d05db903108ce99b9010eff55ba2b928b Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Tue, 22 Jun 2021 11:58:27 +0200 Subject: api: asan: use vec_set_len() so ASan can keep track of buffer len MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ASan poison/unpoison vectors based on the vector length, but _vec_len() bypass ASan annotations, contrary to vec_set_len(). Type: fix Change-Id: I5265a5adcddef1aa11c77e0c3827346b1a66c306 Signed-off-by: Benoît Ganne --- src/vlibmemory/socket_api.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index f5b3a6063f9..60ca650d92f 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -295,7 +295,7 @@ vl_socket_read_ready (clib_file_t * uf) } /* Fake smaller length teporarily, so input_buffer can be used as msg_buffer. */ - _vec_len (socket_main.input_buffer) = n; + vec_set_len (socket_main.input_buffer, n); /* * Look for bugs here. This code is tricky because @@ -340,10 +340,10 @@ vl_socket_read_ready (clib_file_t * uf) vec_validate (rp->unprocessed_input, vec_len (msg_buffer) - 1); clib_memcpy_fast (rp->unprocessed_input, msg_buffer, vec_len (msg_buffer)); - _vec_len (rp->unprocessed_input) = vec_len (msg_buffer); + vec_set_len (rp->unprocessed_input, vec_len (msg_buffer)); } /* No more full messages, restore original input_buffer length. */ - _vec_len (socket_main.input_buffer) = save_input_buffer_length; + vec_set_len (socket_main.input_buffer, save_input_buffer_length); return 0; } @@ -353,7 +353,7 @@ vl_socket_read_ready (clib_file_t * uf) * so we can overwrite its length to what single message has. */ data_for_process = (u8 *) vec_dup (msg_buffer); - _vec_len (data_for_process) = msgbuf_len; + vec_set_len (data_for_process, msgbuf_len); /* Everything is ready to signal the SOCKET_READ_EVENT. */ pool_get (socket_main.process_args, a); a->reg_index = reg_index; @@ -367,12 +367,12 @@ vl_socket_read_ready (clib_file_t * uf) vec_delete (msg_buffer, msgbuf_len, 0); else /* We are done with msg_buffer. */ - _vec_len (msg_buffer) = 0; + vec_set_len (msg_buffer, 0); } while (vec_len (msg_buffer) > 0); /* Restore input_buffer, it could have been msg_buffer. */ - _vec_len (socket_main.input_buffer) = save_input_buffer_length; + vec_set_len (socket_main.input_buffer, save_input_buffer_length); return 0; } -- cgit 1.2.3-korg