UPSTREAM: netfilter: nf_tables: release batch on table validation from abort path
commit a45e6889575c2067d3c0212b6bc1022891e65b91 upstream.
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
03c1f1ef1584 ("netfilter: Cleanup nft_net->module_list from nf_tables_exit_net()")
only needs to release the pending modules for registration.
Bug: 332996726
Cc: stable@vger.kernel.org
Fixes: c0391b6ab8
("netfilter: nf_tables: missing validation from the abort path")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit b0b36dcbe0f24383612e5e62bd48df5a8107f7fc)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I38f9b05ac4eadd1d2b7b306cccaf0aeacb61b57a
This commit is contained in:

committed by
Treehugger Robot

parent
cd2fc5a605
commit
582e001b25
@@ -8774,10 +8774,11 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
|
|||||||
struct nft_trans *trans, *next;
|
struct nft_trans *trans, *next;
|
||||||
LIST_HEAD(set_update_list);
|
LIST_HEAD(set_update_list);
|
||||||
struct nft_trans_elem *te;
|
struct nft_trans_elem *te;
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
if (action == NFNL_ABORT_VALIDATE &&
|
if (action == NFNL_ABORT_VALIDATE &&
|
||||||
nf_tables_validate(net) < 0)
|
nf_tables_validate(net) < 0)
|
||||||
return -EAGAIN;
|
err = -EAGAIN;
|
||||||
|
|
||||||
list_for_each_entry_safe_reverse(trans, next, &nft_net->commit_list,
|
list_for_each_entry_safe_reverse(trans, next, &nft_net->commit_list,
|
||||||
list) {
|
list) {
|
||||||
@@ -8942,7 +8943,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
|
|||||||
else
|
else
|
||||||
nf_tables_module_autoload_cleanup(net);
|
nf_tables_module_autoload_cleanup(net);
|
||||||
|
|
||||||
return 0;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nf_tables_abort(struct net *net, struct sk_buff *skb,
|
static int nf_tables_abort(struct net *net, struct sk_buff *skb,
|
||||||
@@ -8956,6 +8957,8 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb,
|
|||||||
ret = __nf_tables_abort(net, action);
|
ret = __nf_tables_abort(net, action);
|
||||||
nft_gc_seq_end(nft_net, gc_seq);
|
nft_gc_seq_end(nft_net, gc_seq);
|
||||||
|
|
||||||
|
WARN_ON_ONCE(!list_empty(&nft_net->commit_list));
|
||||||
|
|
||||||
mutex_unlock(&nft_net->commit_mutex);
|
mutex_unlock(&nft_net->commit_mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -9694,8 +9697,11 @@ static void __net_exit nf_tables_exit_net(struct net *net)
|
|||||||
|
|
||||||
gc_seq = nft_gc_seq_begin(nft_net);
|
gc_seq = nft_gc_seq_begin(nft_net);
|
||||||
|
|
||||||
if (!list_empty(&nft_net->commit_list))
|
WARN_ON_ONCE(!list_empty(&nft_net->commit_list));
|
||||||
__nf_tables_abort(net, NFNL_ABORT_NONE);
|
|
||||||
|
if (!list_empty(&nft_net->module_list))
|
||||||
|
nf_tables_module_autoload_cleanup(net);
|
||||||
|
|
||||||
__nft_release_tables(net);
|
__nft_release_tables(net);
|
||||||
|
|
||||||
nft_gc_seq_end(nft_net, gc_seq);
|
nft_gc_seq_end(nft_net, gc_seq);
|
||||||
|
Reference in New Issue
Block a user