lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f3b279ea-92c3-457f-915a-2f4963746838@huawei.com>
Date: Wed, 19 Feb 2025 10:16:29 +0800
From: Wang Hai <wanghai38@...wei.com>
To: Eric Dumazet <edumazet@...gle.com>
CC: <ncardwell@...gle.com>, <kuniyu@...zon.com>, <davem@...emloft.net>,
	<dsahern@...nel.org>, <kuba@...nel.org>, <pabeni@...hat.com>,
	<horms@...nel.org>, <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	Jason Xing <kerneljasonxing@...il.com>
Subject: Re: [PATCH net] tcp: Fix error ts_recent time during three-way
 handshake



On 2025/2/18 21:35, Eric Dumazet wrote:
> On Tue, Feb 18, 2025 at 12:00 PM Wang Hai <wanghai38@...wei.com> wrote:
>>
>> If two ack packets from a connection enter tcp_check_req at the same time
>> through different cpu, it may happen that req->ts_recent is updated with
>> with a more recent time and the skb with an older time creates a new sock,
>> which will cause the tcp_validate_incoming check to fail.
>>
>> cpu1                                cpu2
>> tcp_check_req
>>                                      tcp_check_req
>> req->ts_recent = tmp_opt.rcv_tsval = t1
>>                                      req->ts_recent = tmp_opt.rcv_tsval = t2
>>
>> newsk->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) // failed
>>
>> In tcp_check_req, restore ts_recent to this skb's to fix this bug.
>>
>> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>> Signed-off-by: Wang Hai <wanghai38@...wei.com>
>> ---
>>   net/ipv4/tcp_minisocks.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
>> index b089b08e9617..0208455f9eb8 100644
>> --- a/net/ipv4/tcp_minisocks.c
>> +++ b/net/ipv4/tcp_minisocks.c
>> @@ -878,6 +878,10 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
>>          sock_rps_save_rxhash(child, skb);
>>          tcp_synack_rtt_meas(child, req);
>>          *req_stolen = !own_req;
>> +       if (own_req && tcp_sk(child)->rx_opt.tstamp_ok &&
>> +           unlikely(tcp_sk(child)->rx_opt.ts_recent != tmp_opt.rcv_tsval))
>> +               tcp_sk(child)->rx_opt.ts_recent = tmp_opt.rcv_tsval;
>> +
>>          return inet_csk_complete_hashdance(sk, child, req, own_req);
> 
> Have you seen the comment at line 818 ?
> 
> /* TODO: We probably should defer ts_recent change once
>   * we take ownership of @req.
>   */
> 
> Plan was clear and explained. Why implement something else (and buggy) ?
> 
Hi Eric,

Currently we have a real problem, so we want to solve it. This bug 
causes the upper layers to be unable to be notified to call accept after 
the successful three-way handshake.

Skb from cpu1 that fails at tcp_paws_check (which it could have 
succeeded) will not be able to enter the TCP_ESTABLISHED state, and 
therefore parent->sk_data_ready(parent) will not be triggered, and skb 
from cpu2 can complete the three-way handshake, but there is also no way 
to call parent->sk_data_ready(parent) to notify the upper layer, which 
will result
in the upper layer not being able to sense and call accept to obtain the 
nsk.

cpu1                                cpu2
tcp_check_req
                                     tcp_check_req
req->ts_recent = tmp_opt.rcv_tsval = t1
                                     req->ts_recent=tmp_opt.rcv_tsval= t2

newsk->ts_recent = req->ts_recent = t2 // t1 < t2
tcp_child_process
  tcp_rcv_state_process
   tcp_validate_incoming
    tcp_paws_check // failed
  parent->sk_data_ready(parent); // will not be called
                                     tcp_v4_do_rcv
				     tcp_rcv_state_process // Complete the three-way handshake
													// missing parent->sk_data_ready(parent);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ