{"id":2223623,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2223623/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/20260415191837.21663-1-fw@strlen.de/","project":{"id":26,"url":"http://patchwork.ozlabs.org/api/1.1/projects/26/?format=json","name":"Netfilter Development","link_name":"netfilter-devel","list_id":"netfilter-devel.vger.kernel.org","list_email":"netfilter-devel@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260415191837.21663-1-fw@strlen.de>","date":"2026-04-15T19:18:33","name":"[nf] netfilter: nf_tables: use list_del_rcu for netlink hooks","commit_ref":null,"pull_url":null,"state":"superseded","archived":true,"hash":"2eab15c5b5fcf7fe7f949ed4685a57122659c327","submitter":{"id":1025,"url":"http://patchwork.ozlabs.org/api/1.1/people/1025/?format=json","name":"Florian Westphal","email":"fw@strlen.de"},"delegate":{"id":11902,"url":"http://patchwork.ozlabs.org/api/1.1/users/11902/?format=json","username":"strlen","first_name":"Florian","last_name":"Westphal","email":"fw@strlen.de"},"mbox":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/20260415191837.21663-1-fw@strlen.de/mbox/","series":[{"id":500034,"url":"http://patchwork.ozlabs.org/api/1.1/series/500034/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/list/?series=500034","date":"2026-04-15T19:18:33","name":"[nf] netfilter: nf_tables: use list_del_rcu for netlink hooks","version":1,"mbox":"http://patchwork.ozlabs.org/series/500034/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223623/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223623/checks/","tags":{},"headers":{"Return-Path":"\n <netfilter-devel+bounces-11935-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","netfilter-devel@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=netfilter-devel+bounces-11935-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=91.216.245.30","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=strlen.de","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=Chamillionaire.breakpoint.cc"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fwrZC237Qz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 05:20:03 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 7EF5A3072619\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 19:18:46 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 1EAD8384254;\n\tWed, 15 Apr 2026 19:18:46 +0000 (UTC)","from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc\n [91.216.245.30])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E9061DED40\n\tfor <netfilter-devel@vger.kernel.org>; Wed, 15 Apr 2026 19:18:44 +0000 (UTC)","by Chamillionaire.breakpoint.cc (Postfix, from userid 1003)\n\tid E4F2E60640; Wed, 15 Apr 2026 21:18:41 +0200 (CEST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776280725; cv=none;\n b=PbOMFe+vJwnb5fd3aHia10VCSoB7y2UQ06vXalSB2Oj6DmWhCVYiEKpoRpshbx51s19/XylqOYBNliYy71tgKg4T0GEKNmOsW8X+m+E9i7bbpPoV50+sHD8NUNemmU2husNJr6IybOKtOX/qlX1jqj5k3EhqU2wFBQ9pjrksws8=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776280725; c=relaxed/simple;\n\tbh=Nk/0BYekiXYE1BQz+V5PgegkBrqZ26wMKA3K/zSmOOA=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=hRVwG6ndV+u2UfCwxLVTK+KL+l2IxS5uCNj3VnAPQJR3XguJVaSycy9qCuN005IFGQVDhg4bi0XdPk9+HNbt7ckrwe8DazFIZ+MRtKAFTaWSCaVxAfQ9+FwEu3+V26Jhq5oXX98cnI5fJWt3DiNm7JFPhlsdLtZlY6rViXQa6ow=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=strlen.de;\n spf=pass smtp.mailfrom=Chamillionaire.breakpoint.cc;\n arc=none smtp.client-ip=91.216.245.30","From":"Florian Westphal <fw@strlen.de>","To":"<netfilter-devel@vger.kernel.org>","Cc":"Florian Westphal <fw@strlen.de>","Subject":"[PATCH nf] netfilter: nf_tables: use list_del_rcu for netlink hooks","Date":"Wed, 15 Apr 2026 21:18:33 +0200","Message-ID":"<20260415191837.21663-1-fw@strlen.de>","X-Mailer":"git-send-email 2.52.0","Precedence":"bulk","X-Mailing-List":"netfilter-devel@vger.kernel.org","List-Id":"<netfilter-devel.vger.kernel.org>","List-Subscribe":"<mailto:netfilter-devel+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:netfilter-devel+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"nft_netdev_unregister_hooks and __nft_unregister_flowtable_net_hooks need\nto use list_del_rcu(), this list can be walked by concurrent dumpers.\n\nAdd a new helper and use it consistently.\n\nFixes: f9a43007d3f7 (\"netfilter: nf_tables: double hook unregistration in netns path\")\nSigned-off-by: Florian Westphal <fw@strlen.de>\n---\n Sorry for late send, this was spotted by LLM after re-prompting\n based on findings from a different patch.\n\n net/netfilter/nf_tables_api.c | 44 ++++++++++++++---------------------\n 1 file changed, 18 insertions(+), 26 deletions(-)","diff":"diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c\nindex 8c42247a176c..090d4d688a33 100644\n--- a/net/netfilter/nf_tables_api.c\n+++ b/net/netfilter/nf_tables_api.c\n@@ -374,6 +374,12 @@ static void nft_netdev_hook_free_rcu(struct nft_hook *hook)\n \tcall_rcu(&hook->rcu, __nft_netdev_hook_free_rcu);\n }\n \n+static void nft_netdev_hook_unlink_free_rcu(struct nft_hook *hook)\n+{\n+\tlist_del_rcu(&hook->list);\n+\tnft_netdev_hook_free_rcu(hook);\n+}\n+\n static void nft_netdev_unregister_hooks(struct net *net,\n \t\t\t\t\tstruct list_head *hook_list,\n \t\t\t\t\tbool release_netdev)\n@@ -384,10 +390,8 @@ static void nft_netdev_unregister_hooks(struct net *net,\n \tlist_for_each_entry_safe(hook, next, hook_list, list) {\n \t\tlist_for_each_entry(ops, &hook->ops_list, list)\n \t\t\tnf_unregister_net_hook(net, ops);\n-\t\tif (release_netdev) {\n-\t\t\tlist_del(&hook->list);\n-\t\t\tnft_netdev_hook_free_rcu(hook);\n-\t\t}\n+\t\tif (release_netdev)\n+\t\t\tnft_netdev_hook_unlink_free_rcu(hook);\n \t}\n }\n \n@@ -2323,10 +2327,8 @@ void nf_tables_chain_destroy(struct nft_chain *chain)\n \n \t\tif (nft_base_chain_netdev(table->family, basechain->ops.hooknum)) {\n \t\t\tlist_for_each_entry_safe(hook, next,\n-\t\t\t\t\t\t &basechain->hook_list, list) {\n-\t\t\t\tlist_del_rcu(&hook->list);\n-\t\t\t\tnft_netdev_hook_free_rcu(hook);\n-\t\t\t}\n+\t\t\t\t\t\t &basechain->hook_list, list)\n+\t\t\t\tnft_netdev_hook_unlink_free_rcu(hook);\n \t\t}\n \t\tmodule_put(basechain->type->owner);\n \t\tif (rcu_access_pointer(basechain->stats)) {\n@@ -3026,6 +3028,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,\n \t\t\t\tlist_for_each_entry(ops, &h->ops_list, list)\n \t\t\t\t\tnf_unregister_net_hook(ctx->net, ops);\n \t\t\t}\n+\t\t\t/* hook.list is on stack, no need for list_del_rcu() */\n \t\t\tlist_del(&h->list);\n \t\t\tnft_netdev_hook_free_rcu(h);\n \t\t}\n@@ -8903,10 +8906,8 @@ static void __nft_unregister_flowtable_net_hooks(struct net *net,\n \tlist_for_each_entry_safe(hook, next, hook_list, list) {\n \t\tlist_for_each_entry(ops, &hook->ops_list, list)\n \t\t\tnft_unregister_flowtable_ops(net, flowtable, ops);\n-\t\tif (release_netdev) {\n-\t\t\tlist_del(&hook->list);\n-\t\t\tnft_netdev_hook_free_rcu(hook);\n-\t\t}\n+\t\tif (release_netdev)\n+\t\t\tnft_netdev_hook_unlink_free_rcu(hook);\n \t}\n }\n \n@@ -8977,8 +8978,7 @@ static int nft_register_flowtable_net_hooks(struct net *net,\n \n \t\t\tnft_unregister_flowtable_ops(net, flowtable, ops);\n \t\t}\n-\t\tlist_del_rcu(&hook->list);\n-\t\tnft_netdev_hook_free_rcu(hook);\n+\t\tnft_netdev_hook_unlink_free_rcu(hook);\n \t}\n \n \treturn err;\n@@ -8988,10 +8988,8 @@ static void nft_hooks_destroy(struct list_head *hook_list)\n {\n \tstruct nft_hook *hook, *next;\n \n-\tlist_for_each_entry_safe(hook, next, hook_list, list) {\n-\t\tlist_del_rcu(&hook->list);\n-\t\tnft_netdev_hook_free_rcu(hook);\n-\t}\n+\tlist_for_each_entry_safe(hook, next, hook_list, list)\n+\t\tnft_netdev_hook_unlink_free_rcu(hook);\n }\n \n static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,\n@@ -9079,8 +9077,7 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,\n \t\t\t\tnft_unregister_flowtable_ops(ctx->net,\n \t\t\t\t\t\t\t     flowtable, ops);\n \t\t}\n-\t\tlist_del_rcu(&hook->list);\n-\t\tnft_netdev_hook_free_rcu(hook);\n+\t\tnft_netdev_hook_unlink_free_rcu(hook);\n \t}\n \n \treturn err;\n@@ -9586,13 +9583,8 @@ static void nf_tables_flowtable_notify(struct nft_ctx *ctx,\n \n static void nf_tables_flowtable_destroy(struct nft_flowtable *flowtable)\n {\n-\tstruct nft_hook *hook, *next;\n-\n \tflowtable->data.type->free(&flowtable->data);\n-\tlist_for_each_entry_safe(hook, next, &flowtable->hook_list, list) {\n-\t\tlist_del_rcu(&hook->list);\n-\t\tnft_netdev_hook_free_rcu(hook);\n-\t}\n+\tnft_hooks_destroy(&flowtable->hook_list);\n \tkfree(flowtable->name);\n \tmodule_put(flowtable->data.type->owner);\n \tkfree(flowtable);\n","prefixes":["nf"]}