Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3044970rwe; Mon, 29 Aug 2022 05:05:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR4G1uuOSqmgCYyrJMprxX7/kI+dXti5BF3dF5eQcpugmSyuKTmy5AGGpnSojiRgxHc9LMnZ X-Received: by 2002:aa7:dcc8:0:b0:447:e8b3:b4f3 with SMTP id w8-20020aa7dcc8000000b00447e8b3b4f3mr11901962edu.374.1661774709668; Mon, 29 Aug 2022 05:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661774709; cv=none; d=google.com; s=arc-20160816; b=t43JrHLcvKe1rFUB8HkHrJrmyeR1DcOSkkN6vE/M3xxhG/9sh0cMnq4jPk+qzGrIMk w0nZ9QVsOSa+e6wsflT/eHyQXpbYxexzHpLbyEhuJJIkUT4XzJCB8hiMWCOAfLlRyEzX Oa0+kw0wgzlJI+x1dvzrhixVwP0szeKs83AWsd36b227qktIrXiBNkMasKiPzloXDbT3 OwYdb0jUn7axoDhmTvz0giWV+irD9hEdu0XpnlqrRKy3fA1YdrLvpWWk+Z7cbFowdslW ZnzzPJIXCb7i69UdVnBRx7K2ZPK09qWuLKRYcoD5y5e6BAqWXJoS435pxB/hnriBCnpN ASBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iwePZ37UHAxGRFIq87gK9IV/+e1+lCwTjj+/GgFNO3k=; b=kWGQf2T3Qnlt1T7zS3LE7xsBkxx4MRC/Com83Tn3HSCXy1Rj+hlRicsXtBnFDDlage IKJ6sdVNGVngZMBrz8C5cnBRAy+5OiL26dAqhQYp6WzjcizkkpCzIIEuCEtMutW/Zfxx eBjiV0nZB7ZkDOQR351vDfQh6KalRO171lSXWVJhuM58d2sD3xoJvfpqS6J15Lnvu02A wf9IjrJPK3pLVc8FNkBLk49WJLZUjkWUAuaLOtLF8/ftSic/6D1SgDzCZVsVv3o+ntom Y9/7GhF4YpL6fVr42dgt/tFqwbdo1gvdtetIscDQcNZjx/flTRUbNpnBd1VC//T3c/Oz du7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dxujgEaU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m20-20020a056402511400b004489e0b42b0si769154edd.530.2022.08.29.05.04.43; Mon, 29 Aug 2022 05:05:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dxujgEaU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231192AbiH2LPe (ORCPT + 99 others); Mon, 29 Aug 2022 07:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231146AbiH2LN2 (ORCPT ); Mon, 29 Aug 2022 07:13:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 469FC6744A; Mon, 29 Aug 2022 04:09:36 -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 ams.source.kernel.org (Postfix) with ESMTPS id 8E3F9B80F93; Mon, 29 Aug 2022 11:09:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AE6BC433D6; Mon, 29 Aug 2022 11:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771371; bh=3TMLBjX1pTq8JtFOlU5X42wHv7nZUO2ENTwMKcFrJKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dxujgEaUJ9q8QWsS/7hr4tGBdAn4b7uXOhccds7kYmQ7LbJTta6ULrZ+RdkmGrySd A+ulZNMNlwFc06HGeqzE6yHb6V4/zTofPzZB+vpntUC6Osc5ezk73AbzVk8hg9vzRG 4pMR8aEL/6NewHDPBBy9lcxwRpthKtR2byMDWdW8= 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.10 60/86] net: Fix a data-race around sysctl_somaxconn. Date: Mon, 29 Aug 2022 12:59:26 +0200 Message-Id: <20220829105759.018736842@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105756.500128871@linuxfoundation.org> References: <20220829105756.500128871@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 d52c265ad449b..bcf68b150fe29 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1670,7 +1670,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; -- 2.35.1