]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: Fix a data-race around sysctl_net_busy_read.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Tue, 23 Aug 2022 17:46:52 +0000 (10:46 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Sep 2022 08:23:55 +0000 (10:23 +0200)
[ Upstream commit e59ef36f0795696ab229569c153936bfd068d21c ]

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

Fixes: 2d48d67fa8cd ("net: poll/select low latency socket support")
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/sock.c

index 1845a37d9f7e19261006b344859fb32a404c0661..e4b28c10901ec524805194323ac8035463aa35a1 100644 (file)
@@ -2508,7 +2508,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
 
 #ifdef CONFIG_NET_RX_BUSY_POLL
        sk->sk_napi_id          =       0;
-       sk->sk_ll_usec          =       sysctl_net_busy_read;
+       sk->sk_ll_usec          =       READ_ONCE(sysctl_net_busy_read);
 #endif
 
        sk->sk_max_pacing_rate = ~0U;