Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3055102rwe; Mon, 29 Aug 2022 05:13:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR46sQxeJWx8QiF9/olw+jSQjG1YuJQWHylUpfQy4eArOHkdseajjpNdolwGsIk/BI8ZcbQU X-Received: by 2002:a05:6402:1e8c:b0:448:8842:d843 with SMTP id f12-20020a0564021e8c00b004488842d843mr2254625edf.353.1661775214144; Mon, 29 Aug 2022 05:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661775214; cv=none; d=google.com; s=arc-20160816; b=WQfIKykUwdJLcm3jSX/ytF2LsAbuuxI5olD/hDaUNPa7mKG1LQXqlgyz/T8Ta7qzyD GfXQkSOE9+8idSJtz8iJ6PwYRbxfOWhnem+aXmrTUu+0t+TTgmPXUkr7LX33+0LFS+6U xKCtwiEOO6CXUTAV7krozD09FSObN8jM2CLBojO0iwLy93KfvQlsz3bJuq32YJ4ignKA nWZf1Mw/tJstuYcJUMTGTZ84sV22IuU3pgEkn3jp0lD7O0GdbMxTuaua1jXPXjcghNNK kwK98lvEe0dVBOO+NCizxxgtiA4KVxyCIJnxzZCT/CvSbco/dMh7ucyL8eA+ftYXbrD+ 5UEw== 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=IYBBlZohaFPe9GnmOcMprWfD3lqkPhVJOQ++zdkIhbc=; b=in6ezbtb4oFSu76MIY0dHvCem58B/OOOuTuZ43WjrsCg7tvDKBTPv3jfdK7I4mISal ozo2RVfdSNIt/AW8u3PP5rGGA/E0iv7Cm2XEHCMQ8EpDsN95MBELzORNJKNroQOZ8mjZ bierLEEatkgl4aUleTWtkxpvnTHlcYF3DjcEPLERqbdcOwvqUl6MJA1BqpyMsDJTlda9 llCR6Ac4Ah7ZI0XsSKOgvX/0cm2C93efFep1oyucJT0LMZpYV9ldJOgqtwfHsUMAe3OA V++8CVaVIJ6OhOMlbcFKVToZMrVB3/eSLJXoIFaqnpPbw0l9x1d/Rv2FTHTP3KOerkHF PpYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gwIFTdft; 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 qb26-20020a1709077e9a00b0073d6c94fc3dsi6870413ejc.162.2022.08.29.05.12.45; Mon, 29 Aug 2022 05:13:34 -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=gwIFTdft; 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 S231826AbiH2L1X (ORCPT + 99 others); Mon, 29 Aug 2022 07:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231863AbiH2LYw (ORCPT ); Mon, 29 Aug 2022 07:24:52 -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 64E5D76946; Mon, 29 Aug 2022 04:15:51 -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 618D6B80EFD; Mon, 29 Aug 2022 11:15:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7456C433D7; Mon, 29 Aug 2022 11:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771728; bh=hneoOVPcVJsmleSHy5/jExhdlIPPX+C5FJSORxGPzik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gwIFTdftkT5AtntIPKhrknm3Mw5tgPURKwIGlOinsRdnVP5Fx1YpPZyvoZgxdDM0O Vq0Ay3+us8SChB7KL7GlNtxGVMG7gDftgcbGtN8XSjaVOg9cSlNuD9uf0cy/NljJVu xHfRCBY2sMc6gXRZLyO5mo8tJ+KAbNgmelzmYPnY= 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 075/158] net: Fix data-races around sysctl_max_skb_frags. Date: Mon, 29 Aug 2022 12:58:45 +0200 Message-Id: <20220829105812.175757083@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 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 3ae2ea0488838..3d446773ff2a5 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1000,7 +1000,7 @@ static 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; } @@ -1348,7 +1348,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 3d90fa9653ef3..513f571a082ba 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1299,7 +1299,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