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

ipv4: Fix a data-race around sysctl_fib_sync_mem.

stable inclusion
from stable-v5.10.132
commit 418b191d5f223a8cb6cab09eae1f72c04ba6adf2
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5YS3T

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

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

[ Upstream commit 73318c4b ]

While reading sysctl_fib_sync_mem, it can be changed concurrently.
So, we need to add READ_ONCE() to avoid a data-race.

Fixes: 9ab948a9 ("ipv4: Allow amount of dirty memory from fib resizing to be controllable")
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>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 1e443e2a
...@@ -497,7 +497,7 @@ static void tnode_free(struct key_vector *tn) ...@@ -497,7 +497,7 @@ static void tnode_free(struct key_vector *tn)
tn = container_of(head, struct tnode, rcu)->kv; tn = container_of(head, struct tnode, rcu)->kv;
} }
if (tnode_free_size >= sysctl_fib_sync_mem) { if (tnode_free_size >= READ_ONCE(sysctl_fib_sync_mem)) {
tnode_free_size = 0; tnode_free_size = 0;
synchronize_rcu(); synchronize_rcu();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册