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: <CANn89iLq0g=TmL+nABr=j4N2gw45yJgRr6g8YOX+iMdWrM3jOg@mail.gmail.com>
Date: Wed, 2 Oct 2024 09:33:44 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: "xin.guo" <guoxin0309@...il.com>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH net-next] tcp: remove unnecessary update for tp->write_seq
 in tcp_connect()

On Wed, Oct 2, 2024 at 8:14 AM xin.guo <guoxin0309@...il.com> wrote:
>
> From: "xin.guo" <guoxin0309@...il.com>
>
> Commit 783237e8daf13("net-tcp: Fast Open client - sending SYN-data")
> introduce tcp_connect_queue_skb() and it would overwrite tcp->write_seq,
> so it is no need to update tp->write_seq before invoking
> tcp_connect_queue_skb()
>
> Signed-off-by: xin.guo <guoxin0309@...il.com>
> ---
>  net/ipv4/tcp_output.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 4fd746b..f255c7d 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -4134,7 +4134,7 @@ int tcp_connect(struct sock *sk)
>         if (unlikely(!buff))
>                 return -ENOBUFS;
>
> -       tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN);
> +       tcp_init_nondata_skb(buff, tp->write_seq, TCPHDR_SYN);
>         tcp_mstamp_refresh(tp);
>         tp->retrans_stamp = tcp_time_stamp_ts(tp);
>         tcp_connect_queue_skb(sk, buff);
> --
> 1.8.3.1
>

At line 3616, there is this comment :

/* FIN eats a sequence byte, write_seq advanced by tcp_queue_skb(). */

I think you need to add a similar one. Future readers will thank you.

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 4fd746bd4d54f621601b20c3821e71370a4a615a..86dea6f022d36cb56ef5678add2bd63132eee20f
100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -4134,7 +4134,10 @@ int tcp_connect(struct sock *sk)
        if (unlikely(!buff))
                return -ENOBUFS;

-       tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN);
+       /* SYN eats a sequence byte, write_seq updated by
+        * tcp_connect_queue_skb()
+        */
+       tcp_init_nondata_skb(buff, tp->write_seq, TCPHDR_SYN);
        tcp_mstamp_refresh(tp);
        tp->retrans_stamp = tcp_time_stamp_ts(tp);
        tcp_connect_queue_skb(sk, buff);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ