mirror-linux/include
Kuniyuki Iwashima 936a192f97 tcp: Add TIME_WAIT sockets in bhash2.
Jiri Slaby reported regression of bind() with a simple repro. [0]

The repro creates a TIME_WAIT socket and tries to bind() a new socket
with the same local address and port.  Before commit 28044fc1d4 ("net:
Add a bhash2 table hashed by port and address"), the bind() failed with
-EADDRINUSE, but now it succeeds.

The cited commit should have put TIME_WAIT sockets into bhash2; otherwise,
inet_bhash2_conflict() misses TIME_WAIT sockets when validating bind()
requests if the address is not a wildcard one.

The straight option is to move sk_bind2_node from struct sock to struct
sock_common to add twsk to bhash2 as implemented as RFC. [1]  However, the
binary layout change in the struct sock could affect performances moving
hot fields on different cachelines.

To avoid that, we add another TIME_WAIT list in inet_bind2_bucket and check
it while validating bind().

[0]: https://lore.kernel.org/netdev/6b971a4e-c7d8-411e-1f92-fda29b5b2fb9@kernel.org/
[1]: https://lore.kernel.org/netdev/20221221151258.25748-2-kuniyu@amazon.com/

Fixes: 28044fc1d4 ("net: Add a bhash2 table hashed by port and address")
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Acked-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-12-30 07:25:52 +00:00
..
acpi More ACPI updates for 6.2-rc1 2022-12-15 10:21:10 -08:00
asm-generic asm-generic bits for 6.2 2022-12-20 08:32:11 -06:00
clocksource
crypto
drm
dt-bindings phy-for-6.2 2022-12-19 08:40:58 -06:00
keys
kunit kunit: add macro to allow conditionally exposing static symbols to tests 2022-12-12 14:13:48 -07:00
kvm
linux fs.vfsuid.ima.v6.2-rc1 2022-12-21 08:13:01 -08:00
math-emu
media
memory
misc
net tcp: Add TIME_WAIT sockets in bhash2. 2022-12-30 07:25:52 +00:00
pcmcia
ras
rdma
rv
scsi SCSI misc on 20221213 2022-12-14 08:58:51 -08:00
soc Networking changes for 6.2. 2022-12-13 15:47:48 -08:00
sound
target
trace rxrpc: Fix a couple of potential use-after-frees 2022-12-28 09:59:23 +00:00
uapi atm: uapi: fix spelling typos in comments 2022-12-22 18:18:37 -08:00
ufs
vdso
video fbdev: omapfb: connector-analog-tv: remove support for platform data 2022-12-14 20:01:49 +01:00
xen