misc: asan: do not poison memory after munmap() 39/26639/2
authorBenoît Ganne <bganne@cisco.com>
Wed, 22 Apr 2020 07:02:48 +0000 (09:02 +0200)
committerDave Barach <openvpp@barachs.net>
Wed, 22 Apr 2020 13:03:08 +0000 (13:03 +0000)
It is a bad idea to poison memory after munmap because the address space
can be reused (eg. for global data of dlopen()ed object) and ASan model
allows access by default.
Moreover, access to a stale address space will fault.

Type: fix

Change-Id: I356de422f255447d9d50a3a71fb0c2eaa790d731
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/plugins/perfmon/perfmon_periodic.c
src/vlibmemory/vlib_api_cli.c
src/vppinfra/mem.h

index 8498419..37d669b 100644 (file)
@@ -248,8 +248,6 @@ disable_events (perfmon_main_t * pm)
          if (munmap (pm->perf_event_pages[i][my_thread_index],
                      pm->page_size) < 0)
            clib_unix_warning ("munmap");
-         CLIB_MEM_POISON (pm->perf_event_pages[i][my_thread_index],
-                          pm->page_size);
          pm->perf_event_pages[i][my_thread_index] = 0;
        }
 
index c57f333..5c9762e 100755 (executable)
@@ -456,7 +456,6 @@ 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)
@@ -507,7 +506,6 @@ 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;
@@ -539,7 +537,6 @@ 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;
@@ -563,7 +560,6 @@ 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;
@@ -666,7 +662,6 @@ 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;
 }
index f254601..06694cc 100644 (file)
@@ -338,7 +338,6 @@ always_inline void
 clib_mem_vm_free (void *addr, uword size)
 {
   munmap (addr, size);
-  CLIB_MEM_POISON (addr, size);
 }
 
 always_inline void *