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: <CAL+tcoDi-=WAjyoM9n01JjYBj_p5_yrOMBJW4M_SCYFw9YGimg@mail.gmail.com>
Date: Wed, 24 May 2023 17:30:38 +0800
From: Jason Xing <kerneljasonxing@...il.com>
To: Cambda Zhu <cambda@...ux.alibaba.com>
Cc: Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org, 
	Xuan Zhuo <xuanzhuo@...ux.alibaba.com>, Dust Li <dust.li@...ux.alibaba.com>, 
	Tony Lu <tonylu@...ux.alibaba.com>, Jack Yang <mingliang@...ux.alibaba.com>
Subject: Re: [PATCH net-next] net: Return user_mss for TCP_MAXSEG in
 CLOSE/LISTEN state

On Wed, May 24, 2023 at 3:10 PM Cambda Zhu <cambda@...ux.alibaba.com> wrote:
>
> After I did a deep search about the TCP_MAXSEG, I found this is a bit
> more complicated than I think before.
>
> I don't know whether the TCP_MAXSEG is from BSD or not, but if the
> "UNIX Network Programming" is right, getting TCP_MAXSEG returns default
> MSS before connecting is as expect, that's what FreeBSD does. If we
> simply remove the !val check for it, getting TCP_MAXSEG will return zero
> before connecting, because tp->rx_opt.user_mss is initialized with zero
> on Linux, while tp->t_maxseg is initialized with default MSS on FreeBSD.
>
> I googled to see how it's used by developers now, and I think getting
> TCP_MAXSEG should return default MSS if before connecting and user_mss
> not set, for backward compatibility.
>
> But the !val check is a bug also, and the problem is not discovered for
> the first time.
> https://stackoverflow.com/questions/25996741/why-getsockopt-does-not-return-the-expected-value-for-tcp-maxseg
>
> I think it should be:
>
> - if (!val && ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
> + if (tp->rx_opt.user_mss && ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))

Good catch, It makes sense to me. With this modification, it could
prevent getsockopt returning zero with TCP_MAXSEG flag when the socket
stays in the close/listen state.

Thanks,
Jason

>
> With this change, getting TCP_MAXSEG will return default MSS as book
> described, and return user_mss if user_mss is set and before connecting.
> The tp->t_maxseg will only decrease on FreeBSD and we don't. I think
> our solution is better.
>
> I'll send a new patch later.
>
>
> Regards,
> Cambda

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ