netfilter: nf_tables: GC transaction race with abort path
authorSasha Levin <sashal@kernel.org>
Fri, 22 Sep 2023 17:01:11 +0000 (19:01 +0200)
committerSalvatore Bonaccorso <carnil@debian.org>
Fri, 29 Sep 2023 04:25:15 +0000 (05:25 +0100)
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 <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name netfilter-nf_tables-gc-transaction-race-with-abort-p.patch

net/netfilter/nf_tables_api.c

index 78bf82f89ecd8690ec95b3733f4a65c5efc190c0..1f67931b86d8e224df97e2d01cb5648438775b51 100644 (file)
@@ -8844,7 +8844,12 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb,
                           enum nfnl_abort_action action)
 {
        struct nftables_pernet *nft_net = net_generic(net, nf_tables_net_id);
-       int ret = __nf_tables_abort(net, action);
+       unsigned int gc_seq;
+       int ret;
+
+       gc_seq = nft_gc_seq_begin(nft_net);
+       ret = __nf_tables_abort(net, action);
+       nft_gc_seq_end(nft_net, gc_seq);
 
        mutex_unlock(&nft_net->commit_mutex);