Article View: linux.kernel.netdev
Article #12738[PATCH v2] net/mlx5e: TC, fix internal port leak when a flow is reoffloaded
From: Wentao Liang
Date: Sun, 08 Nov 2026 13:21
Date: Sun, 08 Nov 2026 13:21
53 lines
10591 bytes
10591 bytes
For a flow originating from an OVS internal port,
mlx5e_tc_add_fdb_flow() takes a reference on the internal port and stores
it in the flow's esw attribute.
If the flow cannot be offloaded because the encap route is not available
(-ENETUNREACH) on a multipath LAG setup, __mlx5e_add_fdb_flow() keeps the
flow on the unready list instead of freeing it. When
mlx5e_tc_reoffload_flows_work() retries, mlx5e_tc_add_fdb_flow() takes
another reference and overwrites the stored pointer, so the previous
reference is never dropped.
Only look up the internal port if the flow does not hold a reference
already; the reference is released together with the flow attributes.
The candidate was found by a static analysis tool we run over the tree,
which reports reference-count imbalance candidates. DeepSeek-V4.1-Flash
and GPT-6.1 Sol were then used to audit the candidate and to prepare
this fix. The leak was identified by code inspection only and was not
triggered, so there is no stack trace or error message to report. The
patch was compile-tested only and was not tested on mlx5 hardware.
Fixes: 166f431ec6be ("net/mlx5e: Add indirect tc offload of ovs internal port")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
Changes in v2:
- Fold the internal port check into the outer condition, as suggested by
Tariq Toukan, instead of re-indenting the lookup.
- Describe in the commit message how the issue was found and how it was
tested, as requested by netdev-bot.
- Drop Cc: stable@vger.kernel.org: the leak is only reachable when a flow
is retried after the encap route lookup fails with -ENETUNREACH on a
multipath LAG setup.
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 708b7987ea4c..88e620654f9f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1981,7 +1981,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
goto err_out;
}
- if (netif_is_ovs_master(parse_attr->filter_dev)) {
+ if (netif_is_ovs_master(parse_attr->filter_dev) &&
+ !esw_attr->int_port) {
struct mlx5e_tc_int_port *int_port;
if (attr->chain) {
--
2.34.1
Technical Details
Message-ID:
<20261108132100.315011-1-vulab@iscas.ac.cn>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358730-linux-kernel-netdev=dewy.ruReferences:
<20261103102855.1340650-1-vulab@iscas.ac.cn> <04665957-efb5-4632-878a-6a45fa1553f5@nvidia.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358730-linux-kernel-netdev=dewy.ru From: vulab@iscas.ac.cn (Wentao Liang) Newsgroups: linux.kernel.netdev Subject: [PATCH v2] net/mlx5e: TC, fix internal port leak when a flow is reoffloaded Date: Sun, 08 Nov 2026 13:21:00 +0000 Organization: Usenet Network Message-ID: <20261108132100.315011-1-vulab@iscas.ac.cn> References: <20261103102855.1340650-1-vulab@iscas.ac.cn> <04665957-efb5-4632-878a-6a45fa1553f5@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="129404"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:AmKdeGBJjCmvaiEG2lxeq2zajOY= sha256:gH07fipQYArcT1pL8rvvf12DFJpIBZfyJL6Ezs6JQCM= sha1:1XzSLmJ5v1C8N45Pa7aaEgZncv4= sha256:tlnKVRTVAZUbnYY2bb4d1irHUWlKKrxurDfj3m51B/0= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 012AC11357C; Sun, 8 Nov 2026 16:17:17 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BiClj9_HHMUf; Sun, 8 Nov 2026 16:17:06 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-358730-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=iscas.ac.cn X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 5ACA5113577; Sun, 8 Nov 2026 16:16:56 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 9CD9860C77D; Sun, 8 Nov 2026 13:16:55 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1794143809; b=WHr/hfT0rAlM3r3NwRU81ZLk+TXrpSeBUgUX2NzjQc91N7o1I86jizdivMNsjL9XXq1c QYiqFjfRAnbesU9g62K/v8wiFR+sfe/9Pcne3X5UdqG8IGscn4z6IAiKGBHVL+4hPFaJA QLyqVfVlqiy2xZwTjW8zoGlntdp0QxMHeTYZo0e+TcWjNuM988p1y9wurdGKGtEoCSWia vnRAYrpcPV7zQwSQyOQ7YMlg/1CHdYsinNYLP0WF4nrkvd+GoV6x4yxs0nmWbH/hwtBdi HOlpWkj8HbJW517itQoAe9fu+6lyMThwOp7PUF3WDUkjaZr1ua6+1GA6t7vDMcz9iqQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794143809; h=X-Original-To:Received:DMARC-Filter:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=wyuD9PdZZTyd8Ezh2sp77+2jgNbxGbIBu3YTZsnhh1c=; b=K0ABR0iJGvG1xmx24SJE1jFxMSyRM4DFPFtP6xqESo4GF1lF7rxfZP+b0itXBwXU3cSD V0wSs1mFn3FYf6OHpAOy2kzSx2hbAtyJwkbjUSYnoaZkuWiRWzjRjumFOOzBu91iTwDwQ 6lXq4xapweUr6n8Qty9SaKbjDiyjBmDODW63eKP1y9GINiR5KnUvEg0uZKyguFHuZijtw AXJ4INstgJv0gBvgzndkHrZf6sQP5t+vQUKHRIJDFErWw7gtQRe8ZFdHzC/WqFpD1QKu+ SWUNj6cNXp4RTJrljjuCK1w2MeE0YhrpSjga923LkpT5pAtrDUWX92u9wuuFl2IUAhQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=fail smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D52BC606A332; Sun, 8 Nov 2026 13:16:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=159.226.251.81 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794143799; b=UQ8yx9en8/+nV9THz6Zo+U9YwbNt4rtXoB3zrgi9YYZJim0YP6VXrHqvKR2Bw95zsyhY vwZ5vJF7PxKCninNpue9tjuyWqkNrqi055VfYH8B8gidvDC/1kOBJA5uk5SeMuk9YDWrG 78n0VYadcgNOiI3Udk1jc+Ufdqlo+INzvZPK40fpUyIGQwYJZWJ4Mt30h3xXCDwb/MQPw uUvyD3RBMAL+6IcvOcrORunmKgM8iyUbiZFFF4odAoNE5ERZ04HDqShiGSeZ/AFVG16kC PihvZPbtusF+NHaO6+ftZc1Kd0On9QaBF4gkZ8c4CNrNK/zzCiEQBlwLOMwq3Xo76aw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794143799; h=DMARC-Filter:Received:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Type:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-Originating-IP:X-CM-SenderInfo; bh=wyuD9PdZZTyd8Ezh2sp77+2jgNbxGbIBu3YTZsnhh1c=; b=1aZuY2IvbJR1vdylfpvpyYGf2Xpt2BzkoKwYbpnBVWBI3jzNiKmiwMOT5ae5KQR+wLE4 vmWPIfd+yrhN6s2YW/9AH+8Ukm1EX5ah9r2ExaDjDmNEkTiSHUpP4Dge4YNlkphgt9Exf IWiEiPfAArBZBirJJWuPj+27OLICgUIhTHryIGvolE48uL17QAgBT+LQHGJcBE/TtRM5L 0loI7GenuooXw9T0P3vDDGyenjBGSk6JUzbvebEFkJVDiJeOERDLqK21AaaWme6gegvEl m4v7qFfqdhT8ClMe6vlAOTxS+V16F+CqfY1ZbFqqzbgQNvPGMftdZBMDq0rTY/i2CVw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.remote-ip=159.226.251.81 X-Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A88D0606A31C; Sun, 8 Nov 2026 13:16:36 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A88D0606A31C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn X-Received: from [172.100.0.8] (unknown [36.110.52.2]) by APP-03 (Coremail) with SMTP id rQCowAAXKJkrdvBqYNOUAA--.21299S2; Sun, 08 Nov 2026 21:16:27 +0800 (CST) X-Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Wentao Liang <vulab@iscas.ac.cn> X-In-Reply-To: <04665957-efb5-4632-878a-6a45fa1553f5@nvidia.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-CM-TRANSID: rQCowAAXKJkrdvBqYNOUAA--.21299S2 X-Coremail-Antispam: 1UD129KBjvJXoW7AFyDGF48Kw43JFWfGr1fXrb_yoW8KFy5pF WUGry7KrWDXa4xAa17Ja1rZa4ruw43tFW5ua4xA39xXrn8JF17Wr9I9a45ua4UCrW8WFyj yr4qv3Z5uFWDAaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9G1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_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