patch 'graph: fix updating edge with active graph' has been queued to stable release 23.11.6
Shani Peretz
shperetz at nvidia.com
Thu Dec 25 10:18:23 CET 2025
Hi,
FYI, your patch has been queued to stable release 23.11.6
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/30/25. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/shanipr/dpdk-stable
This queued commit can be viewed at:
https://github.com/shanipr/dpdk-stable/commit/3c45ee5556f6bc93422296601fd23e93c360238d
Thanks.
Shani
---
>From 3c45ee5556f6bc93422296601fd23e93c360238d Mon Sep 17 00:00:00 2001
From: Robin Jarry <rjarry at redhat.com>
Date: Fri, 31 Oct 2025 23:13:04 +0100
Subject: [PATCH] graph: fix updating edge with active graph
[ upstream commit eaa11767069f476e13000fc3fec618a40c46ab7e ]
After creating at least one graph and calling rte_node_edge_update to
add a new edge on a node which is in use in the graph, the node memory
is reallocated but the active graph still has a pointer to the freed
memory.
When destroying the graph, it causes a use-after-free error detected by
libasan:
ERROR: AddressSanitizer: heap-use-after-free
READ of size 8 at 0x7c4baa5e4da8 thread T0
#0 0x0000005ad224 in graph_node_fini lib/graph/graph.c:256
#1 0x0000005ae657 in rte_graph_destroy lib/graph/graph.c:504
...
freed by thread T0 here:
#0 0x7f1bac4e5e4b in realloc.part.0 (/lib64/libasan.so.8+0xe5e4b)
#1 0x0000005ab6d7 in edge_update lib/graph/node.c:271
#2 0x0000005abb1b in rte_node_edge_update lib/graph/node.c:339
...
previously allocated by thread T0 here:
#0 0x7f1bac4e5e4b in realloc.part.0 (/lib64/libasan.so.8+0xe5e4b)
#1 0x0000005ab6d7 in edge_update lib/graph/node.c:271
#2 0x0000005abb1b in rte_node_edge_update lib/graph/node.c:339
...
Use malloc+memcpy and add an internal function to replace all references
to the old node memory before freeing it.
Fixes: c59dac2ca14a ("graph: implement node operations")
Signed-off-by: Robin Jarry <rjarry at redhat.com>
Acked-by: Jerin Jacob <jerinj at marvell.com>
---
lib/graph/graph.c | 14 ++++++++++++++
lib/graph/graph_private.h | 12 ++++++++++++
lib/graph/node.c | 6 +++++-
3 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/lib/graph/graph.c b/lib/graph/graph.c
index 8ea2109645..c101a37cd5 100644
--- a/lib/graph/graph.c
+++ b/lib/graph/graph.c
@@ -260,6 +260,20 @@ graph_node_fini(struct graph *graph)
graph_node->node->name));
}
+void
+graph_node_replace_all(struct node *old, struct node *new)
+{
+ struct graph_node *graph_node;
+ struct graph *graph;
+
+ STAILQ_FOREACH(graph, &graph_list, next) {
+ STAILQ_FOREACH(graph_node, &graph->node_list, next) {
+ if (graph_node->node == old)
+ graph_node->node = new;
+ }
+ }
+}
+
static struct rte_graph *
graph_mem_fixup_node_ctx(struct rte_graph *graph)
{
diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h
index d0ef13b205..f10f894bbe 100644
--- a/lib/graph/graph_private.h
+++ b/lib/graph/graph_private.h
@@ -289,6 +289,18 @@ int graph_node_has_edge_to_src_node(struct graph *graph);
*/
int graph_node_has_loop_edge(struct graph *graph);
+/**
+ * @internal
+ *
+ * Replace all pointers of a given node with another one in all active graphs.
+ *
+ * @param old
+ * Node pointer to replace in all graphs.
+ * @param new
+ * Updated pointer.
+ */
+void graph_node_replace_all(struct node *old, struct node *new);
+
/**
* @internal
*
diff --git a/lib/graph/node.c b/lib/graph/node.c
index 99a9622779..d492e30507 100644
--- a/lib/graph/node.c
+++ b/lib/graph/node.c
@@ -235,11 +235,15 @@ edge_update(struct node *node, struct node *prev, rte_edge_t from,
need_realloc = max_edges > node->nb_edges;
if (need_realloc) {
sz = sizeof(struct node) + (max_edges * RTE_NODE_NAMESIZE);
- new_node = realloc(node, sz);
+ new_node = malloc(sz);
if (new_node == NULL) {
rte_errno = ENOMEM;
goto restore;
} else {
+ sz = sizeof(*node) + (node->nb_edges * RTE_NODE_NAMESIZE);
+ memcpy(new_node, node, sz);
+ graph_node_replace_all(node, new_node);
+ free(node);
node = new_node;
}
}
--
2.43.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2025-12-25 11:16:39.473774620 +0200
+++ 0062-graph-fix-updating-edge-with-active-graph.patch 2025-12-25 11:16:36.020952000 +0200
@@ -1 +1 @@
-From eaa11767069f476e13000fc3fec618a40c46ab7e Mon Sep 17 00:00:00 2001
+From 3c45ee5556f6bc93422296601fd23e93c360238d Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit eaa11767069f476e13000fc3fec618a40c46ab7e ]
+
@@ -36 +37,0 @@
-Cc: stable at dpdk.org
@@ -47 +48 @@
-index 61159edc72..6911ea8abe 100644
+index 8ea2109645..c101a37cd5 100644
@@ -50 +51 @@
-@@ -277,6 +277,20 @@ graph_node_fini(struct graph *graph)
+@@ -260,6 +260,20 @@ graph_node_fini(struct graph *graph)
@@ -72 +73 @@
-index 21912c0ae6..26cdc66371 100644
+index d0ef13b205..f10f894bbe 100644
@@ -75 +76 @@
-@@ -299,6 +299,18 @@ int graph_node_has_edge_to_src_node(struct graph *graph);
+@@ -289,6 +289,18 @@ int graph_node_has_edge_to_src_node(struct graph *graph);
@@ -95 +96 @@
-index cae1c809ed..e3359fe490 100644
+index 99a9622779..d492e30507 100644
@@ -98 +99 @@
-@@ -325,11 +325,15 @@ edge_update(struct node *node, struct node *prev, rte_edge_t from,
+@@ -235,11 +235,15 @@ edge_update(struct node *node, struct node *prev, rte_edge_t from,
More information about the stable
mailing list