Skip to content

Commit e7ebc39

Browse files
committed
netfilter: nft_set_pipapo: call nft_trans_gc_queue_sync() in catchall GC
jira VULN-430 cve CVE-2023-4244 commit-author Pablo Neira Ayuso <pablo@netfilter.org> commit 4a9e12e pipapo needs to enqueue GC transactions for catchall elements through nft_trans_gc_queue_sync(). Add nft_trans_gc_catchall_sync() and nft_trans_gc_catchall_async() to handle GC transaction queueing accordingly. Fixes: 5f68718 ("netfilter: nf_tables: GC transaction API to avoid race with control plane") Fixes: f6c383b ("netfilter: nf_tables: adapt set backend to use GC transaction API") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> (cherry picked from commit 4a9e12e) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent 89d6ab2 commit e7ebc39

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,8 +1629,9 @@ void nft_trans_gc_queue_sync_done(struct nft_trans_gc *trans);
16291629

16301630
void nft_trans_gc_elem_add(struct nft_trans_gc *gc, void *priv);
16311631

1632-
struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
1633-
unsigned int gc_seq);
1632+
struct nft_trans_gc *nft_trans_gc_catchall_async(struct nft_trans_gc *gc,
1633+
unsigned int gc_seq);
1634+
struct nft_trans_gc *nft_trans_gc_catchall_sync(struct nft_trans_gc *gc);
16341635

16351636
void nft_setelem_data_deactivate(const struct net *net,
16361637
const struct nft_set *set,

net/netfilter/nf_tables_api.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9256,8 +9256,9 @@ void nft_trans_gc_queue_sync_done(struct nft_trans_gc *trans)
92569256
call_rcu(&trans->rcu, nft_trans_gc_trans_free);
92579257
}
92589258

9259-
struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
9260-
unsigned int gc_seq)
9259+
static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
9260+
unsigned int gc_seq,
9261+
bool sync)
92619262
{
92629263
struct nft_set_elem_catchall *catchall;
92639264
const struct nft_set *set = gc->set;
@@ -9273,7 +9274,11 @@ struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
92739274

92749275
nft_set_elem_dead(ext);
92759276
dead_elem:
9276-
gc = nft_trans_gc_queue_async(gc, gc_seq, GFP_ATOMIC);
9277+
if (sync)
9278+
gc = nft_trans_gc_queue_sync(gc, GFP_ATOMIC);
9279+
else
9280+
gc = nft_trans_gc_queue_async(gc, gc_seq, GFP_ATOMIC);
9281+
92779282
if (!gc)
92789283
return NULL;
92799284

@@ -9283,6 +9288,17 @@ struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
92839288
return gc;
92849289
}
92859290

9291+
struct nft_trans_gc *nft_trans_gc_catchall_async(struct nft_trans_gc *gc,
9292+
unsigned int gc_seq)
9293+
{
9294+
return nft_trans_gc_catchall(gc, gc_seq, false);
9295+
}
9296+
9297+
struct nft_trans_gc *nft_trans_gc_catchall_sync(struct nft_trans_gc *gc)
9298+
{
9299+
return nft_trans_gc_catchall(gc, 0, true);
9300+
}
9301+
92869302
static void nf_tables_module_autoload_cleanup(struct net *net)
92879303
{
92889304
struct nftables_pernet *nft_net = nft_pernet(net);

net/netfilter/nft_set_hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static void nft_rhash_gc(struct work_struct *work)
372372
nft_trans_gc_elem_add(gc, he);
373373
}
374374

375-
gc = nft_trans_gc_catchall(gc, gc_seq);
375+
gc = nft_trans_gc_catchall_async(gc, gc_seq);
376376

377377
try_later:
378378
/* catchall list iteration requires rcu read side lock. */

net/netfilter/nft_set_pipapo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ static void pipapo_gc(const struct nft_set *_set, struct nft_pipapo_match *m)
16111611
}
16121612
}
16131613

1614-
gc = nft_trans_gc_catchall(gc, 0);
1614+
gc = nft_trans_gc_catchall_sync(gc);
16151615
if (gc) {
16161616
nft_trans_gc_queue_sync_done(gc);
16171617
priv->last_gc = jiffies;

net/netfilter/nft_set_rbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ static void nft_rbtree_gc(struct work_struct *work)
670670
nft_trans_gc_elem_add(gc, rbe);
671671
}
672672

673-
gc = nft_trans_gc_catchall(gc, gc_seq);
673+
gc = nft_trans_gc_catchall_async(gc, gc_seq);
674674

675675
try_later:
676676
write_seqcount_end(&priv->count);

0 commit comments

Comments
 (0)