提交 60f92929 编写于 作者: B Baptiste Lepers 提交者: Cheng Jian

udp: Prevent reuseport_select_sock from reading uninitialized socks

stable inclusion
from linux-4.19.170
commit 4669452b4c66268a184a51c543b525533013c14e

--------------------------------

[ Upstream commit fd2ddef0 ]

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: acdcecc6 ("udp: correct reuseport selection with connected sockets")
Signed-off-by: NBaptiste Lepers <baptiste.lepers@gmail.com>
Acked-by: NWillem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/20210107051110.12247-1-baptiste.lepers@gmail.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NAichun Li <liaichun@huawei.com>
reviewed-by: Nwangxiaopeng <wangxiaopeng7@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 4ccc75e9
...@@ -299,7 +299,7 @@ struct sock *reuseport_select_sock(struct sock *sk, ...@@ -299,7 +299,7 @@ struct sock *reuseport_select_sock(struct sock *sk,
i = j = reciprocal_scale(hash, socks); i = j = reciprocal_scale(hash, socks);
while (reuse->socks[i]->sk_state == TCP_ESTABLISHED) { while (reuse->socks[i]->sk_state == TCP_ESTABLISHED) {
i++; i++;
if (i >= reuse->num_socks) if (i >= socks)
i = 0; i = 0;
if (i == j) if (i == j)
goto out; goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册