Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3046887rwe; Mon, 29 Aug 2022 05:06:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR6i2ZzA7aTYaPC2yqIt+hyxkkGb6dmzSmd1NOxJeFZTmUR2+doYvI3HF7Yku9bXScQMjGws X-Received: by 2002:a17:906:9bf0:b0:741:362a:3ff1 with SMTP id de48-20020a1709069bf000b00741362a3ff1mr8877853ejc.275.1661774795567; Mon, 29 Aug 2022 05:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661774795; cv=none; d=google.com; s=arc-20160816; b=uzvp26kr455kXGkfF6yNSsoi6W5hKin4YFhrPQMZeFOw8/r1XnPz5x6MqbYOLZSyms wjxEWSQ76hGnVw+w+1DaNtf98lL11syNyWb9QdR2NA1XOL9xBm+Wf0lPHYqsHVc4nI2b VKoV3TPIhFdy58bY+3oOKHgQVSK3HrmAL4xi4te6hCqulFTJgVMvA2uppuzDoCX3DXJv Gm81IW+9o72pR6Jomfv6KZBcMWPp2yeYALVl9YOil+G36jdugQtAIitQEATvFfdLHiJp ajuFZkjfVzDe4voxChN/TURC/5PdOBnH71F67cdf1XL5S1qm5nPjfyEGy4FMKNhVFwuY 5hDA== 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=85hU6K7LTTA5eAwKsy3raUjiu+pgH5sI0jiBVFCjSso=; b=0wElAPkdW/0diHRdy0SB5Gwplidlwtd5lfhO0VqvLVMCScrUpuhMtameYXBTD76SFy z6hHWtdQA8bZpUMBEs773ZPrSy7f7RfmKCvkHe2L+bTU1m1fVHLD1q+rLvepUKc8byZh t5GyUxg63fSMInO9nsFDoubppX2VzDLZwF51JOXHyblS3ZvKzcNWYvoooMuNh85NreNg cDD6ugSMCTs5Yz3zT0BvBMvhIF5pjgwFafTadPDzmO4manjVUhUUoeh1i6aHu846WLB4 kKwSGnWIu6I1xLLizgToqbk4tzW3uiaKJ/7tXoNxFR7+RNO2bNsXN/9nhvNzzygbBHOA r3Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=coHuRp3g; 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 gt17-20020a1709072d9100b0073d7ad9607bsi7238132ejc.551.2022.08.29.05.06.09; Mon, 29 Aug 2022 05:06: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=coHuRp3g; 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 S232366AbiH2La0 (ORCPT + 99 others); Mon, 29 Aug 2022 07:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232440AbiH2L3A (ORCPT ); Mon, 29 Aug 2022 07:29:00 -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 066C97A745; Mon, 29 Aug 2022 04:17:20 -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 D7F58B80F10; Mon, 29 Aug 2022 11:07:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC1DFC433C1; Mon, 29 Aug 2022 11:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771235; bh=yjoZOiEcvdnTyVB/vFAkaEAvDwwad/7SbJUYxTfTwBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=coHuRp3gXTLNNKa/hLQLyUuHvXBEF5rcxbjPRiuQGiXxZYtYmureWJGiOA59oo/F4 ZnhK4CdJK3XlkRXNl/H4J+jXtH9/7mfpdLkR6sjidbMxyywppaOQlMPkuJJN3ZpxOb 4+XXoRXw4+F4M6B909wesUyNbXPbaZjK1ZSC+lv0= 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.15 082/136] net: Fix data-races around sysctl_max_skb_frags. Date: Mon, 29 Aug 2022 12:59:09 +0200 Message-Id: <20220829105808.008903886@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105804.609007228@linuxfoundation.org> References: <20220829105804.609007228@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 657b991afb89d25fe6c4783b1b75a8ad4563670d ] While reading sysctl_max_skb_frags, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 5f74f82ea34c ("net:Add sysctl_max_skb_frags") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/tcp.c | 4 ++-- net/mptcp/protocol.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 52f51717f02f3..0ebef2a5950cd 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -991,7 +991,7 @@ struct sk_buff *tcp_build_frag(struct sock *sk, int size_goal, int flags, i = skb_shinfo(skb)->nr_frags; can_coalesce = skb_can_coalesce(skb, i, page, offset); - if (!can_coalesce && i >= sysctl_max_skb_frags) { + if (!can_coalesce && i >= READ_ONCE(sysctl_max_skb_frags)) { tcp_mark_push(tp, skb); goto new_segment; } @@ -1344,7 +1344,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size) if (!skb_can_coalesce(skb, i, pfrag->page, pfrag->offset)) { - if (i >= sysctl_max_skb_frags) { + if (i >= READ_ONCE(sysctl_max_skb_frags)) { tcp_mark_push(tp, skb); goto new_segment; } diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index a089791414bfb..5df60a4b09304 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1317,7 +1317,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, i = skb_shinfo(skb)->nr_frags; can_coalesce = skb_can_coalesce(skb, i, dfrag->page, offset); - if (!can_coalesce && i >= sysctl_max_skb_frags) { + if (!can_coalesce && i >= READ_ONCE(sysctl_max_skb_frags)) { tcp_mark_push(tcp_sk(ssk), skb); goto alloc_skb; } -- 2.35.1