From nobody Sun Sep 7 12:25:50 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 179DDC38145 for ; Fri, 2 Sep 2022 12:36:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236894AbiIBMgI (ORCPT ); Fri, 2 Sep 2022 08:36:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236761AbiIBMeO (ORCPT ); Fri, 2 Sep 2022 08:34:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF9F6E39A5; Fri, 2 Sep 2022 05:28:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7644862180; Fri, 2 Sep 2022 12:28:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75B49C433D6; Fri, 2 Sep 2022 12:28:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662121689; bh=bHz25WY47fF99xCkNTtdyucgM4/0bYVDXbB1OFIFlLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EwKObwL7PUvgGbf9YX+KI6IQmfPT1UOP91LRS7v6vckWxiWfhazxdw8jeVEgcYkSf SUKU7XVdpgieoQR5LRvWFT6oflDRMKd0ggOjmOdoewJcAIEBRRWwgkaEYAZRyvR0lA xyRUyUy+/cYgBQ9oUZ9nyrwmOpI9tWKvAJ2ohLBY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 34/77] net: Fix a data-race around sysctl_somaxconn. Date: Fri, 2 Sep 2022 14:18:43 +0200 Message-Id: <20220902121404.772034607@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121403.569927325@linuxfoundation.org> References: <20220902121403.569927325@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/socket.c b/net/socket.c index 94358566c9d10..02feaf5bd84a3 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1661,7 +1661,7 @@ int __sys_listen(int fd, int backlog) =20 sock =3D sockfd_lookup_light(fd, &err, &fput_needed); if (sock) { - somaxconn =3D sock_net(sock->sk)->core.sysctl_somaxconn; + somaxconn =3D READ_ONCE(sock_net(sock->sk)->core.sysctl_somaxconn); if ((unsigned int)backlog > somaxconn) backlog =3D somaxconn; =20 --=20 2.35.1