]> git.baikalelectronics.ru Git - kernel.git/commit
net: Fix data-races around weight_p and dev_weight_[rt]x_bias.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Tue, 23 Aug 2022 17:46:45 +0000 (10:46 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Sep 2022 08:27:41 +0000 (10:27 +0200)
commit4e2de69318f37df40c8638f4749eeb85d2e88f97
tree07616adf6a899af67dbcd9106d29b63cc0b7c273
parent19210f1e3fb4c889902fa076ee8a54df9f5850e0
net: Fix data-races around weight_p and dev_weight_[rt]x_bias.

[ Upstream commit 5b5257140da56d42f5b8fd5676a8923372c1e7d4 ]

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

Also, dev_[rt]x_weight can be read/written at the same time.  So, we
need to use READ_ONCE() and WRITE_ONCE() for its access.  Moreover, to
use the same weight_p while changing dev_[rt]x_weight, we add a mutex
in proc_do_dev_weight().

Fixes: 8eed0d997ade ("net: dev_weight: TX/RX orthogonality")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/core/dev.c
net/core/sysctl_net_core.c
net/sched/sch_generic.c