Skip to content

Commit

Permalink
netfilter: nf_tables: set backend .flush always succeeds
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gvrose8192 committed Nov 2, 2024
1 parent a70c4eb commit 4b1bb03
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 23 deletions.
2 changes: 1 addition & 1 deletion include/net/netfilter/nf_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ struct nft_set_ops {
void * (*deactivate)(const struct net *net,
const struct nft_set *set,
const struct nft_set_elem *elem);
bool (*flush)(const struct net *net,
void (*flush)(const struct net *net,
const struct nft_set *set,
void *priv);
void (*remove)(const struct net *net,
Expand Down
9 changes: 1 addition & 8 deletions net/netfilter/nf_tables_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -5894,17 +5894,13 @@ static int nft_flush_set(const struct nft_ctx *ctx,
struct nft_set_elem *elem)
{
struct nft_trans *trans;
int err;

trans = nft_trans_alloc_gfp(ctx, NFT_MSG_DELSETELEM,
sizeof(struct nft_trans_elem), GFP_ATOMIC);
if (!trans)
return -ENOMEM;

if (!set->ops->flush(ctx->net, set, elem->priv)) {
err = -ENOENT;
goto err1;
}
set->ops->flush(ctx->net, set, elem->priv);
set->ndeact++;

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

return 0;
err1:
kfree(trans);
return err;
}

static int nf_tables_delsetelem(struct net *net, struct sock *nlsk,
Expand Down
4 changes: 1 addition & 3 deletions net/netfilter/nft_set_bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static void nft_bitmap_activate(const struct net *net,
nft_set_elem_change_active(net, set, &be->ext);
}

static bool nft_bitmap_flush(const struct net *net,
static void nft_bitmap_flush(const struct net *net,
const struct nft_set *set, void *_be)
{
struct nft_bitmap *priv = nft_set_priv(set);
Expand All @@ -188,8 +188,6 @@ static bool nft_bitmap_flush(const struct net *net,
/* Enter 10 state, similar to deactivation. */
priv->bitmap[idx] &= ~(genmask << off);
nft_set_elem_change_active(net, set, &be->ext);

return true;
}

static void *nft_bitmap_deactivate(const struct net *net,
Expand Down
7 changes: 2 additions & 5 deletions net/netfilter/nft_set_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,12 @@ static void nft_rhash_activate(const struct net *net, const struct nft_set *set,
nft_set_elem_change_active(net, set, &he->ext);
}

static bool nft_rhash_flush(const struct net *net,
static void nft_rhash_flush(const struct net *net,
const struct nft_set *set, void *priv)
{
struct nft_rhash_elem *he = priv;

nft_set_elem_change_active(net, set, &he->ext);

return true;
}

static void *nft_rhash_deactivate(const struct net *net,
Expand Down Expand Up @@ -567,13 +565,12 @@ static void nft_hash_activate(const struct net *net, const struct nft_set *set,
nft_set_elem_change_active(net, set, &he->ext);
}

static bool nft_hash_flush(const struct net *net,
static void nft_hash_flush(const struct net *net,
const struct nft_set *set, void *priv)
{
struct nft_hash_elem *he = priv;

nft_set_elem_change_active(net, set, &he->ext);
return true;
}

static void *nft_hash_deactivate(const struct net *net,
Expand Down
5 changes: 2 additions & 3 deletions net/netfilter/nft_set_pipapo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1706,13 +1706,12 @@ static void *nft_pipapo_deactivate(const struct net *net,
*
* Return: true if element was found and deactivated.
*/
static bool nft_pipapo_flush(const struct net *net, const struct nft_set *set,
static void nft_pipapo_flush(const struct net *net, const struct nft_set *set,
void *elem)
{
struct nft_pipapo_elem *e = elem;

return pipapo_deactivate(net, set, (const u8 *)nft_set_ext_key(&e->ext),
&e->ext);
nft_set_elem_change_active(net, set, &e->ext);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions net/netfilter/nft_set_rbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,12 @@ static void nft_rbtree_activate(const struct net *net,
nft_set_elem_change_active(net, set, &rbe->ext);
}

static bool nft_rbtree_flush(const struct net *net,
static void nft_rbtree_flush(const struct net *net,
const struct nft_set *set, void *priv)
{
struct nft_rbtree_elem *rbe = priv;

nft_set_elem_change_active(net, set, &rbe->ext);

return true;
}

static void *nft_rbtree_deactivate(const struct net *net,
Expand Down

0 comments on commit 4b1bb03

Please sign in to comment.