From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <wanghai38@huawei.com>
Cc: <davem@davemloft.net>, <dsahern@kernel.org>,
<edumazet@google.com>, <horms@kernel.org>,
<kerneljasonxing@gmail.com>, <kuba@kernel.org>,
<kuniyu@amazon.com>, <linux-kernel@vger.kernel.org>,
<liujian56@huawei.com>, <ncardwell@google.com>,
<netdev@vger.kernel.org>, <pabeni@redhat.com>,
<yuehaibing@huawei.com>, <zhangchangzhong@huawei.com>
Subject: Re: [PATCH v3 net] tcp: Defer ts_recent changes until req is owned
Date: Tue, 25 Feb 2025 13:16:31 -0800 [thread overview]
Message-ID: <20250225211631.97380-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20250224090047.50748-1-wanghai38@huawei.com>
From: Wang Hai <wanghai38@huawei.com>
Date: Mon, 24 Feb 2025 17:00:47 +0800
> Recently a bug was discovered where the server had entered TCP_ESTABLISHED
> state, but the upper layers were not notified.
>
> The same 5-tuple packet may be processed by different CPUSs, so two
> CPUs may receive different ack packets at the same time when the
> state is TCP_NEW_SYN_RECV.
>
> In that case, req->ts_recent in tcp_check_req may be changed concurrently,
> which will probably cause the newsk's ts_recent to be incorrectly large.
> So that tcp_validate_incoming will fail. At this point, newsk will not be
> able to enter the TCP_ESTABLISHED.
>
> cpu1 cpu2
> tcp_check_req
> tcp_check_req
> req->ts_recent = rcv_tsval = t1
> req->ts_recent = rcv_tsval = t2
>
> syn_recv_sock
> tcp_sk(child)->rx_opt.ts_recent = req->ts_recent = t2 // t1 < t2
> tcp_child_process
> tcp_rcv_state_process
> tcp_validate_incoming
> tcp_paws_check
> if ((s32)(rx_opt->ts_recent - rx_opt->rcv_tsval) <= paws_win)
> // t2 - t1 > paws_win, failed
> tcp_v4_do_rcv
> tcp_rcv_state_process
> // TCP_ESTABLISHED
>
> The cpu2's skb or a newly received skb will call tcp_v4_do_rcv to get
> the newsk into the TCP_ESTABLISHED state, but at this point it is no
> longer possible to notify the upper layer application. A notification
> mechanism could be added here, but the fix is more complex, so the
> current fix is used.
>
> In tcp_check_req, req->ts_recent is used to assign a value to
> tcp_sk(child)->rx_opt.ts_recent, so removing the change in req->ts_recent
> and changing tcp_sk(child)->rx_opt.ts_recent directly after owning the
> req fixes this bug.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
next prev parent reply other threads:[~2025-02-25 21:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 9:00 [PATCH v3 net] tcp: Defer ts_recent changes until req is owned Wang Hai
2025-02-24 9:22 ` Eric Dumazet
2025-02-25 21:16 ` Kuniyuki Iwashima [this message]
2025-02-26 9:00 ` 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=20250225211631.97380-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liujian56@huawei.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wanghai38@huawei.com \
--cc=yuehaibing@huawei.com \
--cc=zhangchangzhong@huawei.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