Skip to content

Commit 4c755b3

Browse files
ummakynesguojinhui-liam
authored andcommitted
netfilter: nf_tables: release mutex after nft_gc_seq_end from abort path
commit 0d459e2 upstream. 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]> Signed-off-by: Feng Zhou <[email protected]>
1 parent 50975e1 commit 4c755b3

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
@@ -9875,11 +9875,6 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
98759875
nf_tables_abort_release(trans);
98769876
}
98779877

9878-
if (action == NFNL_ABORT_AUTOLOAD)
9879-
nf_tables_module_autoload(net);
9880-
else
9881-
nf_tables_module_autoload_cleanup(net);
9882-
98839878
return err;
98849879
}
98859880

@@ -9896,6 +9891,14 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb,
98969891

98979892
WARN_ON_ONCE(!list_empty(&nft_net->commit_list));
98989893

9894+
/* module autoload needs to happen after GC sequence update because it
9895+
* temporarily releases and grabs mutex again.
9896+
*/
9897+
if (action == NFNL_ABORT_AUTOLOAD)
9898+
nf_tables_module_autoload(net);
9899+
else
9900+
nf_tables_module_autoload_cleanup(net);
9901+
98999902
mutex_unlock(&nft_net->commit_mutex);
99009903

99019904
return ret;

0 commit comments

Comments
 (0)