From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: Eric Dumazet <edumazet@google.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, Ido Schimmel <idosch@nvidia.com>,
David Ahern <dsahern@kernel.org>,
eric.dumazet@gmail.com, Ji'an Zhou <eilaimemedsnaimel@gmail.com>,
Cong Wang <xiyou.wangcong@gmail.com>
Subject: Re: [PATCH net] ipv4: free net->ipv4.sysctl_local_reserved_ports after unregister_net_sysctl_table()
Date: Thu, 21 May 2026 21:59:20 +0800 [thread overview]
Message-ID: <0ef1f7da-c5b3-4c91-a656-4a3efecbbaf2@linux.dev> (raw)
In-Reply-To: <20260521122147.3584624-1-edumazet@google.com>
On 5/21/26 8:21 PM, Eric Dumazet wrote:
> ipv4_sysctl_exit_net() is currently freeing net->ipv4.sysctl_local_reserved_ports
> too soon.
>
> Only after unregister_net_sysctl_table() we can be sure no threads can possibly
> use the sysctls, including /proc/sys/net/ipv4/ip_local_reserved_ports.
>
> Fixes: 122ff243f5f1 ("ipv4: make ip_local_reserved_ports per netns")
> Reported-by: Ji'an Zhou <eilaimemedsnaimel@gmail.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Cong Wang <xiyou.wangcong@gmail.com>
> ---
> net/ipv4/sysctl_net_ipv4.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
> index d8bdb1bdbff17ab52fe969b93ce13673e88c05a4..c0e85cc171aec099fd5d4897b1a623dd27eaee08 100644
> --- a/net/ipv4/sysctl_net_ipv4.c
> +++ b/net/ipv4/sysctl_net_ipv4.c
> @@ -1705,10 +1705,10 @@ static __net_exit void ipv4_sysctl_exit_net(struct net *net)
> {
> const struct ctl_table *table;
>
> - kfree(net->ipv4.sysctl_local_reserved_ports);
> table = net->ipv4.ipv4_hdr->ctl_table_arg;
> unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
> kfree(table);
> + kfree(net->ipv4.sysctl_local_reserved_ports);
> }
>
> static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
If there are still processes in the namespace, the netns refcnt cannot
become 0,
so I think it should be: first open
/proc/sys/net/ipv4/ip_local_reserved_ports, then pass
the fd to another process outside the netns? Maybe SCM_RIGHTS is used?
next prev parent reply other threads:[~2026-05-21 13:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 12:21 [PATCH net] ipv4: free net->ipv4.sysctl_local_reserved_ports after unregister_net_sysctl_table() Eric Dumazet
2026-05-21 13:13 ` Jason Xing
2026-05-21 13:59 ` Jiayuan Chen [this message]
2026-05-21 14:39 ` Eric Dumazet
2026-05-23 2:20 ` patchwork-bot+netdevbpf
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=0ef1f7da-c5b3-4c91-a656-4a3efecbbaf2@linux.dev \
--to=jiayuan.chen@linux.dev \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=eilaimemedsnaimel@gmail.com \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=xiyou.wangcong@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.