public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] netfilter: nft_set_pipapo: clear dirty flag on abort/commit clone failure
@ 2026-03-04 13:38 Natarajan KV
  2026-03-04 13:47 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Natarajan KV @ 2026-03-04 13:38 UTC (permalink / raw)
  To: stable; +Cc: gregkh, pablo, kadlec, fw

nft_pipapo_abort() and nft_pipapo_commit() call pipapo_clone() which
can fail under memory pressure. When this happens, the functions return
early without clearing priv->dirty. Since the set_ops->abort callback
returns void, the nf_tables framework cannot detect this failure.

The stale clone, which still contains modifications from the failed
transaction, persists with dirty == true. On a subsequent commit,
nft_pipapo_commit() sees dirty == true and promotes the stale clone
to the active match via rcu_assign_pointer(), causing the lookup data
to reflect operations that should have been rolled back.

This can lead to incorrect packet matching (firewall rule bypass),
memory leaks from unreachable elements, and potential use-after-free
if elements freed by the framework are still referenced through
stale clone mapping tables.

In mainline, this was resolved by commit 212ed75dc5fb ("netfilter:
nf_tables: integrate pipapo into commit protocol") which refactored
pipapo to use dedicated set commit/abort ops, eliminating
pipapo_clone() from the abort path entirely. That refactor touches
3 files and modifies the nf_tables framework, making it too invasive
to backport to stable branches.

Fix this minimally by clearing priv->dirty when pipapo_clone() fails
in both nft_pipapo_commit() and nft_pipapo_abort(), preventing stale
clone promotion on subsequent commits.

Fixes: 3c4287f62044 ("nf_tables: Add set type for arbitrary concatenation of ranges")
Cc: stable@vger.kernel.org
Signed-off-by: Natarajan KV <natarajankv91@gmail.com>
---
 net/netfilter/nft_set_pipapo.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c
index 4274831b6e67..34a108399fd3 100644
--- a/net/netfilter/nft_set_pipapo.c
+++ b/net/netfilter/nft_set_pipapo.c
@@ -1708,8 +1708,10 @@ static void nft_pipapo_commit(struct nft_set *set)
 		return;
 
 	new_clone = pipapo_clone(priv->clone);
-	if (IS_ERR(new_clone))
+	if (IS_ERR(new_clone)) {
+		priv->dirty = false;
 		return;
+	}
 
 	priv->dirty = false;
 
@@ -1743,8 +1745,10 @@ static void nft_pipapo_abort(const struct nft_set *set)
 	m = rcu_dereference_protected(priv->match, nft_pipapo_transaction_mutex_held(set));
 
 	new_clone = pipapo_clone(m);
-	if (IS_ERR(new_clone))
+	if (IS_ERR(new_clone)) {
+		priv->dirty = false;
 		return;
+	}
 
 	priv->dirty = false;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-03-04 21:30 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-04 13:38 [PATCH] netfilter: nft_set_pipapo: clear dirty flag on abort/commit clone failure Natarajan KV
2026-03-04 13:47 ` Greg KH
2026-03-04 13:50 ` Florian Westphal
2026-03-04 15:08 ` [PATCH v2] netfilter: nft_set_pipapo: move clone allocation to insert/removal path Natarajan KV
2026-03-04 15:12   ` Greg KH
2026-03-04 16:54     ` [PATCH v3 6.6.y 0/8] " Natarajan KV
2026-03-04 16:54       ` [PATCH v3 6.6.y 1/8] netfilter: nft_set_pipapo: move prove_locking helper around Natarajan KV
2026-03-04 16:54       ` [PATCH v3 6.6.y 2/8] netfilter: nft_set_pipapo: make pipapo_clone helper return NULL Natarajan KV
2026-03-04 16:55       ` [PATCH v3 6.6.y 3/8] netfilter: nft_set_pipapo: prepare destroy function for on-demand clone Natarajan KV
2026-03-04 16:55       ` [PATCH v3 6.6.y 4/8] netfilter: nft_set_pipapo: prepare walk " Natarajan KV
2026-03-04 16:55       ` [PATCH v3 6.6.y 5/8] netfilter: nft_set_pipapo: merge deactivate helper into caller Natarajan KV
2026-03-04 16:55       ` [PATCH v3 6.6.y 6/8] netfilter: nft_set_pipapo: prepare pipapo_get helper for on-demand clone Natarajan KV
2026-03-04 16:55       ` [PATCH v3 6.6.y 7/8] netfilter: nft_set_pipapo: move cloning of match info to insert/removal path Natarajan KV
2026-03-04 16:55       ` [PATCH v3 6.6.y 8/8] netfilter: nft_set_pipapo: remove dirty flag Natarajan KV
2026-03-04 21:30       ` [PATCH v3 6.6.y 0/8] netfilter: nft_set_pipapo: move clone allocation to insert/removal path Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox