From 9b4dde02a43ec82558db99f94bfbb512ea37e967 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 21 Aug 2023 22:52:28 +0200 Subject: [PATCH -stable,4.14 14/17] netfilter: nf_tables: GC transaction race with abort path commit 720344340fb9be2765bbaab7b292ece0a4570eae upstream. Abort path is missing a synchronization point with GC transactions. Add GC sequence number hence any GC transaction losing race will be discarded. Fixes: 5f68718b34a5 ("netfilter: nf_tables: GC transaction API to avoid race with control plane") Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_tables_api.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 4087b2fedca0..cf3f6722fb2a 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -5686,6 +5686,9 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb) { struct nft_trans *trans, *next; struct nft_trans_elem *te; + unsigned int gc_seq; + + gc_seq = nft_gc_seq_begin(net); list_for_each_entry_safe_reverse(trans, next, &net->nft.commit_list, list) { @@ -5793,6 +5796,8 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb) nf_tables_abort_release(trans); } + nft_gc_seq_end(net, gc_seq); + return 0; } -- 2.30.2