Skip to content

Commit f21727c

Browse files
committed
netfilter: nf_tables: set backend .flush always succeeds
jira VULN-430 cve CVE-2023-4244 commit-author Pablo Neira Ayuso <pablo@netfilter.org> commit 6509a2e .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 <pablo@netfilter.org> (cherry picked from commit 6509a2e) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent 7c0a2d9 commit f21727c

File tree

6 files changed

+7
-23
lines changed

6 files changed

+7
-23
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ struct nft_set_ops {
412412
void * (*deactivate)(const struct net *net,
413413
const struct nft_set *set,
414414
const struct nft_set_elem *elem);
415-
bool (*flush)(const struct net *net,
415+
void (*flush)(const struct net *net,
416416
const struct nft_set *set,
417417
void *priv);
418418
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
@@ -6834,17 +6834,13 @@ static int nft_setelem_flush(const struct nft_ctx *ctx,
68346834
struct nft_set_elem *elem)
68356835
{
68366836
struct nft_trans *trans;
6837-
int err;
68386837

68396838
trans = nft_trans_alloc_gfp(ctx, NFT_MSG_DELSETELEM,
68406839
sizeof(struct nft_trans_elem), GFP_ATOMIC);
68416840
if (!trans)
68426841
return -ENOMEM;
68436842

6844-
if (!set->ops->flush(ctx->net, set, elem->priv)) {
6845-
err = -ENOENT;
6846-
goto err1;
6847-
}
6843+
set->ops->flush(ctx->net, set, elem->priv);
68486844
set->ndeact++;
68496845

68506846
nft_setelem_data_deactivate(ctx->net, set, elem);
@@ -6853,9 +6849,6 @@ static int nft_setelem_flush(const struct nft_ctx *ctx,
68536849
nft_trans_commit_list_add_tail(ctx->net, trans);
68546850

68556851
return 0;
6856-
err1:
6857-
kfree(trans);
6858-
return err;
68596852
}
68606853

68616854
static int __nft_set_catchall_flush(const struct nft_ctx *ctx,

net/netfilter/nft_set_bitmap.c

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

177-
static bool nft_bitmap_flush(const struct net *net,
177+
static void nft_bitmap_flush(const struct net *net,
178178
const struct nft_set *set, void *_be)
179179
{
180180
struct nft_bitmap *priv = nft_set_priv(set);
@@ -186,8 +186,6 @@ static bool nft_bitmap_flush(const struct net *net,
186186
/* Enter 10 state, similar to deactivation. */
187187
priv->bitmap[idx] &= ~(genmask << off);
188188
nft_set_elem_change_active(net, set, &be->ext);
189-
190-
return true;
191189
}
192190

193191
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
@@ -192,14 +192,12 @@ static void nft_rhash_activate(const struct net *net, const struct nft_set *set,
192192
nft_set_elem_change_active(net, set, &he->ext);
193193
}
194194

195-
static bool nft_rhash_flush(const struct net *net,
195+
static void nft_rhash_flush(const struct net *net,
196196
const struct nft_set *set, void *priv)
197197
{
198198
struct nft_rhash_elem *he = priv;
199199

200200
nft_set_elem_change_active(net, set, &he->ext);
201-
202-
return true;
203201
}
204202

205203
static void *nft_rhash_deactivate(const struct net *net,
@@ -590,13 +588,12 @@ static void nft_hash_activate(const struct net *net, const struct nft_set *set,
590588
nft_set_elem_change_active(net, set, &he->ext);
591589
}
592590

593-
static bool nft_hash_flush(const struct net *net,
591+
static void nft_hash_flush(const struct net *net,
594592
const struct nft_set *set, void *priv)
595593
{
596594
struct nft_hash_elem *he = priv;
597595

598596
nft_set_elem_change_active(net, set, &he->ext);
599-
return true;
600597
}
601598

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

net/netfilter/nft_set_pipapo.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,14 +1811,12 @@ static void *nft_pipapo_deactivate(const struct net *net,
18111811
*
18121812
* Return: true if element was found and deactivated.
18131813
*/
1814-
static bool nft_pipapo_flush(const struct net *net, const struct nft_set *set,
1814+
static void nft_pipapo_flush(const struct net *net, const struct nft_set *set,
18151815
void *elem)
18161816
{
18171817
struct nft_pipapo_elem *e = elem;
18181818

18191819
nft_set_elem_change_active(net, set, &e->ext);
1820-
1821-
return true;
18221820
}
18231821

18241822
/**

net/netfilter/nft_set_rbtree.c

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

533-
static bool nft_rbtree_flush(const struct net *net,
533+
static void nft_rbtree_flush(const struct net *net,
534534
const struct nft_set *set, void *priv)
535535
{
536536
struct nft_rbtree_elem *rbe = priv;
537537

538538
nft_set_elem_change_active(net, set, &rbe->ext);
539-
540-
return true;
541539
}
542540

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

0 commit comments

Comments
 (0)