Skip to content

Commit 6e190e5

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 <pablo@netfilter.org> 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: stable@vger.kernel.org Fixes: c0391b6 ("netfilter: nf_tables: missing validation from the abort path") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> (cherry picked from commit a45e688) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent 46a1bbb commit 6e190e5

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
@@ -9888,10 +9888,11 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
98889888
struct nft_trans *trans, *next;
98899889
LIST_HEAD(set_update_list);
98909890
struct nft_trans_elem *te;
9891+
int err = 0;
98919892

98929893
if (action == NFNL_ABORT_VALIDATE &&
98939894
nf_tables_validate(net) < 0)
9894-
return -EAGAIN;
9895+
err = -EAGAIN;
98959896

98969897
list_for_each_entry_safe_reverse(trans, next, &nft_net->commit_list,
98979898
list) {
@@ -10073,7 +10074,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
1007310074
else
1007410075
nf_tables_module_autoload_cleanup(net);
1007510076

10076-
return 0;
10077+
return err;
1007710078
}
1007810079

1007910080
static int nf_tables_abort(struct net *net, struct sk_buff *skb,
@@ -10086,6 +10087,9 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb,
1008610087
gc_seq = nft_gc_seq_begin(nft_net);
1008710088
ret = __nf_tables_abort(net, action);
1008810089
nft_gc_seq_end(nft_net, gc_seq);
10090+
10091+
WARN_ON_ONCE(!list_empty(&nft_net->commit_list));
10092+
1008910093
mutex_unlock(&nft_net->commit_mutex);
1009010094

1009110095
return ret;
@@ -10883,9 +10887,10 @@ static void __net_exit nf_tables_exit_net(struct net *net)
1088310887

1088410888
gc_seq = nft_gc_seq_begin(nft_net);
1088510889

10886-
if (!list_empty(&nft_net->commit_list) ||
10887-
!list_empty(&nft_net->module_list))
10888-
__nf_tables_abort(net, NFNL_ABORT_NONE);
10890+
WARN_ON_ONCE(!list_empty(&nft_net->commit_list));
10891+
10892+
if (!list_empty(&nft_net->module_list))
10893+
nf_tables_module_autoload_cleanup(net);
1088910894

1089010895
__nft_release_tables(net);
1089110896

0 commit comments

Comments
 (0)