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] [day] [month] [year] [list]
Message-ID: <d7510d93-7469-4dee-8a09-f80c0f1df3b3@kernel.org>
Date: Tue, 25 Feb 2025 18:18:39 +0100
From: Matthieu Baerts <matttbe@...nel.org>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Paolo Abeni <pabeni@...hat.com>, Kuniyuki Iwashima <kuniyu@...zon.com>,
 Simon Horman <horms@...nel.org>, Florian Westphal <fw@...len.de>,
 netdev@...r.kernel.org, eric.dumazet@...il.com,
 Jakub Kicinski <kuba@...nel.org>, Yong-Hao Zou <yonghaoz1994@...il.com>,
 "David S . Miller" <davem@...emloft.net>,
 Neal Cardwell <ncardwell@...gle.com>
Subject: Re: [PATCH net-next] tcp: be less liberal in tsecr received while in
 SYN_RECV state

Hi Eric,

On 25/02/2025 18:11, Eric Dumazet wrote:
> On Tue, Feb 25, 2025 at 5:56 PM Matthieu Baerts <matttbe@...nel.org> wrote:
>>
>> Hi Eric,
>>
>> On 25/02/2025 11:51, Eric Dumazet wrote:
>>> On Tue, Feb 25, 2025 at 11:48 AM Matthieu Baerts <matttbe@...nel.org> wrote:
>>>>
>>>> On 25/02/2025 11:42, Eric Dumazet wrote:
>>>>> On Tue, Feb 25, 2025 at 11:39 AM Eric Dumazet <edumazet@...gle.com> wrote:
>>>>>>
>>>>>
>>>>>>
>>>>>> Yes, this would be it :
>>>>>>
>>>>>> diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
>>>>>> index 728bce01ccd3ddb1f374fa96b86434a415dbe2cb..3555567ba4fb1ccd5c5921e39d11ff08f1d0cafd
>>>>>> 100644
>>>>>> --- a/net/ipv4/tcp_timer.c
>>>>>> +++ b/net/ipv4/tcp_timer.c
>>>>>> @@ -477,8 +477,8 @@ static void tcp_fastopen_synack_timer(struct sock
>>>>>> *sk, struct request_sock *req)
>>>>>>          * regular retransmit because if the child socket has been accepted
>>>>>>          * it's not good to give up too easily.
>>>>>>          */
>>>>>> -       inet_rtx_syn_ack(sk, req);
>>>>>>         req->num_timeout++;
>>>>>> +       inet_rtx_syn_ack(sk, req);
>>>>>>         tcp_update_rto_stats(sk);
>>>>>>         if (!tp->retrans_stamp)
>>>>>>                 tp->retrans_stamp = tcp_time_stamp_ts(tp);
>>>>>
>>>>> Obviously, I need to refine the patch and send a V2 later.
>>>>
>>>> Sorry, I still have the issue with this modification. I also checked
>>>> with the previous patch, just to be sure, but the problem is still there
>>>> as well.
>>>
>>> I said "req->num_timeout" is not updated where I thought it was.
>>
>> I think that in case of SYN+ACK retransmission, req->num_timeout is
>> incremented after tcp_synack_options():
>>
>>   reqsk_timer_handler()
>>   --> inet_rtx_syn_ack()
>>     --> tcp_rtx_synack()
>>       --> tcp_v6_send_synack()
>>         --> tcp_make_synack()
>>           --> tcp_synack_options()
>>   then: req->num_timeout++
>>
>>> Look at all the places were req->num_timeout or req->num_retrans are
>>> set/changed.... this will give you some indications.
>>
>> I'm probably missing something obvious, but if the goal is to set
>> snt_tsval_first only the first time, why can we not simply set
>>
>>   tcp_rsk(req)->snt_tsval_first = 0;
>>
>> in tcp_conn_request(), and only set it to tsval in tcp_synack_options()
>> when it is 0? Something like that:
>>
>>
>>> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
>>> index 217a8747a79b..26b3daa5efd2 100644
>>> --- a/net/ipv4/tcp_input.c
>>> +++ b/net/ipv4/tcp_input.c
>>> @@ -7249,6 +7249,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
>>>         tcp_rsk(req)->af_specific = af_ops;
>>>         tcp_rsk(req)->ts_off = 0;
>>>         tcp_rsk(req)->req_usec_ts = false;
>>> +       tcp_rsk(req)->snt_tsval_first = 0;
>>>  #if IS_ENABLED(CONFIG_MPTCP)
>>>         tcp_rsk(req)->is_mptcp = 0;
>>>  #endif
>>> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
>>> index 485ca131091e..020c624532d7 100644
>>> --- a/net/ipv4/tcp_output.c
>>> +++ b/net/ipv4/tcp_output.c
>>> @@ -943,7 +943,7 @@ static unsigned int tcp_synack_options(const struct sock *sk,
>>>                 opts->options |= OPTION_TS;
>>>                 opts->tsval = tcp_skb_timestamp_ts(tcp_rsk(req)->req_usec_ts, skb) +
>>>                               tcp_rsk(req)->ts_off;
>>> -               if (!req->num_timeout)
>>> +               if (!tcp_rsk(req)->snt_tsval_first)
>>>                         tcp_rsk(req)->snt_tsval_first = opts->tsval;
>>>                 WRITE_ONCE(tcp_rsk(req)->snt_tsval_last, opts->tsval);
>>>                 opts->tsecr = READ_ONCE(req->ts_recent)
>>
>>
>> Or is the goal to update this field as long as the timeout didn't fire?
>> In this case maybe req->num_timeout should be updated before calling
>> inet_rtx_syn_ack() in reqsk_timer_handler(), no?
>>
>>> Do not worry, I will make sure V2 is fine.
>>
>> I don't doubt about that, thank you! :)
> 
> I can see you are super excited to see this patch landing ;)

Oh no, sorry, when I read your previous email, I understood you wanted
me to look at it. That's why I took a bit of time this afternoon looking
at all the places where req->num_timeout is incremented, and sent this
email :)

So no hurry for me to have this patch landed. All I wanted was it not to
break MPTCP selftests, and help to understand why it was causing issues
in the first place (not due to MPTCP apparently, for once :) )

> I sent the V2, after running all my tests.

Thank you!

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ