From: Matthieu Baerts <matttbe@kernel.org>
To: Kuniyuki Iwashima <kuniyu@google.com>
Cc: Eric Dumazet <edumazet@kernel.org>,
Neal Cardwell <ncardwell@google.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Yuchung Cheng <ycheng@google.com>, Wei Wang <weiwan@google.com>,
Mat Martineau <martineau@kernel.org>,
Geliang Tang <geliang@kernel.org>,
Simon Horman <horms@kernel.org>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH v1 net 1/3] tcp: Clear DEFER_CONNECT before tcp_connect() and in tcp_abort().
Date: Tue, 10 Nov 2026 19:46:19 +0100 [thread overview]
Message-ID: <8362f907-4e8e-4514-bff6-f0bf8fd22f57@kernel.org> (raw)
In-Reply-To: <20261107235720.3129212-2-kuniyu@google.com>
Hi Kuniyuki,
On 08/11/2026 00:56, Kuniyuki Iwashima wrote:
> When TFO is enabled, tcp_v[46]_connect() sets sk->sk_state to
> TCP_SYN_SENT and puts the socket into ehash without calling
> tcp_connect().
>
> Then, tcp_fastopen_defer_connect() sets DEFER_CONNECT, and
> the first write()/sendmsg() will call tcp_connect() and send
> SYN with data if possible.
>
> If tcp_abort() kills a socket before the first write()/sendmsg(),
> the unhashed socket can still call it and send SYN in TCP_CLOSE.
>
> Also, DEFER_CONNECT is cleared after __inet_stream_connect().
>
> So, blocking write()/sendmsg() can release lock_sock() in
> inet_wait_for_connect() while DEFER_CONNECT is set, and
> tcp_poll() could set EPOLLOUT even after SYN is sent.
>
> Let's clear DEFER_CONNECT in tcp_abort() and right before
> tcp_connect() in tcp_sendmsg_fastopen().
Thank you for the fix!
It looks like we can still have the race with MPTCP:
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261107235720.3129212-1-kuniyu%40google.com
But that's not blocking this series here, so for the MPTCP part:
Acked-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Just to avoid a deadlock, are you planning to fix the issue on MPTCP
side as well? If not, I can look at that later on when I can.
(Perhaps by checking if the msk and ssk's DEFER_CONNECT flag is no
longer aligned in mptcp_sendmsg_fastopen(), under the ssk lock? If not,
clear the msk one, report the error, release the lock and return? BTW,
it looks like we also forgot to clear the DEFER_CONNECT flag in
mptcp_disconnect() as well...)
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2026-11-10 18:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 23:56 [PATCH v1 net 0/3] tcp: Small fixes for DEFER_CONNECT Kuniyuki Iwashima
2026-11-07 23:56 ` [PATCH v1 net 1/3] tcp: Clear DEFER_CONNECT before tcp_connect() and in tcp_abort() Kuniyuki Iwashima
2026-11-10 18:46 ` Matthieu Baerts [this message]
2026-11-10 19:12 ` Kuniyuki Iwashima
2026-11-10 19:14 ` Matthieu Baerts
2026-11-07 23:56 ` [PATCH v1 net 2/3] tcp: Drop any segments if DEFER_CONNECT is set Kuniyuki Iwashima
2026-11-07 23:56 ` [PATCH v1 net 3/3] selftest: packetdrill: Add test for DEFER_CONNECT Kuniyuki Iwashima
2026-11-11 22:12 ` [PATCH v1 net 0/3] tcp: Small fixes " 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=8362f907-4e8e-4514-bff6-f0bf8fd22f57@kernel.org \
--to=matttbe@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@google.com \
--cc=martineau@kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=weiwan@google.com \
--cc=ycheng@google.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