Article View: linux.kernel.netdev
Article #23429[PATCH net] netlabel: fix duplicate IPv4 entries in the staticlist dump
From: Linkui Xiao
Date: Fri, 27 Nov 2026 09:23
Date: Fri, 27 Nov 2026 09:23
65 lines
11130 bytes
11130 bytes
From: Linkui Xiao <xiaolinkui@kylinos.cn>
netlbl_unlabel_staticlist() keeps its dump progress in cb->args[]: the
bucket, the offset of the interface in that bucket, and the IPv4 and IPv6
offsets in that interface. It clears iter_addr4 once the whole IPv4 list
of an interface has been walked, so if the skb fills up while the IPv6
list of the same interface is being dumped, cb->args[2] is saved as zero.
The next round resumes on that interface and dumps its IPv4 entries a
second time, which shows up as duplicated lines in "netlbl_unlabel -l".
This needs an interface that carries both IPv4 and IPv6 static entries and
a configuration large enough for the dump to span more than one netlink
message, but once it does the duplication is reproducible on every dump.
Clear both address counters when an interface is started instead of when
it is finished. The skip counters still have to be cleared only after
their own list has been walked in full, otherwise the offset saved for the
interface where the previous dump stopped would also be applied to the
interfaces that follow it.
netlbl_unlabel_staticlistdef() dumps a single interface and never resets
these counters, so it is not affected.
Fixes: 866358ec331f ("netlabel: fix our progress tracking in netlbl_unlabel_staticlist()")
Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
---
net/netlabel/netlabel_unlabeled.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index d73c27b0c9d0..a5ebb8872946 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -1171,6 +1171,12 @@ static int netlbl_unlabel_staticlist(struct sk_buff *skb,
if (!iface->valid ||
iter_chain++ < skip_chain)
continue;
+ /* Restart the address counters for this interface, the
+ * skip counters stay until their own list has been
+ * walked in full.
+ */
+ iter_addr4 = 0;
+ iter_addr6 = 0;
netlbl_af4list_foreach_rcu(addr4,
&iface->addr4_list) {
if (iter_addr4++ < skip_addr4)
@@ -1186,7 +1192,6 @@ static int netlbl_unlabel_staticlist(struct sk_buff *skb,
goto unlabel_staticlist_return;
}
}
- iter_addr4 = 0;
skip_addr4 = 0;
#if IS_ENABLED(CONFIG_IPV6)
netlbl_af6list_foreach_rcu(addr6,
@@ -1204,7 +1209,6 @@ static int netlbl_unlabel_staticlist(struct sk_buff *skb,
goto unlabel_staticlist_return;
}
}
- iter_addr6 = 0;
skip_addr6 = 0;
#endif /* IPv6 */
}
--
2.25.1
Technical Details
Message-ID:
<20261127092325.3563681-2-xiaolinkui@126.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372571-linux-kernel-netdev=dewy.ruReferences:
<20261127092325.3563681-1-xiaolinkui@126.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372571-linux-kernel-netdev=dewy.ru From: xiaolinkui@126.com (Linkui Xiao) Newsgroups: linux.kernel.netdev Subject: [PATCH net] netlabel: fix duplicate IPv4 entries in the staticlist dump Date: Fri, 27 Nov 2026 17:23:25 +0800 Organization: Usenet Network Message-ID: <20261127092325.3563681-2-xiaolinkui@126.com> References: <20261127092325.3563681-1-xiaolinkui@126.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="693853"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:5PIVEmZltNI/xJDyqjSnM8ICjug= sha256:tFJc1er8eUJMtRgXaXXgqKuyYPmJHMQ/z1717zhmP98= sha1:FIaGNGmQJyrqlwky9Uwn6byvu2g= sha256:6r2NMJlTq6iz24RAzD9GiXZtBuwSU6BO7hNsRBqaUjc= 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 C008E125F39; Fri, 27 Nov 2026 12:24:55 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.148 X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, 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, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=126.com 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 Yl2iTIMyuQlS; Fri, 27 Nov 2026 12:24:53 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-372571-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=126.com X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id CAAC5125F36; Fri, 27 Nov 2026 12:24:44 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 4E5ED37198; Fri, 27 Nov 2026 09:24:30 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795771466; b=PAVgllDS9jG2Ut7OXJeAqnldGyhiyhqdNvdzPSh6FELI6KU8FG4xz8uODdUJdXuYfk4p OY5o+vEvuiO3lfyLqQZ4rw3fPE8vwIArauX18ARjEKOtM77Vh8Kn1Pt7sXoZ/dwTCrvG5 NF2juo8Kpxe1X1MHm1ynRg2OL78MyDf2ADaKB8I9jJB4A/QLzBUxiCJGTB83DY/wRMrAl 6PaYzupo2dMObRTI3x2tRmEcREtkEvZIcXRlMmvvg/a4IUKkzYbnhvA1Fa9IsxYbJeDKM fUJBejoZsbTCQYu3ysgMy1oaaLZ5MYL20Kcv9aMmG+lSu0nBo+x5RwCNVjrQsTlmMXg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795771466; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=mB51IxuF3LEr3pFiFZdoQIrJE8RPv845/UwJgfZGhcw=; b=RBYcG7pTCXr8cQxmiHZpbSA7L4dZ22ZiQRvbWwwyKYBLMFO9h02G/tQ6p14xLk+mxqoo oHnxNLdQUvN1nT7xUWYq7gPuCkWeKzTktehcCtaq952EBsEPvtBRubyklUwyq0lwEe4dB BBJcXzXWqMxFIyky/HuTAjbr5xYnn7qnK6714JseM0pjJZ2kVb58kFzp5P/3aZaxnVB/i vJSFzwtvXi04Z1gNhsEduLrZly2iQf0M3gb4f1NDvnLUpbHIgKccgWNCizoWdBKFZXR9O tuJ6YlwfjcvaqhvKfIVHiIPF+nXxJYqf2L8QMW5vNXKMwg29B7ato0iKMXfuYm8FbEg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=eCZ9w4Q4; dmarc=pass header.from=126.com; spf=pass smtp.mailfrom=126.com; arc=pass header.oldest-pass=0 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 DC130606A323; Fri, 27 Nov 2026 09:24:25 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=eCZ9w4Q4 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.7 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795771460; b=Q3TbwUtuBvfldPxDsc2/AmH4UjthUSEXY72TY1xcMgkPPLg1SYomkS9YD8VINreNGkHo mmtfUaRtuiLQyVBMkEMuzpD/W+4BiamypOSFrkPH7ODa3QemZUatrmnZxCzHgh3JEHsLC fEaILmM/A4u1Vqb06tGWmqQxK3vOrLojy9+lqNtzDmWoLnZdg3Ej9Av/TB2M/h2eVEjYC EYGS8m6w9Yu4XsvyZgMHrXtsTqxZGYV9nf5rVZAhfrPsAjuYx1VdhmHKswtzKmPCsVZvG KuvdMISWrZP9EB2y7+xseZmjlLiqTmlP2FVHCxw4x9LHBJVAmUKRToM8JSBafWopv1A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795771460; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=mB51IxuF3LEr3pFiFZdoQIrJE8RPv845/UwJgfZGhcw=; b=GKwCOGksKO46CdY42ucs8ww1CMvibYzer4HA+vyzHA5FyrnTloqP6veFyKw7q7iaAKes PhBIfOEYgsAET5Kt/Wi16FYt6VH9TFQ6ellpqc7Howu23aP5VwpzBsF/SqEm+rdRI6PMm xp6wQBRo6OsQOza5Bk/LNhzTwN92HAjLal3nhSHDoCqQDaMurukRxF3c/lsuifaOET8Gu 6kxL0tD6k+NCO1WWQDSsZTQPnH7Qa4sTZKUYXsxolriwU1kynZ9Uhnm3oYuRRfaalTGpX p8tXAOkeqxz2VUY48tJJsADIjpFuHoLw+lauzaVk3cmqqMN2MtrVorhKR4nPfrt7cGA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=eCZ9w4Q4; arc=none smtp.remote-ip=220.197.31.7 X-Received: from m16.mail.126.com (m16.mail.126.com [220.197.31.7]) (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 ABF26606A321; Fri, 27 Nov 2026 09:24:18 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ABF26606A321 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=mB 51IxuF3LEr3pFiFZdoQIrJE8RPv845/UwJgfZGhcw=; b=eCZ9w4Q4yAwCLuoOQo OktOi8JQdVVOBEK8ms4GE1D3eP2ixfJAySfD+iur68jbRfyCAsIg9AMhvtsqohFV 5PW/gUQ3SaBHVarn452zARO5nrECPX+x+E3cIf5FnUg0jyHGMlv76aPM0QVurZs2 eRQKJmWBBrNBEu195QlXTcGrg= X-Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g0-4 (Coremail) with SMTP id _____wD3NzAPTAlrktpmEA--.64683S3; Fri, 27 Nov 2026 17:23:29 +0800 (CST) X-Cc: "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, James Morris <jmorris@namei.org>, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Linkui Xiao <xiaolinkui@kylinos.cn> X-Mailer: git-send-email 2.25.1 X-In-Reply-To: <20261127092325.3563681-1-xiaolinkui@126.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: _____wD3NzAPTAlrktpmEA--.64683S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxXFy8WFykXF1xGF1kGFWDtwb_yoW5Jw13pF W5J398JF1vqrWrXa93Jr1kurWjya1DGFy7C3WIk3y0yrnxJryaqFy8KrW2qF98uFy8JrZ0 qrW5Zws8Ww4kWrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j1Hq7UUUUU= X-CM-SenderInfo: p0ld0z5lqn3xa6rslhhfrp/xtbBlBE0C2sJTBHXKwAA35