Netdev List
 help / color / mirror / Atom feed
* [PATCH nf v2 0/2] netfilter: nf_tables: only disable tables on a dormant transition
@ 2026-11-17 16:14 Ma Xinmeng
  2026-11-18 10:08 ` Xuanqiang Luo
  0 siblings, 1 reply; 2+ messages in thread
From: Ma Xinmeng @ 2026-11-17 16:14 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Florian Westphal; +Cc: netfilter-devel, netdev, Phil Sutter

Hi,

This is v2 of the fix for the nftables WARN below. v1 was sent as
[PATCH net] and tracked a per-basechain "registered" flag. Xuanqiang
suggested fixing the commit condition instead: a dormant table never has
a registered basechain hook, and nf_tables_commit() should not call
nf_tables_table_disable() for a table that is already dormant.

v2 drops the new field and changes only the NEWTABLE commit path:

- if (table->flags & NFT_TABLE_F_DORMANT)
+ if (table->flags & __NFT_TABLE_F_WAS_AWAKEN)
      nf_tables_table_disable(net, table);

__NFT_TABLE_F_WAS_AWAKEN records a real awake-to-dormant transition.
Since table adoption added __NFT_TABLE_F_WAS_ORPHAN, __NFT_TABLE_F_UPDATE
can be set for an adoption that leaves the table dormant, so the old
check disabled the table and unregistered a hook that was never
registered.

The WARN was found by FuzzAnything's AI-assisted kernel fuzzer while
fuzzing nftables netlink messages in a user and network namespace, and
I reproduced it at runtime on 7.3.0-rc4, 7.3.1, 7.4-rc1, 7.4-rc2, and
7.4-rc3. The baseline 7.4-rc3 dmesg is:

  hook not found, pf 2 num 3
  WARNING: net/netfilter/core.c:522 at __nf_unregister_net_hook+0x71/0x1b0
  Call Trace:
    nft_table_disable+0x78/0xa0
    nf_tables_commit+0x1c03/0x1ec0
    nfnetlink_rcv_batch+0x939/0xaf0

v2 was tested on 7.4.0-rc3-c027fixv2: the PoC returns 0 and dmesg has no
WARN. I also checked a real awake-to-dormant transition: after the table
became dormant, a ping left the basechain counter at 0, so the hook was
still unregistered correctly.

Changes in v2:
- remove the per-basechain registered field
- check __NFT_TABLE_F_WAS_AWAKEN instead of NFT_TABLE_F_DORMANT
- add Fixes: 31bf508be656 ("netfilter: nf_tables: Implement table adoption support")
- use [PATCH nf] as requested
- add a selftest as 2/2

The selftest uses the nft owner/persist table flags to create the
dormant orphan, and checks the kernel taint state rather than parsing
dmesg. It fails on unpatched 7.4-rc3 and passes on v2.

Thanks,
Ma Xinmeng

Ma Xinmeng (2):
  netfilter: nf_tables: only disable tables on a dormant transition
  selftests: netfilter: test re-owning an already dormant table

 net/netfilter/nf_tables_api.c                 |  2 +-
 .../testing/selftests/net/netfilter/Makefile  |  1 +
 .../net/netfilter/nft_table_dormant_adopt.sh  | 57 +++++++++++++++++++
 3 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100755 tools/testing/selftests/net/netfilter/nft_table_dormant_adopt.sh

-- 
2.56.0.windows.4.niugit


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

end of thread, other threads:[~2026-11-18 10:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 16:14 [PATCH nf v2 0/2] netfilter: nf_tables: only disable tables on a dormant transition Ma Xinmeng
2026-11-18 10:08 ` Xuanqiang Luo

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