Skip to content

Commit e8b19b9

Browse files
CIQ Kernel Automationroxanan1996
authored andcommitted
netfilter: nf_tables: fix use-after-free in nf_tables_addchain()
jira VULN-177697 cve CVE-2026-23231 commit-author Inseo An <y0un9sa@gmail.com> commit 71e99ee nf_tables_addchain() publishes the chain to table->chains via list_add_tail_rcu() (in nft_chain_add()) before registering hooks. If nf_tables_register_hook() then fails, the error path calls nft_chain_del() (list_del_rcu()) followed by nf_tables_chain_destroy() with no RCU grace period in between. This creates two use-after-free conditions: 1) Control-plane: nf_tables_dump_chains() traverses table->chains under rcu_read_lock(). A concurrent dump can still be walking the chain when the error path frees it. 2) Packet path: for NFPROTO_INET, nf_register_net_hook() briefly installs the IPv4 hook before IPv6 registration fails. Packets entering nft_do_chain() via the transient IPv4 hook can still be dereferencing chain->blob_gen_X when the error path frees the chain. Add synchronize_rcu() between nft_chain_del() and the chain destroy so that all RCU readers -- both dump threads and in-flight packet evaluation -- have finished before the chain is freed. Fixes: 91c7b38 ("netfilter: nf_tables: use new transaction infrastructure to handle chain") Signed-off-by: Inseo An <y0un9sa@gmail.com> Signed-off-by: Florian Westphal <fw@strlen.de> (cherry picked from commit 71e99ee) Signed-off-by: CIQ Kernel Automation <ciq_kernel_automation@ciq.com>
1 parent 6aebf64 commit e8b19b9

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,6 +2479,7 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
24792479

24802480
err_register_hook:
24812481
nft_chain_del(chain);
2482+
synchronize_rcu();
24822483
err_chain_add:
24832484
nft_trans_destroy(trans);
24842485
err_trans:

0 commit comments

Comments
 (0)