Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1027727yba; Thu, 4 Apr 2019 02:45:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqw51LuqV+J9XuwUDt8YraWodZ7cIDIf1okqf/O5LK6S33offKXdIP8OM4BMakcuRojxa6og X-Received: by 2002:a65:62c9:: with SMTP id m9mr4496496pgv.309.1554371146067; Thu, 04 Apr 2019 02:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554371146; cv=none; d=google.com; s=arc-20160816; b=B8VNK2Rr4rALDVyaqBEFBEeu0+kSbYj7d1UFkfTjVVE5QGVa5avNSjKsCd2xATJSkM hkEb5iAZA9CNtR0bLx6R0fZAKRmgeATWWKYsJT9vsJbPxpKXJVj0cxY7SXzI2oW6i9AE furg7WXPxgk4UvB2o7Gi32plHjflbbhscgPtx3ra95cTc6U/qao/9IETSV/jrm0OUdqi YbXQenkmF2MEdCdKBpp26to+DUszLaGl0BDn0D7+MbuvnazZLWq8N0yIknQ8Hiihb9Wf nSfLP2GUPrp9rjgb8xQb1TVXVuQIYLRcgE7cLpN3tFhCLzo5JhhPML2txMEk8qls4fX5 2HEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u2T3WMl3BGd6jCAf65FNmHzbjnS8cmBJAgvCYzx5Uac=; b=FoXlaILMR+DxExk+3ExARmv15C4wntORlma5jkSDY/+x1XYr9toynTFHSbrbi/IgqD 5aBBiKwdsXnTGcndr1aMXeeK/i40xbTyxPxGXplSjKjlcn/9O8B9Oy/4M0ejJ9FiF6J3 LI8lK3O8wvdJo9i4ngux9XAdiad2EAGm1WT8h3RvWpZ+AW50g3gToP5i8etybtCbxki8 BazbC46BwDFJ1HqZrcYr0eqhamAyISNA/BYn6TWj7iro5vSXgK+1QqOdFnZU+bhFibCR SjqwD7lKp1eTO3QNc/GtKHnWX4XcWpvwPqbT4SMK/WhkzWj8XTeVbHSc6z8fsDm9em3h 1mWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pnUu6qFP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d92si611656pld.100.2019.04.04.02.45.30; Thu, 04 Apr 2019 02:45:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pnUu6qFP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731284AbfDDJpA (ORCPT + 99 others); Thu, 4 Apr 2019 05:45:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:35586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731074AbfDDI7V (ORCPT ); Thu, 4 Apr 2019 04:59:21 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05D6920652; Thu, 4 Apr 2019 08:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368360; bh=erMtdow+xmMQDA4r64UWuase+NqFQdsGiKNW1u/x7d0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pnUu6qFPzYSlMRLQjetxPLnJHjoAqxULknkX+o5eeCFS35a2WPFB6YQ7azMQS15YF XkysR5nWnqJz99G1Wz8PPn9HBw34fYXuWW7cJXSLBh2R+AnQyEM09CulbJ8mlXWdte /SbrF79bkPd3Nj1mB0p0LYKgqpAVfGQtrrkolQ/0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eli Cohen , Tonghao Zhang , Roi Dayan , Saeed Mahameed , Sasha Levin Subject: [PATCH 4.19 011/187] net/mlx5: Avoid panic when setting vport mac, getting vport config Date: Thu, 4 Apr 2019 10:45:48 +0200 Message-Id: <20190404084603.640560892@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 6e77c413e8e73d0f36b5358b601389d75ec4451c ] If we try to set VFs mac address on a VF (not PF) net device, the kernel will be crash. The commands are show as below: $ echo 2 > /sys/class/net/$MLX_PF0/device/sriov_numvfs $ ip link set $MLX_VF0 vf 0 mac 00:11:22:33:44:00 [exception RIP: mlx5_eswitch_set_vport_mac+41] [ffffb8b7079e3688] do_setlink at ffffffff8f67f85b [ffffb8b7079e37a8] __rtnl_newlink at ffffffff8f683778 [ffffb8b7079e3b68] rtnl_newlink at ffffffff8f683a63 [ffffb8b7079e3b90] rtnetlink_rcv_msg at ffffffff8f67d812 [ffffb8b7079e3c10] netlink_rcv_skb at ffffffff8f6b88ab [ffffb8b7079e3c60] netlink_unicast at ffffffff8f6b808f [ffffb8b7079e3ca0] netlink_sendmsg at ffffffff8f6b8412 [ffffb8b7079e3d18] sock_sendmsg at ffffffff8f6452f6 [ffffb8b7079e3d30] ___sys_sendmsg at ffffffff8f645860 [ffffb8b7079e3eb0] __sys_sendmsg at ffffffff8f647a38 [ffffb8b7079e3f38] do_syscall_64 at ffffffff8f00401b [ffffb8b7079e3f50] entry_SYSCALL_64_after_hwframe at ffffffff8f80008c and [exception RIP: mlx5_eswitch_get_vport_config+12] [ffffa70607e57678] mlx5e_get_vf_config at ffffffffc03c7f8f [mlx5_core] [ffffa70607e57688] do_setlink at ffffffffbc67fa59 [ffffa70607e577a8] __rtnl_newlink at ffffffffbc683778 [ffffa70607e57b68] rtnl_newlink at ffffffffbc683a63 [ffffa70607e57b90] rtnetlink_rcv_msg at ffffffffbc67d812 [ffffa70607e57c10] netlink_rcv_skb at ffffffffbc6b88ab [ffffa70607e57c60] netlink_unicast at ffffffffbc6b808f [ffffa70607e57ca0] netlink_sendmsg at ffffffffbc6b8412 [ffffa70607e57d18] sock_sendmsg at ffffffffbc6452f6 [ffffa70607e57d30] ___sys_sendmsg at ffffffffbc645860 [ffffa70607e57eb0] __sys_sendmsg at ffffffffbc647a38 [ffffa70607e57f38] do_syscall_64 at ffffffffbc00401b [ffffa70607e57f50] entry_SYSCALL_64_after_hwframe at ffffffffbc80008c Fixes: a8d70a054a718 ("net/mlx5: E-Switch, Disallow vlan/spoofcheck setup if not being esw manager") Cc: Eli Cohen Signed-off-by: Tonghao Zhang Reviewed-by: Roi Dayan Acked-by: Saeed Mahameed Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index 886a4a77c47f..26c9f9421901 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c @@ -1797,7 +1797,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw, u64 node_guid; int err = 0; - if (!MLX5_CAP_GEN(esw->dev, vport_group_manager)) + if (!esw || !MLX5_CAP_GEN(esw->dev, vport_group_manager)) return -EPERM; if (!LEGAL_VPORT(esw, vport) || is_multicast_ether_addr(mac)) return -EINVAL; @@ -1871,7 +1871,7 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw, { struct mlx5_vport *evport; - if (!MLX5_CAP_GEN(esw->dev, vport_group_manager)) + if (!esw || !MLX5_CAP_GEN(esw->dev, vport_group_manager)) return -EPERM; if (!LEGAL_VPORT(esw, vport)) return -EINVAL; -- 2.19.1