Skip to content

Commit b1df305

Browse files
committed
netfilter: nf_tables: release mutex after nft_gc_seq_end from abort path
jira VULN-4906 cve CVE-2024-26925 commit-author Pablo Neira Ayuso <[email protected]> commit 0d459e2 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]> (cherry picked from commit 0d459e2) Signed-off-by: Marcin Wcisło <[email protected]>
1 parent 96c6b6f commit b1df305

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
@@ -9923,11 +9923,6 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
99239923
nf_tables_abort_release(trans);
99249924
}
99259925

9926-
if (action == NFNL_ABORT_AUTOLOAD)
9927-
nf_tables_module_autoload(net);
9928-
else
9929-
nf_tables_module_autoload_cleanup(net);
9930-
99319926
return err;
99329927
}
99339928

@@ -9944,6 +9939,14 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb,
99449939

99459940
WARN_ON_ONCE(!list_empty(&nft_net->commit_list));
99469941

9942+
/* module autoload needs to happen after GC sequence update because it
9943+
* temporarily releases and grabs mutex again.
9944+
*/
9945+
if (action == NFNL_ABORT_AUTOLOAD)
9946+
nf_tables_module_autoload(net);
9947+
else
9948+
nf_tables_module_autoload_cleanup(net);
9949+
99479950
mutex_unlock(&nft_net->commit_mutex);
99489951

99499952
return ret;

0 commit comments

Comments
 (0)