Skip to content

Commit fd09e77

Browse files
committed
netfilter: nft_set_rbtree: use read spinlock to avoid datapath contention
jira VULN-430 cve CVE-2023-4244 commit-author Pablo Neira Ayuso <pablo@netfilter.org> commit 96b3330 rbtree GC does not modify the datastructure, instead it collects expired elements and it enqueues a GC transaction. Use a read spinlock instead to avoid data contention while GC worker is running. 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 96b3330) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent e7ebc39 commit fd09e77

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

net/netfilter/nft_set_rbtree.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,7 @@ static void nft_rbtree_gc(struct work_struct *work)
622622
if (!gc)
623623
goto done;
624624

625-
write_lock_bh(&priv->lock);
626-
write_seqcount_begin(&priv->count);
625+
read_lock_bh(&priv->lock);
627626
for (node = rb_first(&priv->root); node != NULL; node = rb_next(node)) {
628627

629628
/* Ruleset has been updated, try later. */
@@ -673,8 +672,7 @@ static void nft_rbtree_gc(struct work_struct *work)
673672
gc = nft_trans_gc_catchall_async(gc, gc_seq);
674673

675674
try_later:
676-
write_seqcount_end(&priv->count);
677-
write_unlock_bh(&priv->lock);
675+
read_unlock_bh(&priv->lock);
678676

679677
if (gc)
680678
nft_trans_gc_queue_async_done(gc);

0 commit comments

Comments
 (0)