Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4450853imw; Tue, 19 Jul 2022 06:54:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vXV83B5ydE7x959s37s5Kkst8LqfKr0Y5t5RIgSg9kKiQhWktp0iPbrp9lIaDPn02w1zJy X-Received: by 2002:a05:6402:950:b0:43a:5194:174c with SMTP id h16-20020a056402095000b0043a5194174cmr44251387edz.145.1658238863245; Tue, 19 Jul 2022 06:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238863; cv=none; d=google.com; s=arc-20160816; b=vWVCiKjMGmlK2KNaW9mCV1iXehjatrQrpKOq/X5MCoMhS88KmuIStLY9T1zb6BQZDZ DIyJI50QsAnaLHB3Q9yM6TgazqqkGA2Lb9do5Jijd1pi+Y8/PGhXwgR+cQqHHo0s88ed bbTixIw2aqP4456In9SoB7UEWQQCQDyzIYFgffXmleAWpFlDVSmCLaBYd+DKKuwGkGyk eauP8coyPW5SsSrPMdocZ5ORkQmZkbSRNoBAv4IOCm6d+V1unociMDcz+ydSRjd9OmaC Or1W8YAsqbstBhSxGyaXqLWZetX6GIzfN7fCndBu8uVP0c2BL8Ulq+HUFd4l+lHKmT02 vxEA== 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=269NJ0MsmUOUFxzm1OQE34T2L8FPF4rlxP1CFltPwgk=; b=KP4qHp685+3KPVUSoo6DG8Z9YvjrPXH2h3Hz5UVkMfePDNRURm96RimuMirDoTDdbk ebRDbRM4mnFvhyAC4jc5yXFhU+ZxMvqZ1kui+Y7YPJi0GgYhlYkzQvPlozfvIFI3KKNh Q+E3Q83hgYOoOQv3L3YP+Nhk2kfqzIa21MB2FvnxLKFP+Qacvum3k+zBfabUdNfAoIU5 gmfNcQYVEpvZP/wckcFi/0b8eEEz83t3+P+qgzli8dzk+eJbzml7CkPOrdhmdzZIN+V2 lAbLu8R6CF+OhhhUS0ZThl1ZjAQsBpCVXeU5HeCBkom6EDILumLe3BkBkVKzYm094eGa Z+nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a665dgPs; 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 y7-20020a056402440700b0043a6defcbafsi20321643eda.219.2022.07.19.06.53.59; Tue, 19 Jul 2022 06:54:23 -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=a665dgPs; 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 S234604AbiGSMVC (ORCPT + 99 others); Tue, 19 Jul 2022 08:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239513AbiGSMTZ (ORCPT ); Tue, 19 Jul 2022 08:19:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F50B57E38; Tue, 19 Jul 2022 05:06:56 -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 C76CC61772; Tue, 19 Jul 2022 12:06:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 991EFC341C6; Tue, 19 Jul 2022 12:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232415; bh=CuwSAwhyIVsP82SzYIX9jVQdRILewFnfVRxFuBiysAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a665dgPsAqQ4Mq1/CjTWWVzTDXvDcU+HdlpfrTe5TYNDLO9SgeYs5FEP3tS8H8nlu a/hIbsao5U+YKqqlYnCt6T9YyIbGbb4T4j9HeR0iXIQAEtDJZZ3ItxCBfRrQr58Yhl M99MHjE8jPv7qUAzD/9pI/yzsU44/L9MaOoDiTM4= 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 048/112] tcp: Fix a data-race around sysctl_tcp_max_orphans. Date: Tue, 19 Jul 2022 13:53:41 +0200 Message-Id: <20220719114631.137612075@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 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 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 47e6ab24e8c6e3ca10ceb5835413f401f90de4bf ] While reading sysctl_tcp_max_orphans, it can be changed concurrently. So, we need to add READ_ONCE() to avoid a data-race. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index a3ec2a08027b..19c13ad5c121 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2490,7 +2490,8 @@ static void tcp_orphan_update(struct timer_list *unused) static bool tcp_too_many_orphans(int shift) { - return READ_ONCE(tcp_orphan_cache) << shift > sysctl_tcp_max_orphans; + return READ_ONCE(tcp_orphan_cache) << shift > + READ_ONCE(sysctl_tcp_max_orphans); } bool tcp_check_oom(struct sock *sk, int shift) -- 2.35.1