Skip to contentSkip to conversation

netfilter: nf_tables: always walk all pending catchall elements

PATCH Applied Steffen Pfendtner 2 participants 2 messages Oct 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nf_tables: always walk all pending catchall elements

From: Florian Westphal <[email protected]>

[ Upstream commit 7cb9a23d7ae40a702577d3d8bacb7026f04ac2a9 ]

During transaction processing we might have more than one catchall element:
1 live catchall element and 1 pending element that is coming as part of the new batch.

If the map holding the catchall elements is also going away, its required to toggle all catchall elements and not just the first viable candidate.

Otherwise, we get:

 WARNING: ./include/net/netfilter/nf_tables.h:1281 at nft_data_release+0xb7/0xe0 [nf_tables], CPU#2: nft/1404
 RIP: 0010:nft_data_release+0xb7/0xe0 [nf_tables]
 [..]
 __nft_set_elem_destroy+0x106/0x380 [nf_tables]
 nf_tables_abort_release+0x348/0x8d0 [nf_tables]
 nf_tables_abort+0xcf2/0x3ac0 [nf_tables]
 nfnetlink_rcv_batch+0x9c9/0x20e0 [..]
Fixes 628bd3e49cba ("netfilter: nf_tables: drop map element references from preparation phase")

[ Backport to 5.15.y: 5.15 still passes a struct nft_set_elem to
nft_setelem_data_{de,}activate(); only the break statements are removed. ]

Assisted-by Claude:claude-opus-5-5

---
Straightforward: only the two break statements are removed; 5.15 still passes a struct nft_set_elem to nft_setelem_data_{de,}activate().

Build-tested on arm64; boot-tested under QEMU with KASAN: map with a catch-all element, batched update and flush run without KASAN reports.

 net/netfilter/nf_tables_api.c | 2 --
 1 file changed, 2 deletions(-)
net/netfilter/nf_tables_api.c +0 -2
index b5273255b738..ea7da306ffcc 100644
@@ -627,7 +627,6 @@ static void nft_map_catchall_deactivate(const struct nft_ctx *ctx,
 		elem.priv = catchall->elem;
 		nft_set_elem_change_active(ctx->net, set, ext);
 		nft_setelem_data_deactivate(ctx->net, set, &elem);
-		break;
 	}
 }
 
@@ -5172,7 +5171,6 @@ static void nft_map_catchall_activate(const struct nft_ctx *ctx,
 		nft_clear(ctx->net, ext);
 		elem.priv = catchall->elem;
 		nft_setelem_data_activate(ctx->net, set, &elem);
-		break;
 	}
 }
 
Signature · 1 line
2.50.1 (Apple Git-155)
maintainer Applied
#1 lore raw
Quoted 3 lines

During transaction processing we might have more than one catchall element:
1 live catchall element and 1 pending element that is coming as part of the new batch.

Queued for 5.15, thanks.

Signature · 2 lines
Thanks,
Sasha