]> git.baikalelectronics.ru Git - kernel.git/commit
udp: Copy has_conns in reuseport_grow().
authorKuniyuki Iwashima <kuniyu@amazon.co.jp>
Tue, 21 Jul 2020 06:15:30 +0000 (15:15 +0900)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Jul 2020 22:31:02 +0000 (15:31 -0700)
commit3c68c942c58a87e658d9283b469b9f4f64fa0ebe
tree063ac533d4709d483b55bb5b8d3e3899c04651ea
parent8d4a7a94ad5c29e68ab1a118b9ed7b65063e8348
udp: Copy has_conns in reuseport_grow().

If an unconnected socket in a UDP reuseport group connect()s, has_conns is
set to 1. Then, when a packet is received, udp[46]_lib_lookup2() scans all
sockets in udp_hslot looking for the connected socket with the highest
score.

However, when the number of sockets bound to the port exceeds max_socks,
reuseport_grow() resets has_conns to 0. It can cause udp[46]_lib_lookup2()
to return without scanning all sockets, resulting in that packets sent to
connected sockets may be distributed to unconnected sockets.

Therefore, reuseport_grow() should copy has_conns.

Fixes: 94179daae74b ("udp: correct reuseport selection with connected sockets")
CC: Willem de Bruijn <willemb@google.com>
Reviewed-by: Benjamin Herrenschmidt <benh@amazon.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/sock_reuseport.c