Skip to contentSkip to conversation

netfilter: nf_tables: only disable tables on a dormant transition

PATCH Superseded Ma Xinmeng 1 participant 1 message Nov 24

Subsystems (3)
lore
Share & tools
lore

Ma Xinmeng

author
#0 lore raw

v3 cover netfilter: nf_tables: only disable tables on a dormant transition

Hi,

This is v3 of the fix. v2 included a selftest in the kernel tree; review asked to move it to nftables.git as a shell test under tests/shell/testcases/transactions/, where run-tests.sh already handles the tainted-kernel check. v3 keeps only the one-line kernel fix; the test is sent separately as [PATCH nft] (0052dormant_table_adopt_0).

The problem is unchanged. A dormant table has no registered basechain hooks. Re-owning an already dormant PERSIST orphan sets __NFT_TABLE_F_UPDATE because of the adoption, and nf_tables_commit() used to call nf_tables_table_disable() for it. That cleared DORMANT, walked the chains, and unregistered a hook that was never registered, triggering WARN_ONCE("hook not found") in __nf_unregister_net_hook().

v3 only changes the NEWTABLE commit path to check __NFT_TABLE_F_WAS_AWAKEN, which records a real awake-to-dormant transition:

- if (table->flags & NFT_TABLE_F_DORMANT)
+ if (table->flags & __NFT_TABLE_F_WAS_AWAKEN)

      nf_tables_table_disable(net, table);

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 v2 code was A/B tested on 7.4.0-rc3: baseline WARN, patched no WARN, and a real awake-to-dormant transition still disables the hook.

Changes in v3:
- drop the kernel selftest; no change to the one-line fix
- move the test to nftables.git as a separate [PATCH nft]
- keep Fixes: 31bf508be656 ("netfilter: nf_tables: Implement table adoption support")

Thanks,
Ma Xinmeng

Ma Xinmeng (1):
netfilter: nf_tables: only disable tables on a dormant transition

 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.56.0.windows.4.niugit