From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <kerneljasonxing@gmail.com>
Cc: <0x7f454c46@gmail.com>, <davem@davemloft.net>, <dima@arista.com>,
<dsahern@kernel.org>, <edumazet@google.com>, <fw@strlen.de>,
<kernelxing@tencent.com>, <kuba@kernel.org>, <kuniyu@amazon.com>,
<ncardwell@google.com>, <netdev@vger.kernel.org>,
<pabeni@redhat.com>, <pablo@netfilter.org>
Subject: Re: [PATCH net-next] tcp: do not allow to connect with the four-tuple symmetry socket
Date: Mon, 19 Aug 2024 10:56:14 -0700 [thread overview]
Message-ID: <20240819175614.14990-1-kuniyu@amazon.com> (raw)
In-Reply-To: <CAL+tcoCZQdU5H3c88g3MMoBRxvMTC81HaVzKF4TL=mA53arwWw@mail.gmail.com>
From: Jason Xing <kerneljasonxing@gmail.com>
Date: Mon, 19 Aug 2024 17:41:32 +0800
> On Mon, Aug 19, 2024 at 5:38 PM Eric Dumazet <edumazet@google.com> wrote:
> >
> > On Mon, Aug 19, 2024 at 11:32 AM Jason Xing <kerneljasonxing@gmail.com> wrote:
> >
> > > After investigating such an issue more deeply in the customers'
> > > machines, the main reason why it can happen is the listener exits
> > > while another thread starts to connect, which can cause
> > > self-connection, even though the chance is slim. Later, the listener
> > > tries to listen and for sure it will fail due to that single
> > > self-connection.
> >
> > This would happen if the range of ephemeral ports include the listening port,
> > which is discouraged.
>
> Yes.
>
> >
> > ip_local_reserved_ports is supposed to help.
>
> Sure, I workarounded it by using this and it worked.
>
> >
> > This looks like a security issue to me, and netfilter can handle it.
>
> I have to admit setting netfilter rules for each flow is not a very
> user-friendly way.
I think even netfilter is not needed.
It sounds like the server application needs to implement graceful shutdown.
The server should not release the port if there are on-going clients. The
server should spin up a new process and use the following to transfer the
remaining connections:
* FD passing
* SO_REUSEPORT w/ (net.ipv4.tcp_migrate_req or BPF)
Then, no client can occupy the server's port even without
ip_local_reserved_ports.
But I still recommend using ip_local_reserved_ports unless the server port
is random.
next prev parent reply other threads:[~2024-08-19 17:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-18 4:25 [PATCH net-next] tcp: do not allow to connect with the four-tuple symmetry socket Jason Xing
2024-08-18 5:16 ` Jason Xing
2024-08-18 13:50 ` Jason Xing
2024-08-18 18:48 ` Kuniyuki Iwashima
2024-08-18 23:48 ` Jason Xing
2024-08-19 0:26 ` Jason Xing
2024-08-19 7:30 ` Eric Dumazet
2024-08-19 9:01 ` Jason Xing
2024-08-19 9:18 ` Eric Dumazet
2024-08-19 9:31 ` Jason Xing
2024-08-19 9:38 ` Eric Dumazet
2024-08-19 9:41 ` Jason Xing
2024-08-19 17:56 ` Kuniyuki Iwashima [this message]
2024-08-20 0:29 ` Jason Xing
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=20240819175614.14990-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=0x7f454c46@gmail.com \
--cc=davem@davemloft.net \
--cc=dima@arista.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kerneljasonxing@gmail.com \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
/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