Skip to content

Commit fd2ddef

Browse files
BLeperskuba-moo
authored andcommitted
udp: Prevent reuseport_select_sock from reading uninitialized socks
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: acdcecc ("udp: correct reuseport selection with connected sockets") Signed-off-by: Baptiste Lepers <[email protected]> Acked-by: Willem de Bruijn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 53475c5 commit fd2ddef

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

net/core/sock_reuseport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ struct sock *reuseport_select_sock(struct sock *sk,
293293
i = j = reciprocal_scale(hash, socks);
294294
while (reuse->socks[i]->sk_state == TCP_ESTABLISHED) {
295295
i++;
296-
if (i >= reuse->num_socks)
296+
if (i >= socks)
297297
i = 0;
298298
if (i == j)
299299
goto out;

0 commit comments

Comments
 (0)