aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/adj
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2020-01-30 09:11:18 -0800
committerNeale Ranns <nranns@cisco.com>2020-02-03 10:45:37 +0000
commit3d5f6229bccf77fcf7e0e17ab4f1b361fedd1b2b (patch)
tree4a9c6352c07fd6bcf3433208e579388f774e3c02 /src/vnet/adj
parent48ac1c2b2e973814d0ea991dddc9602c406acb10 (diff)
fib: refresh adj pointer after fib_walk_sync due to possible realloc
fib_walk_sync may call adj_alloc which may cause adj_pool to expand. When that happens, any previous frame which still use the old adj pointer needs to refresh. Failure to do so may access or update to the old adj memory unintentionally and crash mysteriously. Type: fix Ticket: VPPSUPP-54 Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: I173dec4c5ce81c6e26c4fe011b894a7345901b24
Diffstat (limited to 'src/vnet/adj')
-rw-r--r--src/vnet/adj/adj_nbr.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/vnet/adj/adj_nbr.c b/src/vnet/adj/adj_nbr.c
index 75313267ea1..7acdccc72b0 100644
--- a/src/vnet/adj/adj_nbr.c
+++ b/src/vnet/adj/adj_nbr.c
@@ -452,6 +452,12 @@ adj_nbr_update_rewrite_internal (ip_adjacency_t *adj,
};
fib_walk_sync(FIB_NODE_TYPE_ADJ, walk_ai, &bw_ctx);
+ /*
+ * fib_walk_sync may allocate a new adjacency and potentially cuase a
+ * realloc for adj_pool. When that happens, adj pointer is no longer
+ * valid here. We refresh the adj pointer accordingly.
+ */
+ adj = adj_get (ai);
}
/*