Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp473514imn; Wed, 27 Jul 2022 11:11:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uqKOe2lG8kANwU6GGa5dqa5ALR1Ifm5VQE46jCKTHFgXfk7Q71elo9QS5dQ2PWYj40r8cF X-Received: by 2002:a17:906:58d6:b0:72f:25c0:af2b with SMTP id e22-20020a17090658d600b0072f25c0af2bmr18415804ejs.326.1658945479499; Wed, 27 Jul 2022 11:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658945479; cv=none; d=google.com; s=arc-20160816; b=NO2d/sNlKVP92V0RczwR9Wj0h1tGq9kpM0qN9Bne7BtEFXLyEo4Lery60ZltaL+ExF sOXa6mU3tov3/E5jMWPwcSm2L16C0WeKY/nrA7vv8+ny+JJg8/wv8SBKiVcq+wBODN+E YfFoq7c3nFFfjgRPs590coPO2+dtjCxBIfxHIUGXSnIaRWFBTt2PqM2YJ+51OGzJvprh zGrz+TgTVay0H2Gjt2NCfg2Jjakz4H/4WuN5svfte9r84HTHVDxK/zzlcE+vo4VpEg+y RFhwg5XznSVN2KUAnMvUgJ7yXQKCHnrK2p3VW4po3kAxts+fg5MQjTXbPe6/5X/htI+8 kS2Q== 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=YGJpTrPsZ5oOEHwcNs/vMKSmHDbAAeWEHYPtapN0pE8=; b=WNciYj9Aa2dfWbZPbF1M45Luc4DpCtnFSezleFiSeCVEHqE6t+K2NkNw4VOLIQ9Lym 9kKqHoBvwEaTzN+vsW3DwpT2O8pCasMsMqfL/ophWPxMfredggve3/ysineRwqm0JHj7 ANQzirVQ2PJMRXa7FYFUQCXh3rYDrpF7rLh74Q4U2Y7qmtnE/XtOT6OPMP5x2HPzfpya Na6jXabOEXVZof8dZvMWcpWddAMsup9tbc5xLpkcL8Od5xJy/qKA/hox25uOfoEeZRMw GUkDhu7mNFZsQcoHJfmJBrKDhF7oIY9KopfXiptCaNyK1667F5+C/Y/fZZKltl+jqHwt 09nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w6AQp3hx; 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 sc34-20020a1709078a2200b0072f1b3ebaafsi22483035ejc.136.2022.07.27.11.10.54; Wed, 27 Jul 2022 11:11:19 -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=w6AQp3hx; 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 S240664AbiG0Quh (ORCPT + 99 others); Wed, 27 Jul 2022 12:50:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240786AbiG0QtZ (ORCPT ); Wed, 27 Jul 2022 12:49:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 295954E86A; Wed, 27 Jul 2022 09:32:55 -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 6E9ADB81F90; Wed, 27 Jul 2022 16:32:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6204C433C1; Wed, 27 Jul 2022 16:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939573; bh=U7SjzZ87V97EDXdPPtKXqWDbu9YvGTtPAJ7iSO2QroU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w6AQp3hxrMixzMpF9VZsnflX2N11FrqXWPZZKaKKX4s6F4o5zkJ8/oS0saaTV9Wbx RGfHhVe3HPeMju0qdHNwyX4JW+0K/41ICqQMMUQ/qQnPkiN0YmvYip/KBADz1v8rL8 0Z+U6TqRCVCgohZeGvLugedl83x+jfu8c+vOJr78= 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.10 029/105] ip: Fix data-races around sysctl_ip_fwd_use_pmtu. Date: Wed, 27 Jul 2022 18:10:15 +0200 Message-Id: <20220727161013.272212651@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161012.056867467@linuxfoundation.org> References: <20220727161012.056867467@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 76aaa7eb5b82..a7e40ef02732 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -440,7 +440,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 aab8ac383d5d..374647693d7a 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1442,7 +1442,7 @@ u32 ip_mtu_from_fib_result(struct fib_result *res, __be32 daddr) struct fib_info *fi = res->fi; 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