Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1957703imn; Mon, 1 Aug 2022 06:17:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR46lILfH/WmHJRJq9PVm2x36GvVuX/yJ6Vn1cj+NhHwz/F97NG8XfboMuCB9oDUPtwLLtTg X-Received: by 2002:a17:903:24e:b0:16b:9fa2:41e5 with SMTP id j14-20020a170903024e00b0016b9fa241e5mr16627613plh.127.1659359874124; Mon, 01 Aug 2022 06:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659359874; cv=none; d=google.com; s=arc-20160816; b=kK1r/0Gsoj29hN7yr5xCa09gRmy+wanpEZPB/fpqk6PgqA25OrekbxLNVV3+5643u6 htzb/A53zWxe0FN0cWUTJ7LJ/wiEgqCOCTw0r29rmCnLKM9XroE+Dt7rQc0UMEfvc/LK rQrQZrF2xOh1LL6Hjt6whkKegUyEQOngN82aPetg51sjzpr1mwbROuj7y5rEHo9G/K6w SFk/6P2s+gwwPh7rWxft+/MrVOnhA8UvwzS0oG/ortxW851HWMcc4NpNmrPDyRPf5CaA D07aM7UKcETxPwfWKk9/tPv0dPHYruRBcJmMsvMZMhorwAk9Uk9104haFun8UO0nHdnL 4lkg== 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=W6fs3l7d9sB006o0evqs67qz8PBMyAJWRIUzP0IbxMo=; b=0q1MckLevYRj6/vrjMc/vrzgJoQ0IdREoU6i1f8jMz1G7lShhA/FR6w61jayCFzeZx BX8B/X5C0n8XGPfKNt4VEFx64x/yPKgRvyi2I0jiqQZUu9yxBtzv6ncV2rFm0p75is9H 3rZGdWVL2VeuRzmptQDz3E/Smqzf2baECqPWi2R2YsfcHg92UuW8Io6oRvlHGhuk5zgj 0dhYL/X4bo0jhBm9kbv63rIMMeBRqVmU56kkOHvV5F11XqUernHGotot95KqgNI7PqQM Iyx4BDAw5e3+6j9pwTPoTDmfYBq+X5okK7Aq3mIbgCF5En51m9VOcc26F3KfYJUCK1zz DGeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="XF8Jmfl/"; 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 p2-20020a170902b08200b0016ca0533a62si11288167plr.306.2022.08.01.06.17.39; Mon, 01 Aug 2022 06:17:54 -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="XF8Jmfl/"; 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 S232062AbiHALxX (ORCPT + 99 others); Mon, 1 Aug 2022 07:53:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232063AbiHALwr (ORCPT ); Mon, 1 Aug 2022 07:52:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BDB13ED7D; Mon, 1 Aug 2022 04:49:59 -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 2D349B81163; Mon, 1 Aug 2022 11:49:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EB10C433D6; Mon, 1 Aug 2022 11:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1659354596; bh=oh0QFq70671r6ZqWHLWs0sNiAlab5iRxCQoY88xlmGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XF8Jmfl/8lzSKcX22h4yzik8pdLZ/lvwHXuR5htrG6plhHDfgz8xwXkzkFsmmlINi aqbcEsu8be5ag3QoMBTWppd1crWDSM9zOLkMtcgDU+tWw4lR/+xnrKY7jYFrYL7jCj woZQFC+8+mJiflx3siqo4rk9dH7uugfy4yP4Ziks= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" Subject: [PATCH 5.10 18/65] tcp: Fix data-races around sysctl_tcp_moderate_rcvbuf. Date: Mon, 1 Aug 2022 13:46:35 +0200 Message-Id: <20220801114134.477754607@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220801114133.641770326@linuxfoundation.org> References: <20220801114133.641770326@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.7 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 commit 780476488844e070580bfc9e3bc7832ec1cea883 upstream. While reading sysctl_tcp_moderate_rcvbuf, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_input.c | 2 +- net/mptcp/protocol.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -693,7 +693,7 @@ void tcp_rcv_space_adjust(struct sock *s * */ - if (sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf && + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf) && !(sk->sk_userlocks & SOCK_RCVBUF_LOCK)) { int rcvmem, rcvbuf; u64 rcvwin, grow; --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1421,7 +1421,7 @@ static void mptcp_rcv_space_adjust(struc if (msk->rcvq_space.copied <= msk->rcvq_space.space) goto new_measure; - if (sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf && + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf) && !(sk->sk_userlocks & SOCK_RCVBUF_LOCK)) { int rcvmem, rcvbuf; u64 rcvwin, grow;