From: Kuniyuki Iwashima Date: Tue, 23 Aug 2022 17:47:00 +0000 (-0700) Subject: net: Fix a data-race around sysctl_somaxconn. X-Git-Tag: baikal/aarch64/sdk6.1~3197^2~8^2 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=70384b59fd9ee542af76fb47028e84be37779091;p=kernel.git net: Fix a data-race around sysctl_somaxconn. While reading sysctl_somaxconn, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller --- diff --git a/net/socket.c b/net/socket.c index 9b27c5e4e5ba8..7378375d3a5b6 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1801,7 +1801,7 @@ int __sys_listen(int fd, int backlog) sock = sockfd_lookup_light(fd, &err, &fput_needed); if (sock) { - somaxconn = sock_net(sock->sk)->core.sysctl_somaxconn; + somaxconn = READ_ONCE(sock_net(sock->sk)->core.sysctl_somaxconn); if ((unsigned int)backlog > somaxconn) backlog = somaxconn;