[PATCH net] netlabel: fix duplicate IPv4 entries in the staticlist dump
From: Linkui Xiao
Date: Fri Nov 27 2026 - 04:24:30 EST
From: Linkui Xiao <xiaolinkui@xxxxxxxxxx>
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@xxxxxxxxxx>
---
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