Skip to content

Commit 96c6b6f

Browse files
committed
netfilter: nf_tables: release batch on table validation from abort path
jira VULN-4906 cve-pre CVE-2024-26925 commit-author Pablo Neira Ayuso <[email protected]> commit a45e688 Unlike early commit path stage which triggers a call to abort, an explicit release of the batch is required on abort, otherwise mutex is released and commit_list remains in place. Add WARN_ON_ONCE to ensure commit_list is empty from the abort path before releasing the mutex. After this patch, commit_list is always assumed to be empty before grabbing the mutex, therefore 03c1f1e ("netfilter: Cleanup nft_net->module_list from nf_tables_exit_net()") only needs to release the pending modules for registration. Cc: [email protected] Fixes: c0391b6 ("netfilter: nf_tables: missing validation from the abort path") Signed-off-by: Pablo Neira Ayuso <[email protected]> (cherry picked from commit a45e688) Signed-off-by: Marcin Wcisło <[email protected]>
1 parent 018fea0 commit 96c6b6f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9749,10 +9749,11 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
97499749
struct nft_trans *trans, *next;
97509750
LIST_HEAD(set_update_list);
97519751
struct nft_trans_elem *te;
9752+
int err = 0;
97529753

97539754
if (action == NFNL_ABORT_VALIDATE &&
97549755
nf_tables_validate(net) < 0)
9755-
return -EAGAIN;
9756+
err = -EAGAIN;
97569757

97579758
list_for_each_entry_safe_reverse(trans, next, &nft_net->commit_list,
97589759
list) {
@@ -9927,7 +9928,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
99279928
else
99289929
nf_tables_module_autoload_cleanup(net);
99299930

9930-
return 0;
9931+
return err;
99319932
}
99329933

99339934
static int nf_tables_abort(struct net *net, struct sk_buff *skb,
@@ -9940,6 +9941,9 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb,
99409941
gc_seq = nft_gc_seq_begin(nft_net);
99419942
ret = __nf_tables_abort(net, action);
99429943
nft_gc_seq_end(nft_net, gc_seq);
9944+
9945+
WARN_ON_ONCE(!list_empty(&nft_net->commit_list));
9946+
99439947
mutex_unlock(&nft_net->commit_mutex);
99449948

99459949
return ret;
@@ -10737,9 +10741,10 @@ static void __net_exit nf_tables_exit_net(struct net *net)
1073710741

1073810742
gc_seq = nft_gc_seq_begin(nft_net);
1073910743

10740-
if (!list_empty(&nft_net->commit_list) ||
10741-
!list_empty(&nft_net->module_list))
10742-
__nf_tables_abort(net, NFNL_ABORT_NONE);
10744+
WARN_ON_ONCE(!list_empty(&nft_net->commit_list));
10745+
10746+
if (!list_empty(&nft_net->module_list))
10747+
nf_tables_module_autoload_cleanup(net);
1074310748

1074410749
__nft_release_tables(net);
1074510750

0 commit comments

Comments
 (0)