Skip to content

Commit 6fb4d40

Browse files
committed
netfilter: nf_tables: release batch on table validation from abort path
jira VULN-4969 subsystem-sync netfilter:nf_tables 4.18.0-553.16.1 commit-author Pablo Neira Ayuso <pablo@netfilter.org> commit a45e688 upstream-diff - A couple of conflicts fixed up by referring to 4.18.0-553.16.1 tagged code as the source of truth in resolving. 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: Greg Rose <g.v.rose@ciq.com> Conflicts: net/netfilter/nf_tables_api.c
1 parent 14fe263 commit 6fb4d40

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8465,10 +8465,11 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
84658465
struct nft_trans *trans, *next;
84668466
LIST_HEAD(set_update_list);
84678467
struct nft_trans_elem *te;
8468+
int err = 0;
84688469

84698470
if (action == NFNL_ABORT_VALIDATE &&
84708471
nf_tables_validate(net) < 0)
8471-
return -EAGAIN;
8472+
err = -EAGAIN;
84728473

84738474
list_for_each_entry_safe_reverse(trans, next, &net->nft.commit_list,
84748475
list) {
@@ -8617,7 +8618,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
86178618
else
86188619
nf_tables_module_autoload_cleanup(net);
86198620

8620-
return 0;
8621+
return err;
86218622
}
86228623

86238624
static void nf_tables_cleanup(struct net *net)
@@ -8636,6 +8637,16 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb,
86368637
ret = __nf_tables_abort(net, action);
86378638
nft_gc_seq_end(nft_net, gc_seq);
86388639

8640+
WARN_ON_ONCE(!list_empty(&net->nft.commit_list));
8641+
8642+
/* module autoload needs to happen after GC sequence update because it
8643+
* temporarily releases and grabs mutex again.
8644+
*/
8645+
if (action == NFNL_ABORT_AUTOLOAD)
8646+
nf_tables_module_autoload(net);
8647+
else
8648+
nf_tables_module_autoload_cleanup(net);
8649+
86398650
mutex_unlock(&net->nft_commit_mutex);
86408651

86418652
return ret;
@@ -9287,9 +9298,10 @@ static void __net_exit nf_tables_exit_net(struct net *net)
92879298

92889299
gc_seq = nft_gc_seq_begin(nft_net);
92899300

9290-
if (!list_empty(&net->nft.commit_list) ||
9291-
!list_empty(&net->nft_module_list))
9292-
__nf_tables_abort(net, NFNL_ABORT_NONE);
9301+
WARN_ON_ONCE(!list_empty(&net->nft.commit_list));
9302+
9303+
if (!list_empty(&net->nft_module_list))
9304+
nf_tables_module_autoload_cleanup(net);
92939305

92949306
__nft_release_tables(net);
92959307

0 commit comments

Comments
 (0)