vlib epoll: protect against clib file pool expansion 50/19050/2
authorFlorin Coras <fcoras@cisco.com>
Thu, 18 Apr 2019 17:04:03 +0000 (10:04 -0700)
committerDave Wallace <dwallacelf@gmail.com>
Thu, 18 Apr 2019 18:15:24 +0000 (18:15 +0000)
Change-Id: I320e7c2fdacb3056bc448c73fec08d9e2978ee5e
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vlib/unix/input.c

index 0edc4e4..318043e 100644 (file)
@@ -248,7 +248,7 @@ linux_epoll_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
   for (e = em->epoll_events; e < em->epoll_events + n_fds_ready; e++)
     {
       u32 i = e->data.u32;
-      clib_file_t *f = fm->file_pool + i;
+      clib_file_t *f = pool_elt_at_index (fm->file_pool, i);
       clib_error_t *errors[4];
       int n_errors = 0;
 
@@ -287,6 +287,8 @@ linux_epoll_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
            {
              f->read_events++;
              errors[n_errors] = f->read_function (f);
+             /* Make sure f is valid if the file pool moves */
+             f = pool_elt_at_index (fm->file_pool, i);
              n_errors += errors[n_errors] != 0;
            }
          if (e->events & EPOLLOUT)