Skip to content

Commit 0d459e2

Browse files
committed
netfilter: nf_tables: release mutex after nft_gc_seq_end from abort path
The commit mutex should not be released during the critical section between nft_gc_seq_begin() and nft_gc_seq_end(), otherwise, async GC worker could collect expired objects and get the released commit lock within the same GC sequence. nf_tables_module_autoload() temporarily releases the mutex to load module dependencies, then it goes back to replay the transaction again. Move it at the end of the abort phase after nft_gc_seq_end() is called. Cc: [email protected] Fixes: 7203443 ("netfilter: nf_tables: GC transaction race with abort path") Reported-by: Kuan-Ting Chen <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent a45e688 commit 0d459e2

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10651,11 +10651,6 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
1065110651
nf_tables_abort_release(trans);
1065210652
}
1065310653

10654-
if (action == NFNL_ABORT_AUTOLOAD)
10655-
nf_tables_module_autoload(net);
10656-
else
10657-
nf_tables_module_autoload_cleanup(net);
10658-
1065910654
return err;
1066010655
}
1066110656

@@ -10672,6 +10667,14 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb,
1067210667

1067310668
WARN_ON_ONCE(!list_empty(&nft_net->commit_list));
1067410669

10670+
/* module autoload needs to happen after GC sequence update because it
10671+
* temporarily releases and grabs mutex again.
10672+
*/
10673+
if (action == NFNL_ABORT_AUTOLOAD)
10674+
nf_tables_module_autoload(net);
10675+
else
10676+
nf_tables_module_autoload_cleanup(net);
10677+
1067510678
mutex_unlock(&nft_net->commit_mutex);
1067610679

1067710680
return ret;

0 commit comments

Comments
 (0)