Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6266933rwb; Tue, 9 Aug 2022 12:04:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR4dj/jAs82BSKGAauju/xpqYGf1y6Ck6GkIDDnRWMBzwk488cVWcFPE8kpWGTkJNwiV5SzJ X-Received: by 2002:a05:6a00:a8a:b0:52f:190e:a679 with SMTP id b10-20020a056a000a8a00b0052f190ea679mr13751549pfl.79.1660071875327; Tue, 09 Aug 2022 12:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660071875; cv=none; d=google.com; s=arc-20160816; b=nN5xJKidBzO64GNyO4TZ54uP1ZAwsQ7uaRIxeS3SLE28wyxNpCvatyon26LzuVcXt6 NdVA+7Qyu2bZiPhrvAI3cEBsRylp7a/uNFB7V82bEczJbCAeY+i9gZfrngNk/pDH9090 sEjM2/WH7vUnwoenMJpJeSWiGRPEAVhf3iOjr2DyU5Ol+9wbRHzLlo5xLWFXBBAst80n UvnNsQ7IsJUBsEWU5ggJS4NY6Os690LYDjAOCFgyY9S/WaxH4xTkYajHDaxuCd9gGpF5 bLPRgpuBilwLOuIqMOjrv64Q5F9AM0qBNL7dRRVnmrxu/sxg4LQZivuaAzxIM6Tu/f1Q cWgA== 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=L100wG+xPuzs8ya7tb5cyOATwiA9i0j/G736ZGLCKTU=; b=kr58ArzWEl7QYXBjqksdvvRJYWKf77hzdx5bL7JuUv1/C6+5KFlL8f0xqh9vCHpGgp CFDouWN23BW8LOdToEke/UJyukmhRTA4MON0/e1NPgery3EPeEY9+siKpPxybA/ULix1 5hIyOipj8O7R4sZ8XErZ5J5VRfXjp4R9jdHtzGr94vWmNZ/hrZBwiaiaUSnK2wdODcyD 1p/WE8dNQiQYslGTZjk1smAeH4IT2oELbFY8cT6VrDGAe5YERZc0vyZrStJjAdPOcPmU Y5Ixr14gkAnVVrSygdHaFDlSLpJc760QRm6KyTPRZPJj0ACRGFUvHwLJGi7ZHW+eRt5j GR2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jAUKcGds; 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 rm13-20020a17090b3ecd00b001f4df89edc4si17834211pjb.52.2022.08.09.12.04.08; Tue, 09 Aug 2022 12:04:35 -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=jAUKcGds; 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 S245325AbiHISF4 (ORCPT + 99 others); Tue, 9 Aug 2022 14:05:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344658AbiHISEr (ORCPT ); Tue, 9 Aug 2022 14:04:47 -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 30F1D2714E; Tue, 9 Aug 2022 11:02:23 -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 81ADA6101C; Tue, 9 Aug 2022 18:02:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87F6BC43470; Tue, 9 Aug 2022 18:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660068141; bh=sTA3hE0yPZpR1noreH2827Yh1FajznPrRSsblFg38eQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jAUKcGdso4E0P/UUkfp2mAKANEyx1xj4dEx3ejmWok3pMWB+r0kCzoyV/eS3hj+q/ G7VUcGiHX0ExGTH314GJrGhQNohLzqSpJ/9e5wXVoj6q8q4SPHLIA/4r7LIMJf9akw aqcpvxpif/EEysmVyFy8hFwPwuLKJDQkOCpijCDU= 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 4.19 16/32] tcp: Fix a data-race around sysctl_tcp_autocorking. Date: Tue, 9 Aug 2022 20:00:07 +0200 Message-Id: <20220809175513.602497816@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220809175513.082573955@linuxfoundation.org> References: <20220809175513.082573955@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,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 85225e6f0a76e6745bc841c9f25169c509b573d8 ] While reading sysctl_tcp_autocorking, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: f54b311142a9 ("tcp: auto corking") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 7acc0d07f148..768a7daab559 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -706,7 +706,7 @@ static bool tcp_should_autocork(struct sock *sk, struct sk_buff *skb, int size_goal) { return skb->len < size_goal && - sock_net(sk)->ipv4.sysctl_tcp_autocorking && + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_autocorking) && !tcp_rtx_queue_empty(sk) && refcount_read(&sk->sk_wmem_alloc) > skb->truesize; } -- 2.35.1