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 6DFF448AEF for ; Wed, 12 Nov 2025 17:55:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 68F4D40BA6; Wed, 12 Nov 2025 17:55:28 +0100 (CET) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mails.dpdk.org (Postfix) with ESMTP id E9B7140BA6 for ; Wed, 12 Nov 2025 17:55:26 +0100 (CET) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-477632d45c9so7942655e9.2 for ; Wed, 12 Nov 2025 08:55:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762966526; x=1763571326; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bEvPMNJyOc3ZIavASpi01lIJS6MYPvHNaDZWtIBMr8E=; b=clcwVdsAkYwfxI4Y/pUnxxF6uM4Y7JmobD+LhsZA0JiPpxahPpHWho6i5U92XxgqoW Rp/iYlj0e2rpfS19gfwECjkJAiHXuTEHov6EXTfh+W5/J5oVMrckHi4KU8Mah4iYqKvy an7eKS18yUWrl+NSaqoahKg6NEWPeFSUqYWMG0GVir7sJzIzBTTcz6vWI61qgWZDsaDB Kl8BVB+F3gncqPYab6HUu7LP8eU76UwgbQyQcXtppImUwtdbdgEcqY3oY5WyeF2Jhvai x2uDbDbDPUbF0vP1MaRZBKbuwMlL4qFJnWj4Xe+locDrAiXpvGcnp8EDmF5pwd+oXRjc mpkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762966526; x=1763571326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bEvPMNJyOc3ZIavASpi01lIJS6MYPvHNaDZWtIBMr8E=; b=wZFKzhCHmD7TMTPw/UxkDb7CPi6AHecrCnk8zJDWWc7GxReKNQYeH2HUdEUbZOlLJX AytKn4dBmkVdnDGndhJxSW3wgKC36VojrwoQxRHreYmFwn6gUw/VbJfEB+ZxxMKxCYP/ EMdakkuzjJH+YxquvbzP7H4vncN51lQTkc6L9BuUFgmxt8b0OtSox4SUbIjfgxtjlDub 9YtYszDhY+29w62jCs87S7o1D0NkqUPXpXHdKCGEejemkhTwqoE0Wobd2hk/SrAuAKJQ k9SLpekPWijgaPlEExWyDTGKknIQ3Cao4QlBzeq2n5ENiYYXB7zKPraoy4uFStSu48gm wCeA== X-Forwarded-Encrypted: i=1; AJvYcCXBV4msOfMG+6bnAeQTORcD2DoU3HS/sbRYZyV0Xs1/0I8dr4LhpzyS9L+RwFP/reT0Vibql7o=@dpdk.org X-Gm-Message-State: AOJu0YxLTdNToVw1sFixsiVPOM0BZ3SwibFdUa/874+0t4xP71Uo4opF BxUEfT5D8woHReKFaB8hvRKU+VcWNUETva9isA22tq5SkDOlssJEKOpbcEtwOA== X-Gm-Gg: ASbGncv826IXJKX1bz7VlOV/b552sKHLv039pUQnL8kqgKaE7/0PWjD2zRcIEBRLQTA OULRr9nkbJqkWZh/+sNuHuv+rzabRnQcUZUlmKphAYMdl7uFE3KUl3b2CRGZWcMXCkA5Js+NAI0 lSV/tlaGvLrF/lBIIO91bE8zYwLfYLNlFegGepbAd2+9SwXNBxWed/OAMMUZjf71E72jvB8rIR0 fM85KCXHJpgI1d4bBSQtH80QAi+axkRDoY5G9XwZn5+fyycSp/slLa37mOkuzgJTjaQ5Kf/IRAL XUgfEZR/ETbOzgP5QtG/HGKRBywokbcLN7BDjV64asc18vIFiR0fH2c7o/TMY7jxcvbhuRbKScU 2lJTaZ2/wYC7KZndWm3Z5QXjyx08Sco40vPcVeTyQzKshbxcYqHAjnHR0lEs2INEbMUt4Frmm0q jzy4Q2FQ== X-Google-Smtp-Source: AGHT+IGQdMkFSy7m8xhBBaBhczEvNmMsV+1m2X9FbbbrvYR6KhFuTD83CU8cBgtid77GwaytQBn6yA== X-Received: by 2002:a05:600c:4744:b0:471:1435:b0ea with SMTP id 5b1f17b1804b1-4778708e26cmr29829845e9.24.1762966526426; Wed, 12 Nov 2025 08:55:26 -0800 (PST) Received: from localhost ([2a01:4b00:d036:ae00:a397:14bc:5982:5745]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-47787e58501sm45086125e9.10.2025.11.12.08.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Nov 2025 08:55:25 -0800 (PST) From: luca.boccassi@gmail.com To: Robin Jarry Cc: Jerin Jacob , dpdk stable Subject: patch 'graph: fix updating edge with active graph' has been queued to stable release 22.11.11 Date: Wed, 12 Nov 2025 16:52:57 +0000 Message-ID: <20251112165308.1618107-43-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251112165308.1618107-1-luca.boccassi@gmail.com> References: <20251027162001.3710450-79-luca.boccassi@gmail.com> <20251112165308.1618107-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 22.11.11 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/14/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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/e691ab105205f25e378c855fb4a39f8cbe8b776a Thanks. Luca Boccassi --- >From e691ab105205f25e378c855fb4a39f8cbe8b776a 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 9027e62a26..03c0ce7369 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -253,6 +253,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 f9a85c8926..391b3b66c3 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -219,6 +219,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 149414dcd9..725031d9f2 100644 --- a/lib/graph/node.c +++ b/lib/graph/node.c @@ -258,11 +258,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.47.3 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-11-12 16:20:42.619818706 +0000 +++ 0043-graph-fix-updating-edge-with-active-graph.patch 2025-11-12 16:20:41.003718817 +0000 @@ -1 +1 @@ -From eaa11767069f476e13000fc3fec618a40c46ab7e Mon Sep 17 00:00:00 2001 +From e691ab105205f25e378c855fb4a39f8cbe8b776a 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 9027e62a26..03c0ce7369 100644 @@ -50 +51 @@ -@@ -277,6 +277,20 @@ graph_node_fini(struct graph *graph) +@@ -253,6 +253,20 @@ graph_node_fini(struct graph *graph) @@ -72 +73 @@ -index 21912c0ae6..26cdc66371 100644 +index f9a85c8926..391b3b66c3 100644 @@ -75 +76 @@ -@@ -299,6 +299,18 @@ int graph_node_has_edge_to_src_node(struct graph *graph); +@@ -219,6 +219,18 @@ int graph_node_has_edge_to_src_node(struct graph *graph); @@ -95 +96 @@ -index cae1c809ed..e3359fe490 100644 +index 149414dcd9..725031d9f2 100644 @@ -98 +99 @@ -@@ -325,11 +325,15 @@ edge_update(struct node *node, struct node *prev, rte_edge_t from, +@@ -258,11 +258,15 @@ edge_update(struct node *node, struct node *prev, rte_edge_t from,