From: Julian Anastasov <ja@ssi.bg>
To: Slavin Liu <slavin452@gmail.com>
Cc: Simon Horman <horms@verge.net.au>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
lvs-devel@vger.kernel.org, netdev@vger.kernel.org,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] ipvs: Defer ip_vs_ftp unregister during netns cleanup
Date: Sat, 13 Sep 2025 20:23:04 +0300 (EEST) [thread overview]
Message-ID: <0effae4a-4b9d-552e-5de7-756af4627451@ssi.bg> (raw)
In-Reply-To: <20250911175759.474-1-slavin452@gmail.com>
Hello,
On Fri, 12 Sep 2025, Slavin Liu wrote:
> On the netns cleanup path, __ip_vs_ftp_exit() may unregister ip_vs_ftp
> before connections with valid cp->app pointers are flushed, leading to a
> use-after-free.
>
> Fix this by introducing a global `exiting_module` flag, set to true in
> ip_vs_ftp_exit() before unregistering the pernet subsystem. In
> __ip_vs_ftp_exit(), skip ip_vs_ftp unregister if called during netns
> cleanup (when module_removing is false) and defer it to
Pablo, can you change here module_removing to exiting_module
before applying?
> __ip_vs_cleanup_batch(), which unregisters all apps after all connections
> are flushed. If called during module exit, unregister ip_vs_ftp
> immediately.
>
> Fixes: 61b1ab4583e2 ("IPVS: netns, add basic init per netns.")
> Suggested-by: Julian Anastasov <ja@ssi.bg>
> Signed-off-by: Slavin Liu <slavin452@gmail.com>
Looks good to me for the nf tree after above text is
changed, thanks!
Signed-off-by: Julian Anastasov <ja@ssi.bg>
> ---
> net/netfilter/ipvs/ip_vs_ftp.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
> index d8a284999544..206c6700e200 100644
> --- a/net/netfilter/ipvs/ip_vs_ftp.c
> +++ b/net/netfilter/ipvs/ip_vs_ftp.c
> @@ -53,6 +53,7 @@ enum {
> IP_VS_FTP_EPSV,
> };
>
> +static bool exiting_module;
> /*
> * List of ports (up to IP_VS_APP_MAX_PORTS) to be handled by helper
> * First port is set to the default port.
> @@ -605,7 +606,7 @@ static void __ip_vs_ftp_exit(struct net *net)
> {
> struct netns_ipvs *ipvs = net_ipvs(net);
>
> - if (!ipvs)
> + if (!ipvs || !exiting_module)
> return;
>
> unregister_ip_vs_app(ipvs, &ip_vs_ftp);
> @@ -627,6 +628,7 @@ static int __init ip_vs_ftp_init(void)
> */
> static void __exit ip_vs_ftp_exit(void)
> {
> + exiting_module = true;
> unregister_pernet_subsys(&ip_vs_ftp_ops);
> /* rcu_barrier() is called by netns */
> }
> --
> 2.34.1
Regards
--
Julian Anastasov <ja@ssi.bg>
next prev parent reply other threads:[~2025-09-13 17:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 6:54 [PATCH 1/1] IPVS: Fix use-after-free issue in ip_vs_unbind_app() Slavin Liu
2025-09-09 15:15 ` Julian Anastasov
2025-09-09 21:21 ` [PATCH v2] ipvs: Check ipvs->enable before unregistration in __ip_vs_ftp_exit() Slavin Liu
2025-09-10 9:39 ` Julian Anastasov
2025-09-11 14:40 ` [RFC PATCH v3] ipvs: Defer ip_vs_ftp unregister during netns cleanup Slavin Liu
2025-09-11 17:57 ` [PATCH v4] " Slavin Liu
2025-09-13 17:23 ` Julian Anastasov [this message]
2025-09-13 21:07 ` Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0effae4a-4b9d-552e-5de7-756af4627451@ssi.bg \
--to=ja@ssi.bg \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=horms@verge.net.au \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvs-devel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=slavin452@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®