Skip to content

Commit 2919917

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 aa04097 commit 2919917

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
@@ -10069,11 +10069,6 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
1006910069
nf_tables_abort_release(trans);
1007010070
}
1007110071

10072-
if (action == NFNL_ABORT_AUTOLOAD)
10073-
nf_tables_module_autoload(net);
10074-
else
10075-
nf_tables_module_autoload_cleanup(net);
10076-
1007710072
return err;
1007810073
}
1007910074

@@ -10090,6 +10085,14 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb,
1009010085

1009110086
WARN_ON_ONCE(!list_empty(&nft_net->commit_list));
1009210087

10088+
/* module autoload needs to happen after GC sequence update because it
10089+
* temporarily releases and grabs mutex again.
10090+
*/
10091+
if (action == NFNL_ABORT_AUTOLOAD)
10092+
nf_tables_module_autoload(net);
10093+
else
10094+
nf_tables_module_autoload_cleanup(net);
10095+
1009310096
mutex_unlock(&nft_net->commit_mutex);
1009410097

1009510098
return ret;

0 commit comments

Comments
 (0)