summaryrefslogtreecommitdiffstats
path: root/net/socket.c
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@amazon.com>2022-08-23 10:47:00 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-08-31 17:16:45 +0200
commitcb9eaedd9fc0871faef0949d25f7c732db5dcd6c (patch)
treefc5013529b2fad4e44ed2c18606ae759fb70eaa5 /net/socket.c
parentb340f83dafbaf821cc2ab5f078a3652c0d09f97a (diff)
downloadlinux-stable-cb9eaedd9fc0871faef0949d25f7c732db5dcd6c.tar.gz
linux-stable-cb9eaedd9fc0871faef0949d25f7c732db5dcd6c.tar.bz2
linux-stable-cb9eaedd9fc0871faef0949d25f7c732db5dcd6c.zip
net: Fix a data-race around sysctl_somaxconn.
[ Upstream commit 3c9ba81d72047f2e81bb535d42856517b613aba7 ] 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 <kuniyu@amazon.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/socket.c')
-rw-r--r--net/socket.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/socket.c b/net/socket.c
index 5053eb0100e4..73666b878f2c 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1721,7 +1721,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;