{"id":2232016,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2232016/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/20260502075639.7440-4-fw@strlen.de/","project":{"id":26,"url":"http://patchwork.ozlabs.org/api/1.2/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,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260502075639.7440-4-fw@strlen.de>","list_archive_url":null,"date":"2026-05-02T07:56:37","name":"[nf,3/5] netfilter: x_tables: unregister the templates first","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"3571090512b4a4d9f669cb54f5a0896be2234baa","submitter":{"id":1025,"url":"http://patchwork.ozlabs.org/api/1.2/people/1025/?format=json","name":"Florian Westphal","email":"fw@strlen.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/20260502075639.7440-4-fw@strlen.de/mbox/","series":[{"id":502515,"url":"http://patchwork.ozlabs.org/api/1.2/series/502515/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/list/?series=502515","date":"2026-05-02T07:56:34","name":"netfilter: xtables: fix module unload and teardown races","version":1,"mbox":"http://patchwork.ozlabs.org/series/502515/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2232016/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2232016/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <netfilter-devel+bounces-12392-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=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org;\n envelope-from=netfilter-devel+bounces-12392-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 sin.lore.kernel.org (sin.lore.kernel.org\n [IPv6:2600:3c15:e001:75::12fc:5321])\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 4g70cK1Sbyz1yJ0\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 02 May 2026 17:57:05 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sin.lore.kernel.org (Postfix) with ESMTP id 1B6F0300681A\n\tfor <incoming@patchwork.ozlabs.org>; Sat,  2 May 2026 07:57:03 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 074AC2FFDF8;\n\tSat,  2 May 2026 07:57:02 +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 6D75D2E889C\n\tfor <netfilter-devel@vger.kernel.org>; Sat,  2 May 2026 07:57:00 +0000 (UTC)","by Chamillionaire.breakpoint.cc (Postfix, from userid 1003)\n\tid BEEA5606C8; Sat, 02 May 2026 09:56:58 +0200 (CEST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777708621; cv=none;\n b=aeWHmTotJ1XmC4lq5rGhqa9KMnbJGLB0R0IMGyFABM+YO9SGXw2xpV4AZ1WdAgcstOQGlgm+cijx/HY3EVJMTgIvL21yQsf82oHbThjxEKqMMTxkVXqbXnxtofxg0c5xpiOqjLUUw8ScKqKkzgfjX6ckpqTk95w6wb6f5M2t2Sk=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777708621; c=relaxed/simple;\n\tbh=U7BXTSfx4PguLleVIy5Zx9WwsgSKCYO6ILNolCwO0bs=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=BY5dQrGKhci3rSUZjhEYXTfA1wFw7krZYHwBi2wn2i3APlHlW4SAX1mlC7RUpHHNti7qKCHbOy5toF89aNYKGRQwZ+7vfLH5F0ra0UTiZhWguCjvTY8f5tJ4zD1vUCEilulXVCW6Div66UKkxaqgSiVWpkKxzXauSIWuERFxygE=","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":"tristan@talencesecurity.com,\n\tFlorian Westphal <fw@strlen.de>,\n\tTristan Madani <tristmd@gmail.com>","Subject":"[PATCH nf 3/5] netfilter: x_tables: unregister the templates first","Date":"Sat,  2 May 2026 09:56:37 +0200","Message-ID":"<20260502075639.7440-4-fw@strlen.de>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260502075639.7440-1-fw@strlen.de>","References":"<20260502075639.7440-1-fw@strlen.de>","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":"When the module is going away we need to zap the template\nfirst.  Else there is a small race window where userspace\ncould instantiate a new table after the pernet exit function\nhas removed the current table.\n\nFixes: fdacd57c79b7 (\"netfilter: x_tables: never register tables by default\")\nReported-by: Tristan Madani <tristmd@gmail.com>\nSigned-off-by: Florian Westphal <fw@strlen.de>\n---\n net/ipv4/netfilter/arptable_filter.c   | 2 +-\n net/ipv4/netfilter/iptable_filter.c    | 2 +-\n net/ipv4/netfilter/iptable_mangle.c    | 2 +-\n net/ipv4/netfilter/iptable_raw.c       | 2 +-\n net/ipv4/netfilter/iptable_security.c  | 2 +-\n net/ipv6/netfilter/ip6table_filter.c   | 2 +-\n net/ipv6/netfilter/ip6table_mangle.c   | 2 +-\n net/ipv6/netfilter/ip6table_raw.c      | 2 +-\n net/ipv6/netfilter/ip6table_security.c | 2 +-\n 9 files changed, 9 insertions(+), 9 deletions(-)","diff":"diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c\nindex 393d9a8c7739..382345567a60 100644\n--- a/net/ipv4/netfilter/arptable_filter.c\n+++ b/net/ipv4/netfilter/arptable_filter.c\n@@ -82,8 +82,8 @@ static int __init arptable_filter_init(void)\n \n static void __exit arptable_filter_fini(void)\n {\n-\tunregister_pernet_subsys(&arptable_filter_net_ops);\n \txt_unregister_template(&packet_filter);\n+\tunregister_pernet_subsys(&arptable_filter_net_ops);\n \tkfree(arpfilter_ops);\n }\n \ndiff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c\nindex b2fbd9651d61..0dea754a9120 100644\n--- a/net/ipv4/netfilter/iptable_filter.c\n+++ b/net/ipv4/netfilter/iptable_filter.c\n@@ -101,8 +101,8 @@ static int __init iptable_filter_init(void)\n \n static void __exit iptable_filter_fini(void)\n {\n-\tunregister_pernet_subsys(&iptable_filter_net_ops);\n \txt_unregister_template(&packet_filter);\n+\tunregister_pernet_subsys(&iptable_filter_net_ops);\n \tkfree(filter_ops);\n }\n \ndiff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c\nindex a99e61996197..4d3b12492308 100644\n--- a/net/ipv4/netfilter/iptable_mangle.c\n+++ b/net/ipv4/netfilter/iptable_mangle.c\n@@ -135,8 +135,8 @@ static int __init iptable_mangle_init(void)\n \n static void __exit iptable_mangle_fini(void)\n {\n-\tunregister_pernet_subsys(&iptable_mangle_net_ops);\n \txt_unregister_template(&packet_mangler);\n+\tunregister_pernet_subsys(&iptable_mangle_net_ops);\n \tkfree(mangle_ops);\n }\n \ndiff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c\nindex 42511721e538..6f7afec7954b 100644\n--- a/net/ipv4/netfilter/iptable_raw.c\n+++ b/net/ipv4/netfilter/iptable_raw.c\n@@ -100,9 +100,9 @@ static int __init iptable_raw_init(void)\n \n static void __exit iptable_raw_fini(void)\n {\n+\txt_unregister_template(&packet_raw);\n \tunregister_pernet_subsys(&iptable_raw_net_ops);\n \tkfree(rawtable_ops);\n-\txt_unregister_template(&packet_raw);\n }\n \n module_init(iptable_raw_init);\ndiff --git a/net/ipv4/netfilter/iptable_security.c b/net/ipv4/netfilter/iptable_security.c\nindex 4646bf6d7d2b..81175c20ccbe 100644\n--- a/net/ipv4/netfilter/iptable_security.c\n+++ b/net/ipv4/netfilter/iptable_security.c\n@@ -89,9 +89,9 @@ static int __init iptable_security_init(void)\n \n static void __exit iptable_security_fini(void)\n {\n+\txt_unregister_template(&security_table);\n \tunregister_pernet_subsys(&iptable_security_net_ops);\n \tkfree(sectbl_ops);\n-\txt_unregister_template(&security_table);\n }\n \n module_init(iptable_security_init);\ndiff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c\nindex f05a9e4b2c67..cf561919bde8 100644\n--- a/net/ipv6/netfilter/ip6table_filter.c\n+++ b/net/ipv6/netfilter/ip6table_filter.c\n@@ -100,8 +100,8 @@ static int __init ip6table_filter_init(void)\n \n static void __exit ip6table_filter_fini(void)\n {\n-\tunregister_pernet_subsys(&ip6table_filter_net_ops);\n \txt_unregister_template(&packet_filter);\n+\tunregister_pernet_subsys(&ip6table_filter_net_ops);\n \tkfree(filter_ops);\n }\n \ndiff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c\nindex afa4a5703e43..1a758f2bc537 100644\n--- a/net/ipv6/netfilter/ip6table_mangle.c\n+++ b/net/ipv6/netfilter/ip6table_mangle.c\n@@ -128,8 +128,8 @@ static int __init ip6table_mangle_init(void)\n \n static void __exit ip6table_mangle_fini(void)\n {\n-\tunregister_pernet_subsys(&ip6table_mangle_net_ops);\n \txt_unregister_template(&packet_mangler);\n+\tunregister_pernet_subsys(&ip6table_mangle_net_ops);\n \tkfree(mangle_ops);\n }\n \ndiff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c\nindex 32d2da81c52a..923455921c1d 100644\n--- a/net/ipv6/netfilter/ip6table_raw.c\n+++ b/net/ipv6/netfilter/ip6table_raw.c\n@@ -98,8 +98,8 @@ static int __init ip6table_raw_init(void)\n \n static void __exit ip6table_raw_fini(void)\n {\n-\tunregister_pernet_subsys(&ip6table_raw_net_ops);\n \txt_unregister_template(&packet_raw);\n+\tunregister_pernet_subsys(&ip6table_raw_net_ops);\n \tkfree(rawtable_ops);\n }\n \ndiff --git a/net/ipv6/netfilter/ip6table_security.c b/net/ipv6/netfilter/ip6table_security.c\nindex 3dfd8d6ea4b9..c44834d93fc7 100644\n--- a/net/ipv6/netfilter/ip6table_security.c\n+++ b/net/ipv6/netfilter/ip6table_security.c\n@@ -88,8 +88,8 @@ static int __init ip6table_security_init(void)\n \n static void __exit ip6table_security_fini(void)\n {\n-\tunregister_pernet_subsys(&ip6table_security_net_ops);\n \txt_unregister_template(&security_table);\n+\tunregister_pernet_subsys(&ip6table_security_net_ops);\n \tkfree(sectbl_ops);\n }\n \n","prefixes":["nf","3/5"]}