udp: Prevent reuseport_select_sock from reading uninitialized socks
authorBaptiste Lepers <baptiste.lepers@gmail.com>
Thu, 7 Jan 2021 05:11:10 +0000 (16:11 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Jan 2021 15:03:59 +0000 (16:03 +0100)
commit4b97ce051ffe21dcc0e09418bb3ab4ba018ee87b
tree3536ac11ea9bc184b07eab078d99f3deba998001
parent24cd3317418955fd9489e4e7e9c2b643691b270b
udp: Prevent reuseport_select_sock from reading uninitialized socks

[ Upstream commit fd2ddef043592e7de80af53f47fa46fd3573086e ]

reuse->socks[] is modified concurrently by reuseport_add_sock. To
prevent reading values that have not been fully initialized, only read
the array up until the last known safe index instead of incorrectly
re-reading the last index of the array.

Fixes: acdcecc61285f ("udp: correct reuseport selection with connected sockets")
Signed-off-by: Baptiste Lepers <baptiste.lepers@gmail.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/20210107051110.12247-1-baptiste.lepers@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/sock_reuseport.c