Skip to content

Commit 866358e

Browse files
pcmoorekuba-moo
authored andcommitted
netlabel: fix our progress tracking in netlbl_unlabel_staticlist()
The current NetLabel code doesn't correctly keep track of the netlink dump state in some cases, in particular when multiple interfaces with large configurations are loaded. The problem manifests itself by not reporting the full configuration to userspace, even though it is loaded and active in the kernel. This patch fixes this by ensuring that the dump state is properly reset when necessary inside the netlbl_unlabel_staticlist() function. Fixes: 8cc4457 ("NetLabel: Introduce static network labels for unlabeled connections") Signed-off-by: Paul Moore <paul@paul-moore.com> Link: https://lore.kernel.org/r/160484450633.3752.16512718263560813473.stgit@sifl Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 97adb13 commit 866358e

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎net/netlabel/netlabel_unlabeled.c‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,12 +1166,13 @@ static int netlbl_unlabel_staticlist(struct sk_buff *skb,
11661166
struct netlbl_unlhsh_walk_arg cb_arg;
11671167
u32 skip_bkt = cb->args[0];
11681168
u32 skip_chain = cb->args[1];
1169-
u32 iter_bkt;
1170-
u32 iter_chain = 0, iter_addr4 = 0, iter_addr6 = 0;
1169+
u32 skip_addr4 = cb->args[2];
1170+
u32 iter_bkt, iter_chain, iter_addr4 = 0, iter_addr6 = 0;
11711171
struct netlbl_unlhsh_iface *iface;
11721172
struct list_head *iter_list;
11731173
struct netlbl_af4list *addr4;
11741174
#if IS_ENABLED(CONFIG_IPV6)
1175+
u32 skip_addr6 = cb->args[3];
11751176
struct netlbl_af6list *addr6;
11761177
#endif
11771178

@@ -1182,15 +1183,15 @@ static int netlbl_unlabel_staticlist(struct sk_buff *skb,
11821183
rcu_read_lock();
11831184
for (iter_bkt = skip_bkt;
11841185
iter_bkt < rcu_dereference(netlbl_unlhsh)->size;
1185-
iter_bkt++, iter_chain = 0, iter_addr4 = 0, iter_addr6 = 0) {
1186+
iter_bkt++) {
11861187
iter_list = &rcu_dereference(netlbl_unlhsh)->tbl[iter_bkt];
11871188
list_for_each_entry_rcu(iface, iter_list, list) {
11881189
if (!iface->valid ||
11891190
iter_chain++ < skip_chain)
11901191
continue;
11911192
netlbl_af4list_foreach_rcu(addr4,
11921193
&iface->addr4_list) {
1193-
if (iter_addr4++ < cb->args[2])
1194+
if (iter_addr4++ < skip_addr4)
11941195
continue;
11951196
if (netlbl_unlabel_staticlist_gen(
11961197
NLBL_UNLABEL_C_STATICLIST,
@@ -1203,10 +1204,12 @@ static int netlbl_unlabel_staticlist(struct sk_buff *skb,
12031204
goto unlabel_staticlist_return;
12041205
}
12051206
}
1207+
iter_addr4 = 0;
1208+
skip_addr4 = 0;
12061209
#if IS_ENABLED(CONFIG_IPV6)
12071210
netlbl_af6list_foreach_rcu(addr6,
12081211
&iface->addr6_list) {
1209-
if (iter_addr6++ < cb->args[3])
1212+
if (iter_addr6++ < skip_addr6)
12101213
continue;
12111214
if (netlbl_unlabel_staticlist_gen(
12121215
NLBL_UNLABEL_C_STATICLIST,
@@ -1219,8 +1222,12 @@ static int netlbl_unlabel_staticlist(struct sk_buff *skb,
12191222
goto unlabel_staticlist_return;
12201223
}
12211224
}
1225+
iter_addr6 = 0;
1226+
skip_addr6 = 0;
12221227
#endif /* IPv6 */
12231228
}
1229+
iter_chain = 0;
1230+
skip_chain = 0;
12241231
}
12251232

12261233
unlabel_staticlist_return:

0 commit comments

Comments
 (0)