Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp477210imn; Wed, 27 Jul 2022 11:17:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ua9wRUVAt31PoIU30LQMDtGO18c8WX0Rg4HFzMSgRHJR+9KvdKJhppWS4qR4DkBOTGi9TV X-Received: by 2002:a17:907:2ce9:b0:72b:30e5:f1bc with SMTP id hz9-20020a1709072ce900b0072b30e5f1bcmr18486647ejc.127.1658945844286; Wed, 27 Jul 2022 11:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658945844; cv=none; d=google.com; s=arc-20160816; b=V0B4i5b9uypz/iU70sHbC7ZM52v7benmcBnUliJsF3CP9LueXIK+ocfR9dUczGVUD3 t8bT+4V7yUmgrpKrG+Iz5CYKt+M1a9GX2WzDeq1W3JskYF/iwsxkgUNu5U1Uo3iF9rff dyLO5TkiHUKevWZmnfz293eXxhtqW8umOVCtOLj/yoyRfYwHf3JjPkbY86s3D1iURx/w Bo2TeyeiJuX5eEFvCtk9g2HFRVghaDk93AimDClCGBtJlkf7nOtUiSjj5Vp8kF8uO+x3 FWcpaj7HY/gKSS6jEThnWt1MNVJ86PtnXf094mrFaUkyt5Bb7Dx10/i22gMotJYixdg+ wc4Q== 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=XVtd89f8OAwQX+d1FkdB915sgKALlV16Iuc+6Lne9Vk=; b=MVi7cfpVvE+3VnRTkzOkRP8wppesWb/xie6rwirmMoZl0UtneiUfyu2UMDWc6kf/KY kXls6zVdx2n4l+eX+UndrpRfamBOn30/+V4xqTX7ZSoz4jvq4Gc6BWgotsvGH7go5pYT y4g9Be5h7aqDhmE0Qg4UwRkWM/Xrygl/OWe6W6xss1saG9rEHXgNHjA+RRM98I5/3kg9 trRXPIozeEblMU6Jn1zlMSNNXyy30j3q2IF648UksO1N1nmiOz8g2iVPX38ZbIL4t0MT BdcAmBpBc/ps7+/+ByCxtTH7GKHdcoTBa1cA8KB6e2GpBZpUuN3xBov+fyELgugwyj13 yivQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qd3j45M7; 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 hb33-20020a170907162100b0072b4a6fd638si21596757ejc.543.2022.07.27.11.16.59; Wed, 27 Jul 2022 11:17:24 -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=qd3j45M7; 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 S235743AbiG0QbR (ORCPT + 99 others); Wed, 27 Jul 2022 12:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237446AbiG0Qal (ORCPT ); Wed, 27 Jul 2022 12:30:41 -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 7DCBA5247E; Wed, 27 Jul 2022 09:25:28 -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 4C6DC617EF; Wed, 27 Jul 2022 16:25:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55C4BC433C1; Wed, 27 Jul 2022 16:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939116; bh=HaPcLU8OTjq/O0rBKkVeU0xDiBOTbO2unGt7nLpjxW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qd3j45M7StFg0v59aBfnVpx7lnyVh1kVNSr2Yt8ssgGx7EikG2HJvBki1RPoAsVWz gLnjwMKhQq5WW8DDQO9gzjxdW+Dd24V9uzF36xNMR8HHCz6VuN/koNfv4w9B9p4OiL 1AnX5BzJtpwBeDY7FXiMM+4A2gvVKB6512sA6UO4= 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 07/62] ip: Fix data-races around sysctl_ip_fwd_use_pmtu. Date: Wed, 27 Jul 2022 18:10:16 +0200 Message-Id: <20220727161004.448768084@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161004.175638564@linuxfoundation.org> References: <20220727161004.175638564@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 [ Upstream commit 60c158dc7b1f0558f6cadd5b50d0386da0000d50 ] While reading sysctl_ip_fwd_use_pmtu, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: f87c10a8aa1e ("ipv4: introduce ip_dst_mtu_maybe_forward and protect forwarding path against pmtu spoofing") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- include/net/ip.h | 2 +- net/ipv4/route.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index d1a4efedbc03..471463bfe6f9 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -402,7 +402,7 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst, struct net *net = dev_net(dst->dev); unsigned int mtu; - if (net->ipv4.sysctl_ip_fwd_use_pmtu || + if (READ_ONCE(net->ipv4.sysctl_ip_fwd_use_pmtu) || ip_mtu_locked(dst) || !forwarding) return dst_mtu(dst); diff --git a/net/ipv4/route.c b/net/ipv4/route.c index d7f17581df7d..57e2316529d0 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1419,7 +1419,7 @@ u32 ip_mtu_from_fib_result(struct fib_result *res, __be32 daddr) struct net_device *dev = nh->nh_dev; u32 mtu = 0; - if (dev_net(dev)->ipv4.sysctl_ip_fwd_use_pmtu || + if (READ_ONCE(dev_net(dev)->ipv4.sysctl_ip_fwd_use_pmtu) || fi->fib_metrics->metrics[RTAX_LOCK - 1] & (1 << RTAX_MTU)) mtu = fi->fib_mtu; -- 2.35.1