CVE-2026-23231: netfilter: nf_tables: fix use-after-free in nf_tables_addchain()
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
netfilter: nf_tables: fix use-after-free in nf_tables_addchain()
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.
The Linux kernel CVE team has assigned CVE-2026-23231 to this issue.
Affected and fixed versions
===========================
Issue introduced in 3.16 with commit 91c7b38dc9f0de4f7f444b796d14476bc12df7bc and fixed in 6.18.14 with commit dbd0af8083dd201f07c49110b2ee93710abdff28 Issue introduced in 3.16 with commit 91c7b38dc9f0de4f7f444b796d14476bc12df7bc and fixed in 6.19.4 with commit 2f9a4ffeb763aec822f8ff3d1e82202d27d46d4b Issue introduced in 3.16 with commit 91c7b38dc9f0de4f7f444b796d14476bc12df7bc and fixed in 7.0-rc1 with commit 71e99ee20fc3f662555118cf1159443250647533
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2026-23231
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
net/netfilter/nf_tables_api.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/dbd0af8083dd201f07c49110b2ee93710abdff28 https://git.kernel.org/stable/c/2f9a4ffeb763aec822f8ff3d1e82202d27d46d4b https://git.kernel.org/stable/c/71e99ee20fc3f662555118cf1159443250647533