Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp497970imn; Wed, 27 Jul 2022 11:54:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vEc/OPTRwiorxHz75FDql1FFRIgDpCvWnLglPMx9aolBWLpdhB2Gc+5ASd92gfoVQ1vg2c X-Received: by 2002:a17:906:93ef:b0:72b:3e88:a47 with SMTP id yl15-20020a17090693ef00b0072b3e880a47mr18715912ejb.706.1658948045310; Wed, 27 Jul 2022 11:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658948045; cv=none; d=google.com; s=arc-20160816; b=06V7DWGeurwrtiTzBipl0F0LdZ8gL1jrN+urais2+sxKIgUXvf7Mm2xUOPMvUabeQw QjC40m8cahYsAiUn4oF249tWENcf4NKValoeOwOSTM61QHDKKhaVc0WSPjcpR5VPzktE 1HbqQBgfaYykr1qh0h9vE00ev/RSJlD22XOJKNVO22Sonzh6WUNSUeUOcdTjBazTY3oN 9yR6hMC025ME4eOieewcHa9S+ZdQ1giH4n1MUs+Oe1ebY2NCAGQ/RMyKZ605UYJv/zLo D/Byh7Dc/X+vpdMMcfEfI3E8fbB+MRJ7RjSuyi18HvGMmFiRtVID0AZbZRk0HdBZbPor upGg== 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=3VvdN7RFOss1d2MDp8JmjUsv/iHrEfOKP+NrE3xZM6g=; b=YobofjAQmxyEDSfPc9grdCxzE/v08eGM2dHLic3cm19bAhO4JG4aPTai63LCJ4isLg ot+X69kJ+fguLOF0FW+gDQ1Cm0/n1RvPPpH2pSqHEpgJWuhhUj9E3aNESusHbR4uaxWP TJrEeKoyfQWHVooZJNMTvLXp1WXz2xHpbFCN6SUMh6gzzANBJfU02OFZin7Hw65jPa1g WyftG+GH0QIq34Hjc4xgJGmABsPEx4p+EzZnrIYWEnLqvWrTGwPzU3tzKU+7mvNE6U9s y2/2O+cOnPdc5ej9/4ICQjLE/agIM4ESFUVFiiaHgXec9CG/qf1DnmfI8PPBJV9Z2SSa NpqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wSuAwFsu; 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 c10-20020aa7c74a000000b00435799ce323si16516785eds.190.2022.07.27.11.53.40; Wed, 27 Jul 2022 11:54:05 -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=wSuAwFsu; 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 S232868AbiG0RFz (ORCPT + 99 others); Wed, 27 Jul 2022 13:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241608AbiG0REk (ORCPT ); Wed, 27 Jul 2022 13:04:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8B344E60E; Wed, 27 Jul 2022 09:39: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 dfw.source.kernel.org (Postfix) with ESMTPS id 65190601D2; Wed, 27 Jul 2022 16:39:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 695E4C433C1; Wed, 27 Jul 2022 16:39:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939959; bh=2vd55fXTxnJeCDvZnoUJYpKKNmBwqMVbZenpWU+mA8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wSuAwFsuP01GGiN2LZAc76kvJ84rCx1Uwq0lsekEwQ/A3xaERPqqr3uy60Ar7M4Mb 7Nh0fwoxASgSdkDw8t44qJNY0aAjAbzslvbbimPjSzSXnuchxnCIyAZIoKCuy/F8Tq 5riijQRnTCNPO5Xe2cVFfgbASSy/wnUG5kQ/6KTA= 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 056/201] ip: Fix data-races around sysctl_ip_fwd_update_priority. Date: Wed, 27 Jul 2022 18:09:20 +0200 Message-Id: <20220727161029.244221383@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161026.977588183@linuxfoundation.org> References: <20220727161026.977588183@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 7bf9e18d9a5e99e3c83482973557e9f047b051e7 ] While reading sysctl_ip_fwd_update_priority, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 432e05d32892 ("net: ipv4: Control SKB reprioritization after forwarding") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 3 ++- net/ipv4/ip_forward.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 6ef4ca8599ac..d17156c11ef8 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -9787,13 +9787,14 @@ static int mlxsw_sp_dscp_init(struct mlxsw_sp *mlxsw_sp) static int __mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp) { struct net *net = mlxsw_sp_net(mlxsw_sp); - bool usp = net->ipv4.sysctl_ip_fwd_update_priority; char rgcr_pl[MLXSW_REG_RGCR_LEN]; u64 max_rifs; + bool usp; if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_RIFS)) return -EIO; max_rifs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); + usp = READ_ONCE(net->ipv4.sysctl_ip_fwd_update_priority); mlxsw_reg_rgcr_pack(rgcr_pl, true, true); mlxsw_reg_rgcr_max_router_interfaces_set(rgcr_pl, max_rifs); diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c index 00ec819f949b..29730edda220 100644 --- a/net/ipv4/ip_forward.c +++ b/net/ipv4/ip_forward.c @@ -151,7 +151,7 @@ int ip_forward(struct sk_buff *skb) !skb_sec_path(skb)) ip_rt_send_redirect(skb); - if (net->ipv4.sysctl_ip_fwd_update_priority) + if (READ_ONCE(net->ipv4.sysctl_ip_fwd_update_priority)) skb->priority = rt_tos2priority(iph->tos); return NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD, -- 2.35.1