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: <CANn89i+Zs2bLC7h2N5v15Xh=aTWdoa3v2d_A-EvRirsnFEPgwQ@mail.gmail.com>
Date: Tue, 25 Feb 2025 11:39:12 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Matthieu Baerts <matttbe@...nel.org>
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

On Tue, Feb 25, 2025 at 11:37 AM Eric Dumazet <edumazet@...gle.com> wrote:
>
> On Tue, Feb 25, 2025 at 11:33 AM Matthieu Baerts <matttbe@...nel.org> wrote:
> >
> > On 25/02/2025 11:21, Eric Dumazet wrote:
> > > On Tue, Feb 25, 2025 at 11:19 AM Matthieu Baerts <matttbe@...nel.org> wrote:
> > >>
> > >> Hi Eric,
> > >>
> > >> On 25/02/2025 11:11, Eric Dumazet wrote:
> > >>> On Tue, Feb 25, 2025 at 11:09 AM Matthieu Baerts <matttbe@...nel.org> wrote:
> > >>>>
> > >>>> Hi Paolo, Eric,
> > >>>>
> > >>>> On 25/02/2025 10:59, Paolo Abeni wrote:
> > >>>>> On 2/24/25 12:06 PM, Eric Dumazet wrote:
> > >>>>>> Yong-Hao Zou mentioned that linux was not strict as other OS in 3WHS,
> > >>>>>> for flows using TCP TS option (RFC 7323)
> > >>>>>>
> > >>>>>> As hinted by an old comment in tcp_check_req(),
> > >>>>>> we can check the TSecr value in the incoming packet corresponds
> > >>>>>> to one of the SYNACK TSval values we have sent.
> > >>>>>>
> > >>>>>> In this patch, I record the oldest and most recent values
> > >>>>>> that SYNACK packets have used.
> > >>>>>>
> > >>>>>> Send a challenge ACK if we receive a TSecr outside
> > >>>>>> of this range, and increase a new SNMP counter.
> > >>>>>>
> > >>>>>> nstat -az | grep TcpExtTSECR_Rejected
> > >>>>>> TcpExtTSECR_Rejected            0                  0.0
> > >>>>
> > >>>> (...)
> > >>>>
> > >>>>> It looks like this change causes mptcp self-test failures:
> > >>>>>
> > >>>>> https://netdev-3.bots.linux.dev/vmksft-mptcp/results/6642/1-mptcp-join-sh/stdout
> > >>>>>
> > >>>>> ipv6 subflows creation fails due to the added check:
> > >>>>>
> > >>>>> # TcpExtTSECR_Rejected            3                  0.0
> > >>>>
> > >>>> You have been faster to report the issue :-)
> > >>>>
> > >>>>> (for unknown reasons the ipv4 variant of the test is successful)
> > >>>>
> > >>>> Please note that it is not the first time the MPTCP test suite caught
> > >>>> issues with the IPv6 stack. It is likely possible the IPv6 stack is less
> > >>>> covered than the v4 one in the net selftests. (Even if I guess here the
> > >>>> issue is only on MPTCP side.)
> > >>>
> > >>>
> > >>> subflow_prep_synack() does :
> > >>>
> > >>>  /* clear tstamp_ok, as needed depending on cookie */
> > >>> if (foc && foc->len > -1)
> > >>>      ireq->tstamp_ok = 0;
> > >>>
> > >>> I will double check fastopen code then.
> > >>
> > >> Fastopen is not used in the failing tests. To be honest, it is not clear
> > >> to me why only the two tests I mentioned are failing, they are many
> > >> other tests using IPv6 in the MP_JOIN.
> > >
> > > Yet, clearing tstamp_ok might be key here.
> > >
> > > Apparently tcp_check_req() can get a non zero tmp_opt.rcv_tsecr even
> > > if tstamp_ok has been cleared at SYNACK generation.
> >
> > Good point. But in the tests, it is not suppose to clear the timestamps.
> >
> > (Of course, when I take a capture, I cannot reproduce the issue :) )
> >
> > >
> > > I would test :
> > >
> > > diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
> > > index a87ab5c693b524aa6a324afe5bf5ff0498e528cc..0ed27f5c923edafdf48919600491eb1cb50bc913
> > > 100644
> > > --- a/net/ipv4/tcp_minisocks.c
> > > +++ b/net/ipv4/tcp_minisocks.c
> > > @@ -674,7 +674,8 @@ struct sock *tcp_check_req(struct sock *sk, struct
> > > sk_buff *skb,
> > >                 if (tmp_opt.saw_tstamp) {
> > >                         tmp_opt.ts_recent = READ_ONCE(req->ts_recent);
> > >                         if (tmp_opt.rcv_tsecr) {
> > > -                               tsecr_reject = !between(tmp_opt.rcv_tsecr,
> > > +                               if (inet_rsk(req)->tstamp_ok)
> > > +                                       tsecr_reject =
> > > !between(tmp_opt.rcv_tsecr,
> > >
> > > tcp_rsk(req)->snt_tsval_first,
> > >
> > > READ_ONCE(tcp_rsk(req)->snt_tsval_last));
> > >                                 tmp_opt.rcv_tsecr -= tcp_rsk(req)->ts_off;
> > Thank you for the suggestion. It doesn't look to be that, I can still
> > reproduce the issue.
> >
> > If I print the different TS (rcv, snt first, snt last) when tsecr_reject
> > is set, I get this:
> >
> > [  227.984292] mattt: 2776726299 2776727335 2776727335
> > [  227.984684] mattt: 2776726299 2776727335 2776727335
> > [  227.984771] mattt: 3603918977 3603920020 3603920020
> > [  227.984896] mattt: 3603918977 3603920020 3603920020
> > [  230.031921] mattt: 3603918977 3603920020 3603922068
> > [  230.032283] mattt: 2776726299 2776727335 2776729383
> > [  230.032554] mattt: 2776729384 2776727335 2776729383
> >       ack rx                [FAIL] got 0 JOIN[s] ack rx expected 2
>
> req->num_timeout might not be updated where I thought it was.


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);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ