Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3053758rwe; Mon, 29 Aug 2022 05:12:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR6NVl84Q3scudAFdtc5Rlc4zBBp0Y/T7+VUKTDSVyH40TLuk/JBwS409whOAZyY5+idmlfc X-Received: by 2002:a05:6a00:4393:b0:52f:3603:e62f with SMTP id bt19-20020a056a00439300b0052f3603e62fmr16205227pfb.23.1661775141265; Mon, 29 Aug 2022 05:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661775141; cv=none; d=google.com; s=arc-20160816; b=BmFnoTYWZhZ4CMfrPrH7JEsybCmPItsI3roO3fRAX5uvMMj4zRHkkqlM6ymbrdPqUb bsEWGVMDS2Gej42RyyKVPcqJ0CtEiiq6I9Ybit0iBtUCK+vz5lfkL95J/ERgxR6VMElx cJ0Ut/oFJEZBJ9DzcQbAVYEBPZQoIWm+djwg3JhBQc2VqAaGcFquU5c49a1DjMBIOJPy dgFG+uiWpqJ2Wcbv33nixRzR3veoMsf+6EeKB2/Sa4ve+dAZbe7Dx9URiONjNz50S1ZF 4A6Pawwxl/3NjzVegtcfBZyJCeZxNoPYf62KO3yIO3LRH14efF6EiFRJlrEEG58BndDb 57pA== 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=zO54xS0ud2fF1pieKSNvXMMpKJlGNcNYsSDr1qXaAdM=; b=ldj7e6XDdUGqLxNFWrzxXtYP0UZr60VOLyMoT7J+1bH0L9S+t9XiMWOyBv7yfLtFLJ /7RGx9BzZQUIimzl8OvjuvkL3mlhURi9YN+/Kv3f3Wgoo3vDRW6aJOYOHzV4/Tdog+id z2wMDczXtJSgWiXP0XYhdn6kATjudRDr17roMT7hAVYNSCrkkZEhpcmmoILnNyjwvdjV oa/wE2NdKbV4A0RW+iOFcepjsJeKl2XtE1/mxAdb/H1W0iJ0iiVB6tZNmSQG/wmf+qnN dXX1DkrZOsi03rHVoMTkt80XRLfXiNiHH+2A1iplr3okRzKTWaLIhVlx9FqjBtqs7KQo NwkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ufs6wley; 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 n16-20020a170903111000b001712e1efa90si9516004plh.22.2022.08.29.05.12.00; Mon, 29 Aug 2022 05:12:21 -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=ufs6wley; 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 S232443AbiH2LbH (ORCPT + 99 others); Mon, 29 Aug 2022 07:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232519AbiH2L3M (ORCPT ); Mon, 29 Aug 2022 07:29:12 -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 F05B37A765; Mon, 29 Aug 2022 04:17:34 -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 1C825B80F01; Mon, 29 Aug 2022 11:17:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E5D4C433C1; Mon, 29 Aug 2022 11:17:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771841; bh=HxmAsXrYyzdTqLFgMqPhC0g9Yai4mH+o7CM00skDxUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ufs6wleyFCFhj5WfThOzElCBSZCwH83ZmqsCU4b/CnQKtiUSUVfSwKQRQpsvLHSiD 8m6gFRqxJDqmMAzWtO8YwgCMr/qghqamq/bWgOd1ZIUZ+IJblbXnx7y0barYchDUFB GhsZRTLgnRwtBwqNS3+QMrrVVSDBuoAfQdMuRpKs= 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.19 081/158] net: Fix a data-race around sysctl_somaxconn. Date: Mon, 29 Aug 2022 12:58:51 +0200 Message-Id: <20220829105812.443478480@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105808.828227973@linuxfoundation.org> References: <20220829105808.828227973@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 96300cdc06251..34102aa4ab0a6 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; -- 2.35.1