Skip to content

Commit eafbd3f

Browse files
Jozsef Kadlecsikkaber
authored andcommitted
netfilter: ipset: set match and SET target fixes
The SET target with --del-set did not work due to using wrongly the internal dimension of --add-set instead of --del-set. Also, the checkentries did not release the set references when returned an error. Bugs reported by Lennert Buytenhek. Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent 0e8a835 commit eafbd3f

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎net/netfilter/xt_set.c‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ set_match_v0_checkentry(const struct xt_mtchk_param *par)
8181
if (info->match_set.u.flags[IPSET_DIM_MAX-1] != 0) {
8282
pr_warning("Protocol error: set match dimension "
8383
"is over the limit!\n");
84+
ip_set_nfnl_put(info->match_set.index);
8485
return -ERANGE;
8586
}
8687

@@ -135,13 +136,19 @@ set_target_v0_checkentry(const struct xt_tgchk_param *par)
135136
if (index == IPSET_INVALID_ID) {
136137
pr_warning("Cannot find del_set index %u as target\n",
137138
info->del_set.index);
139+
if (info->add_set.index != IPSET_INVALID_ID)
140+
ip_set_nfnl_put(info->add_set.index);
138141
return -ENOENT;
139142
}
140143
}
141144
if (info->add_set.u.flags[IPSET_DIM_MAX-1] != 0 ||
142145
info->del_set.u.flags[IPSET_DIM_MAX-1] != 0) {
143146
pr_warning("Protocol error: SET target dimension "
144147
"is over the limit!\n");
148+
if (info->add_set.index != IPSET_INVALID_ID)
149+
ip_set_nfnl_put(info->add_set.index);
150+
if (info->del_set.index != IPSET_INVALID_ID)
151+
ip_set_nfnl_put(info->del_set.index);
145152
return -ERANGE;
146153
}
147154

@@ -192,6 +199,7 @@ set_match_checkentry(const struct xt_mtchk_param *par)
192199
if (info->match_set.dim > IPSET_DIM_MAX) {
193200
pr_warning("Protocol error: set match dimension "
194201
"is over the limit!\n");
202+
ip_set_nfnl_put(info->match_set.index);
195203
return -ERANGE;
196204
}
197205

@@ -219,7 +227,7 @@ set_target(struct sk_buff *skb, const struct xt_action_param *par)
219227
if (info->del_set.index != IPSET_INVALID_ID)
220228
ip_set_del(info->del_set.index,
221229
skb, par->family,
222-
info->add_set.dim,
230+
info->del_set.dim,
223231
info->del_set.flags);
224232

225233
return XT_CONTINUE;
@@ -245,13 +253,19 @@ set_target_checkentry(const struct xt_tgchk_param *par)
245253
if (index == IPSET_INVALID_ID) {
246254
pr_warning("Cannot find del_set index %u as target\n",
247255
info->del_set.index);
256+
if (info->add_set.index != IPSET_INVALID_ID)
257+
ip_set_nfnl_put(info->add_set.index);
248258
return -ENOENT;
249259
}
250260
}
251261
if (info->add_set.dim > IPSET_DIM_MAX ||
252-
info->del_set.flags > IPSET_DIM_MAX) {
262+
info->del_set.dim > IPSET_DIM_MAX) {
253263
pr_warning("Protocol error: SET target dimension "
254264
"is over the limit!\n");
265+
if (info->add_set.index != IPSET_INVALID_ID)
266+
ip_set_nfnl_put(info->add_set.index);
267+
if (info->del_set.index != IPSET_INVALID_ID)
268+
ip_set_nfnl_put(info->del_set.index);
255269
return -ERANGE;
256270
}
257271

0 commit comments

Comments
 (0)