Skip to content

Commit 4b1bb03

Browse files
committed
netfilter: nf_tables: set backend .flush always succeeds
jira VULN-835 subsystem-sync netfilter:nf_tables 4.18.0-534 commit-author Pablo Neira Ayuso <[email protected]> commit 6509a2e upstream-diff - A conflict in nft_pipapo_flush resolved by favoring the 4.18.0-0-534 tagged code. .flush is always successful since this results from iterating over the set elements to toggle mark the element as inactive in the next generation. Signed-off-by: Pablo Neira Ayuso <[email protected]> (cherry picked from commit 6509a2e) Signed-off-by: Greg Rose <[email protected]> Conflicts: net/netfilter/nft_set_pipapo.c
1 parent a70c4eb commit 4b1bb03

File tree

6 files changed

+8
-23
lines changed

6 files changed

+8
-23
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ struct nft_set_ops {
375375
void * (*deactivate)(const struct net *net,
376376
const struct nft_set *set,
377377
const struct nft_set_elem *elem);
378-
bool (*flush)(const struct net *net,
378+
void (*flush)(const struct net *net,
379379
const struct nft_set *set,
380380
void *priv);
381381
void (*remove)(const struct net *net,

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5894,17 +5894,13 @@ static int nft_flush_set(const struct nft_ctx *ctx,
58945894
struct nft_set_elem *elem)
58955895
{
58965896
struct nft_trans *trans;
5897-
int err;
58985897

58995898
trans = nft_trans_alloc_gfp(ctx, NFT_MSG_DELSETELEM,
59005899
sizeof(struct nft_trans_elem), GFP_ATOMIC);
59015900
if (!trans)
59025901
return -ENOMEM;
59035902

5904-
if (!set->ops->flush(ctx->net, set, elem->priv)) {
5905-
err = -ENOENT;
5906-
goto err1;
5907-
}
5903+
set->ops->flush(ctx->net, set, elem->priv);
59085904
set->ndeact++;
59095905

59105906
nft_setelem_data_deactivate(ctx->net, set, elem);
@@ -5913,9 +5909,6 @@ static int nft_flush_set(const struct nft_ctx *ctx,
59135909
list_add_tail(&trans->list, &ctx->net->nft.commit_list);
59145910

59155911
return 0;
5916-
err1:
5917-
kfree(trans);
5918-
return err;
59195912
}
59205913

59215914
static int nf_tables_delsetelem(struct net *net, struct sock *nlsk,

net/netfilter/nft_set_bitmap.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static void nft_bitmap_activate(const struct net *net,
176176
nft_set_elem_change_active(net, set, &be->ext);
177177
}
178178

179-
static bool nft_bitmap_flush(const struct net *net,
179+
static void nft_bitmap_flush(const struct net *net,
180180
const struct nft_set *set, void *_be)
181181
{
182182
struct nft_bitmap *priv = nft_set_priv(set);
@@ -188,8 +188,6 @@ static bool nft_bitmap_flush(const struct net *net,
188188
/* Enter 10 state, similar to deactivation. */
189189
priv->bitmap[idx] &= ~(genmask << off);
190190
nft_set_elem_change_active(net, set, &be->ext);
191-
192-
return true;
193191
}
194192

195193
static void *nft_bitmap_deactivate(const struct net *net,

net/netfilter/nft_set_hash.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,12 @@ static void nft_rhash_activate(const struct net *net, const struct nft_set *set,
194194
nft_set_elem_change_active(net, set, &he->ext);
195195
}
196196

197-
static bool nft_rhash_flush(const struct net *net,
197+
static void nft_rhash_flush(const struct net *net,
198198
const struct nft_set *set, void *priv)
199199
{
200200
struct nft_rhash_elem *he = priv;
201201

202202
nft_set_elem_change_active(net, set, &he->ext);
203-
204-
return true;
205203
}
206204

207205
static void *nft_rhash_deactivate(const struct net *net,
@@ -567,13 +565,12 @@ static void nft_hash_activate(const struct net *net, const struct nft_set *set,
567565
nft_set_elem_change_active(net, set, &he->ext);
568566
}
569567

570-
static bool nft_hash_flush(const struct net *net,
568+
static void nft_hash_flush(const struct net *net,
571569
const struct nft_set *set, void *priv)
572570
{
573571
struct nft_hash_elem *he = priv;
574572

575573
nft_set_elem_change_active(net, set, &he->ext);
576-
return true;
577574
}
578575

579576
static void *nft_hash_deactivate(const struct net *net,

net/netfilter/nft_set_pipapo.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,13 +1706,12 @@ static void *nft_pipapo_deactivate(const struct net *net,
17061706
*
17071707
* Return: true if element was found and deactivated.
17081708
*/
1709-
static bool nft_pipapo_flush(const struct net *net, const struct nft_set *set,
1709+
static void nft_pipapo_flush(const struct net *net, const struct nft_set *set,
17101710
void *elem)
17111711
{
17121712
struct nft_pipapo_elem *e = elem;
17131713

1714-
return pipapo_deactivate(net, set, (const u8 *)nft_set_ext_key(&e->ext),
1715-
&e->ext);
1714+
nft_set_elem_change_active(net, set, &e->ext);
17161715
}
17171716

17181717
/**

net/netfilter/nft_set_rbtree.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,12 @@ static void nft_rbtree_activate(const struct net *net,
384384
nft_set_elem_change_active(net, set, &rbe->ext);
385385
}
386386

387-
static bool nft_rbtree_flush(const struct net *net,
387+
static void nft_rbtree_flush(const struct net *net,
388388
const struct nft_set *set, void *priv)
389389
{
390390
struct nft_rbtree_elem *rbe = priv;
391391

392392
nft_set_elem_change_active(net, set, &rbe->ext);
393-
394-
return true;
395393
}
396394

397395
static void *nft_rbtree_deactivate(const struct net *net,

0 commit comments

Comments
 (0)