From: Linkui Xiao <xiaolinkui@126.com>
To: Paul Moore <paul@paul-moore.com>, netdev@vger.kernel.org
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>
Subject: [PATCH net] netlabel: fix duplicate IPv4 entries in the staticlist dump
Date: Fri, 27 Nov 2026 17:23:25 +0800 [thread overview]
Message-ID: <20261127092325.3563681-2-xiaolinkui@126.com> (raw)
In-Reply-To: <20261127092325.3563681-1-xiaolinkui@126.com>
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
next prev parent reply other threads:[~2026-11-27 9:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 9:23 [PATCH net] netlabel: fix a race in netlbl_unlhsh_condremove_iface() Linkui Xiao
2026-11-27 9:23 ` Linkui Xiao [this message]
2026-11-27 9:27 ` [PATCH net] netlabel: fix duplicate IPv4 entries in the staticlist dump sashiko-bot
2026-11-27 9:30 ` netdev-bot+sinfo
2026-11-27 9:28 ` [PATCH net] netlabel: fix a race in netlbl_unlhsh_condremove_iface() sashiko-bot
2026-11-27 9:30 ` netdev-bot+sinfo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127092325.3563681-2-xiaolinkui@126.com \
--to=xiaolinkui@126.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jmorris@namei.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paul@paul-moore.com \
--cc=xiaolinkui@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox