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, 24 May 2023 15:10:32 +0800
From: Cambda Zhu <cambda@...ux.alibaba.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Paolo Abeni <pabeni@...hat.com>,
 Jason Xing <kerneljasonxing@...il.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

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

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