]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.111/net-mlx5-avoid-panic-when-setting-vport-mac-getting-.patch
Linux 4.14.111
[thirdparty/kernel/stable-queue.git] / releases / 4.14.111 / net-mlx5-avoid-panic-when-setting-vport-mac-getting-.patch
1 From 80592284322c3234de75720a8d82c671bf3d182d Mon Sep 17 00:00:00 2001
2 From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
3 Date: Mon, 4 Mar 2019 00:27:15 -0800
4 Subject: net/mlx5: Avoid panic when setting vport mac, getting vport config
5
6 [ Upstream commit 6e77c413e8e73d0f36b5358b601389d75ec4451c ]
7
8 If we try to set VFs mac address on a VF (not PF) net device,
9 the kernel will be crash. The commands are show as below:
10
11 $ echo 2 > /sys/class/net/$MLX_PF0/device/sriov_numvfs
12 $ ip link set $MLX_VF0 vf 0 mac 00:11:22:33:44:00
13
14 [exception RIP: mlx5_eswitch_set_vport_mac+41]
15 [ffffb8b7079e3688] do_setlink at ffffffff8f67f85b
16 [ffffb8b7079e37a8] __rtnl_newlink at ffffffff8f683778
17 [ffffb8b7079e3b68] rtnl_newlink at ffffffff8f683a63
18 [ffffb8b7079e3b90] rtnetlink_rcv_msg at ffffffff8f67d812
19 [ffffb8b7079e3c10] netlink_rcv_skb at ffffffff8f6b88ab
20 [ffffb8b7079e3c60] netlink_unicast at ffffffff8f6b808f
21 [ffffb8b7079e3ca0] netlink_sendmsg at ffffffff8f6b8412
22 [ffffb8b7079e3d18] sock_sendmsg at ffffffff8f6452f6
23 [ffffb8b7079e3d30] ___sys_sendmsg at ffffffff8f645860
24 [ffffb8b7079e3eb0] __sys_sendmsg at ffffffff8f647a38
25 [ffffb8b7079e3f38] do_syscall_64 at ffffffff8f00401b
26 [ffffb8b7079e3f50] entry_SYSCALL_64_after_hwframe at ffffffff8f80008c
27
28 and
29
30 [exception RIP: mlx5_eswitch_get_vport_config+12]
31 [ffffa70607e57678] mlx5e_get_vf_config at ffffffffc03c7f8f [mlx5_core]
32 [ffffa70607e57688] do_setlink at ffffffffbc67fa59
33 [ffffa70607e577a8] __rtnl_newlink at ffffffffbc683778
34 [ffffa70607e57b68] rtnl_newlink at ffffffffbc683a63
35 [ffffa70607e57b90] rtnetlink_rcv_msg at ffffffffbc67d812
36 [ffffa70607e57c10] netlink_rcv_skb at ffffffffbc6b88ab
37 [ffffa70607e57c60] netlink_unicast at ffffffffbc6b808f
38 [ffffa70607e57ca0] netlink_sendmsg at ffffffffbc6b8412
39 [ffffa70607e57d18] sock_sendmsg at ffffffffbc6452f6
40 [ffffa70607e57d30] ___sys_sendmsg at ffffffffbc645860
41 [ffffa70607e57eb0] __sys_sendmsg at ffffffffbc647a38
42 [ffffa70607e57f38] do_syscall_64 at ffffffffbc00401b
43 [ffffa70607e57f50] entry_SYSCALL_64_after_hwframe at ffffffffbc80008c
44
45 Fixes: a8d70a054a718 ("net/mlx5: E-Switch, Disallow vlan/spoofcheck setup if not being esw manager")
46 Cc: Eli Cohen <eli@mellanox.com>
47 Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
48 Reviewed-by: Roi Dayan <roid@mellanox.com>
49 Acked-by: Saeed Mahameed <saeedm@mellanox.com>
50 Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
51 Signed-off-by: Sasha Levin <sashal@kernel.org>
52 ---
53 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 4 ++--
54 1 file changed, 2 insertions(+), 2 deletions(-)
55
56 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
57 index 2aec0c021b6c..d2914116af8e 100644
58 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
59 +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
60 @@ -1719,7 +1719,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
61 u64 node_guid;
62 int err = 0;
63
64 - if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
65 + if (!esw || !MLX5_CAP_GEN(esw->dev, vport_group_manager))
66 return -EPERM;
67 if (!LEGAL_VPORT(esw, vport) || is_multicast_ether_addr(mac))
68 return -EINVAL;
69 @@ -1793,7 +1793,7 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
70 {
71 struct mlx5_vport *evport;
72
73 - if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
74 + if (!esw || !MLX5_CAP_GEN(esw->dev, vport_group_manager))
75 return -EPERM;
76 if (!LEGAL_VPORT(esw, vport))
77 return -EINVAL;
78 --
79 2.19.1
80