From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 70E7748B69 for ; Fri, 21 Nov 2025 12:23:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6B0164026F; Fri, 21 Nov 2025 12:23:44 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 43336402E0 for ; Fri, 21 Nov 2025 12:23:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763724220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QA2D7+2f66zxJPBrRwnzuz3NPtPTi6Qw9OcjzG1hk8A=; b=eTLiW1D+sRzoap3NMJggPgxJjOtF6j+UDdcf3xjRLfgB7r7NmmoXVmKD13k4cTIsEDg8Pg TCodgbvniIZxCewbUNfpu3Tj0ZGmpuN9uLa81BEEMCaQXZtfqXON46oPaqCtH2JXHuDIkd rwT29bZcoprVRBmn5EGZjrs6GGyh+vs= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-478-BOC3bOmbPPK79rvaWgLfgQ-1; Fri, 21 Nov 2025 06:23:39 -0500 X-MC-Unique: BOC3bOmbPPK79rvaWgLfgQ-1 X-Mimecast-MFC-AGG-ID: BOC3bOmbPPK79rvaWgLfgQ_1763724218 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9B0241956096; Fri, 21 Nov 2025 11:23:38 +0000 (UTC) Received: from rh.redhat.com (unknown [10.42.28.165]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 42A9130044DB; Fri, 21 Nov 2025 11:23:36 +0000 (UTC) From: Kevin Traynor To: Robin Jarry Cc: Jerin Jacob , dpdk stable Subject: patch 'graph: fix updating edge with active graph' has been queued to stable release 24.11.4 Date: Fri, 21 Nov 2025 11:20:41 +0000 Message-ID: <20251121112128.485623-57-ktraynor@redhat.com> In-Reply-To: <20251121112128.485623-1-ktraynor@redhat.com> References: <20251121112128.485623-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: hUEJUw4Wxr_emDEFPo2bI1ZSpybkHxWexvMEf6f_oh0_1763724218 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 24.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/26/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/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/a7c48f74a14125412b02df15eacb2e207072542d Thanks. Kevin --- >From a7c48f74a14125412b02df15eacb2e207072542d Mon Sep 17 00:00:00 2001 From: Robin Jarry 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 Acked-by: Jerin Jacob --- 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 dff8e690a8..ac14e5ef9d 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -261,4 +261,18 @@ graph_node_fini(struct graph *graph) } +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 da48d73587..e2c4d9264c 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -293,4 +293,16 @@ 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 63db629da8..3e4793560b 100644 --- a/lib/graph/node.c +++ b/lib/graph/node.c @@ -269,9 +269,13 @@ edge_update(struct node *node, struct node *prev, rte_edge_t from, 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.51.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-11-21 11:05:11.394461707 +0000 +++ 0057-graph-fix-updating-edge-with-active-graph.patch 2025-11-21 11:05:09.535177258 +0000 @@ -1 +1 @@ -From eaa11767069f476e13000fc3fec618a40c46ab7e Mon Sep 17 00:00:00 2001 +From a7c48f74a14125412b02df15eacb2e207072542d Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit eaa11767069f476e13000fc3fec618a40c46ab7e ] + @@ -36 +37,0 @@ -Cc: stable@dpdk.org @@ -47 +48 @@ -index 61159edc72..6911ea8abe 100644 +index dff8e690a8..ac14e5ef9d 100644 @@ -50 +51 @@ -@@ -278,4 +278,18 @@ graph_node_fini(struct graph *graph) +@@ -261,4 +261,18 @@ graph_node_fini(struct graph *graph) @@ -70 +71 @@ -index 21912c0ae6..26cdc66371 100644 +index da48d73587..e2c4d9264c 100644 @@ -73 +74 @@ -@@ -300,4 +300,16 @@ int graph_node_has_edge_to_src_node(struct graph *graph); +@@ -293,4 +293,16 @@ int graph_node_has_edge_to_src_node(struct graph *graph); @@ -91 +92 @@ -index cae1c809ed..e3359fe490 100644 +index 63db629da8..3e4793560b 100644 @@ -94 +95 @@ -@@ -326,9 +326,13 @@ edge_update(struct node *node, struct node *prev, rte_edge_t from, +@@ -269,9 +269,13 @@ edge_update(struct node *node, struct node *prev, rte_edge_t from,