提交 a11e5544 编写于 作者: K Kuniyuki Iwashima 提交者: Zheng Zengkai

udp: Fix a data-race around sysctl_udp_l3mdev_accept.

stable inclusion
from stable-v5.10.134
commit fcaef69c79ec222e55643e666b80b221e70fa6a8
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5ZVR7

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=fcaef69c79ec222e55643e666b80b221e70fa6a8

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

[ Upstream commit 3d72bb41 ]

While reading sysctl_udp_l3mdev_accept, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its reader.

Fixes: 63a6fff3 ("net: Avoid receiving packets with an l3mdev on unbound UDP sockets")
Signed-off-by: NKuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 0a2244fd
...@@ -259,7 +259,7 @@ static inline bool udp_sk_bound_dev_eq(struct net *net, int bound_dev_if, ...@@ -259,7 +259,7 @@ static inline bool udp_sk_bound_dev_eq(struct net *net, int bound_dev_if,
int dif, int sdif) int dif, int sdif)
{ {
#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
return inet_bound_dev_eq(!!net->ipv4.sysctl_udp_l3mdev_accept, return inet_bound_dev_eq(!!READ_ONCE(net->ipv4.sysctl_udp_l3mdev_accept),
bound_dev_if, dif, sdif); bound_dev_if, dif, sdif);
#else #else
return inet_bound_dev_eq(true, bound_dev_if, dif, sdif); return inet_bound_dev_eq(true, bound_dev_if, dif, sdif);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册