Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3708603pxb; Mon, 24 Jan 2022 16:00:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdbFi7PJFq7FQgOpcyUmYY0rvvlpR2IUOGYHRK6JiQ2cw34P9nRBtoQM/AQvXo37Dxy2cx X-Received: by 2002:a17:902:d487:b0:14b:1bd7:fe69 with SMTP id c7-20020a170902d48700b0014b1bd7fe69mr16153325plg.148.1643068694469; Mon, 24 Jan 2022 15:58:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068694; cv=none; d=google.com; s=arc-20160816; b=mkSkg+0G343UAR8hnx3p4p/VqunUgSA++2mldYygawoAgMxntw/tj82Toc5A52rxaP lG9cn0oXlyruY6YWccliUzFlAX3zECtMdCyNDO1ey9rFiEuQCPmWXfTlXunbXf/YA0QT gtSFjln7nroVzNHUiAGAr66MnLr2wWo/3iu90+FtvI2xobz9G0fXSn6mfrXpJZRYCWZW Q9/ubx92Btvn9bAJbHhL301ObbfslJFVkMGkCjuAyzBRzsC/kau2LT85QZwm0qshhHHJ s7wYsMPELCxRNNjezeNiGnvQY6RBGSIkG85kYWFk+uWSRJmlM3VHlNQSdpOjcNDPtWqH MtzQ== 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=yo/E3cuqT9O/YYZbF9WCm8fAQgheRjLbQOLjGnFGY6k=; b=ljXuP83hYcduj3LDNZbKtDM06Q+YtqofPCvbyUfxHruaCB/Mo5WBB+5n+zrZCR7N7u HFgvuPCY40r2Zma2bbo+7rtIjQ+o9xp7oWbeawfAcPE/hVJsNQn9Oi/aVJd2vFKzzXXW +jHcD0OITAEEu0NyfO0a1sRBAPf2yutceGZvu+uBw2lh3GZQ3jCrZPyiqSRIAvpCpv6i /I885/phEnaQ8xgdUZMOLdLGy9e6zSzg/G3AquqgC33kLiDJ7eH1eM7ElXBDnZ5XFvAi BrPERinrh066RkmdTPd10OLLe+0rdy2WHEuv6n7tnp9NEnWB1RR7ErNRyD1SIToKkZ81 MH1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CnuSWAk2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si14873363pgl.629.2022.01.24.15.58.02; Mon, 24 Jan 2022 15:58:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CnuSWAk2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2365899AbiAXXv4 (ORCPT + 99 others); Mon, 24 Jan 2022 18:51:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1843471AbiAXXED (ORCPT ); Mon, 24 Jan 2022 18:04:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0658DC06C5AB; Mon, 24 Jan 2022 13:14:48 -0800 (PST) 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 981AB6147D; Mon, 24 Jan 2022 21:14:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 812FCC340E5; Mon, 24 Jan 2022 21:14:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058887; bh=ZCpHyFJAoXnEja1vJbnmNPOXxj+CVxDmB0m9DLqkUr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CnuSWAk2T+/zVGkKcEaKvHGUvV3mRHe2TtGXBdfNTMdkZAJ3cWZjeDw89aWDmruVf oQi4puFUtIzdA6mb2ji2TLK45dljQn2wSA8rCJ3peeyg6YHLMB70tiW/GnbsXE5enu 8mripOUEXFxKaacZj3ZrQ19sNHJnnVSMsmTO8hXM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maor Dickman , Vlad Buslov , Roi Dayan , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.16 0407/1039] net/mlx5e: Fix wrong usage of fib_info_nh when routes with nexthop objects are used Date: Mon, 24 Jan 2022 19:36:36 +0100 Message-Id: <20220124184138.990561002@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maor Dickman [ Upstream commit 885751eb1b01d276e38f57d78c583e4ce006c5ed ] Creating routes with nexthop objects while in switchdev mode leads to access to un-allocated memory and trigger bellow call trace due to hitting WARN_ON. This is caused due to illegal usage of fib_info_nh in TC tunnel FIB event handling to resolve the FIB device while fib_info built in with nexthop. Fixed by ignoring attempts to use nexthop objects with routes until support can be properly added. WARNING: CPU: 1 PID: 1724 at include/net/nexthop.h:468 mlx5e_tc_tun_fib_event+0x448/0x570 [mlx5_core] CPU: 1 PID: 1724 Comm: ip Not tainted 5.15.0_for_upstream_min_debug_2021_11_09_02_04 #1 RIP: 0010:mlx5e_tc_tun_fib_event+0x448/0x570 [mlx5_core] RSP: 0018:ffff8881349f7910 EFLAGS: 00010202 RAX: ffff8881492f1980 RBX: ffff8881349f79e8 RCX: 0000000000000000 RDX: ffff8881349f79e8 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffff8881349f7950 R08: 00000000000000fe R09: 0000000000000001 R10: 0000000000000000 R11: 0000000000000000 R12: ffff88811e9d0000 R13: ffff88810eb62000 R14: ffff888106710268 R15: 0000000000000018 FS: 00007f1d5ca6e800(0000) GS:ffff88852c880000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffedba44ff8 CR3: 0000000129808004 CR4: 0000000000370ea0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: atomic_notifier_call_chain+0x42/0x60 call_fib_notifiers+0x21/0x40 fib_table_insert+0x479/0x6d0 ? try_charge_memcg+0x480/0x6d0 inet_rtm_newroute+0x65/0xb0 rtnetlink_rcv_msg+0x2af/0x360 ? page_add_file_rmap+0x13/0x130 ? do_set_pte+0xcd/0x120 ? rtnl_calcit.isra.0+0x120/0x120 netlink_rcv_skb+0x4e/0xf0 netlink_unicast+0x1ee/0x2b0 netlink_sendmsg+0x22e/0x460 sock_sendmsg+0x33/0x40 ____sys_sendmsg+0x1d1/0x1f0 ___sys_sendmsg+0xab/0xf0 ? __mod_memcg_lruvec_state+0x40/0x60 ? __mod_lruvec_page_state+0x95/0xd0 ? page_add_new_anon_rmap+0x4e/0xf0 ? __handle_mm_fault+0xec6/0x1470 __sys_sendmsg+0x51/0x90 ? internal_get_user_pages_fast+0x480/0xa10 do_syscall_64+0x3d/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae Fixes: 8914add2c9e5 ("net/mlx5e: Handle FIB events to update tunnel endpoint device") Signed-off-by: Maor Dickman Reviewed-by: Vlad Buslov Reviewed-by: Roi Dayan Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c index 042b1abe1437f..62cbd15ffc341 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c @@ -1579,6 +1579,8 @@ mlx5e_init_fib_work_ipv4(struct mlx5e_priv *priv, struct net_device *fib_dev; fen_info = container_of(info, struct fib_entry_notifier_info, info); + if (fen_info->fi->nh) + return NULL; fib_dev = fib_info_nh(fen_info->fi, 0)->fib_nh_dev; if (!fib_dev || fib_dev->netdev_ops != &mlx5e_netdev_ops || fen_info->dst_len != 32) -- 2.34.1