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]
Date: Wed, 17 May 2023 17:58:25 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: Cambda Zhu <cambda@...ux.alibaba.com>
Cc: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>, 
	Xuan Zhuo <xuanzhuo@...ux.alibaba.com>, Dust Li <dust.li@...ux.alibaba.com>, 
	Tony Lu <tonylu@...ux.alibaba.com>
Subject: Re: net: getsockopt(TCP_MAXSEG) on listen sock returns wrong MSS?

On Wed, May 17, 2023 at 1:09 PM Cambda Zhu <cambda@...ux.alibaba.com> wrote:
>
> I want to call setsockopt(TCP_MAXSEG) on a listen sock to let
> all child socks have smaller MSS. And I found the child sock
> MSS changed but getsockopt(TCP_MAXSEG) on the listen sock
> returns 536 always.
>

I think TCP_MAXSEG is not like a traditional option you can set and get later,
expecting to read back the value you set.

It is probably a bug.

Getting tp->mss_cache should have been a separate socket option, but
it is too late.


> It seems the tp->mss_cache is initialized with TCP_MSS_DEFAULT,
> but getsockopt(TCP_MAXSEG) returns tp->rx_opt.user_mss only when
> tp->mss_cache is 0. I don't understand the purpose of the mss_cache
> check of TCP_MAXSEG. If getsockopt(TCP_MAXSEG) on listen sock makes
> no sense, why does it have a branch for close/listen sock to return
> user_mss? If getsockopt(TCP_MAXSEG) on listen sock is ok, why does
> it check mss_cache for a listen sock?
>
> I tried to find the commit log about TCP_MAXSEG, and found that
> in commit 0c409e85f0ac ("Import 2.3.41pre2"), the mss_cache check
> was added. No more detailed information found. Is this a bug or am
> I misunderstanding something?

I wonder if we should simply do:

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4d6392c16b7a5a9a853c27e3a4b258d000738304..cb526257a06a6c7a4e65e710fff1770bd382ed2d
100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -4080,9 +4080,10 @@ int do_tcp_getsockopt(struct sock *sk, int level,

        switch (optname) {
        case TCP_MAXSEG:
-               val = tp->mss_cache;
-               if (!val && ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
+               if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
                        val = tp->rx_opt.user_mss;
+               else
+                       val = tp->mss_cache;
                if (tp->repair)
                        val = tp->rx_opt.mss_clamp;
                break;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ