netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Tonghao Zhang <xiangxia.m.yue@gmail.com>,
	Mohamad Haj Yahia <mohamad@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 008/192] net/mlx5: Avoid panic when setting vport rate
Date: Wed, 27 Mar 2019 14:07:20 -0400	[thread overview]
Message-ID: <20190327181025.13507-8-sashal@kernel.org> (raw)
In-Reply-To: <20190327181025.13507-1-sashal@kernel.org>

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

[ Upstream commit 24319258660a84dd77f4be026a55b10a12524919 ]

If we try to set VFs rate 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 max_tx_rate 2 min_tx_rate 1

If not applied the first patch ("net/mlx5: Avoid panic when setting
vport mac, getting vport config"), the command:

$ ip link set $MLX_VF0 vf 0 rate 100

can also crash the kernel.

[ 1650.006388] RIP: 0010:mlx5_eswitch_set_vport_rate+0x1f/0x260 [mlx5_core]
[ 1650.007092]  do_setlink+0x982/0xd20
[ 1650.007129]  __rtnl_newlink+0x528/0x7d0
[ 1650.007374]  rtnl_newlink+0x43/0x60
[ 1650.007407]  rtnetlink_rcv_msg+0x2a2/0x320
[ 1650.007484]  netlink_rcv_skb+0xcb/0x100
[ 1650.007519]  netlink_unicast+0x17f/0x230
[ 1650.007554]  netlink_sendmsg+0x2d2/0x3d0
[ 1650.007592]  sock_sendmsg+0x36/0x50
[ 1650.007625]  ___sys_sendmsg+0x280/0x2a0
[ 1650.007963]  __sys_sendmsg+0x58/0xa0
[ 1650.007998]  do_syscall_64+0x5b/0x180
[ 1650.009438]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fixes: c9497c98901c ("net/mlx5: Add support for setting VF min rate")
Cc: Mohamad Haj Yahia <mohamad@mellanox.com>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Acked-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index d6706475a3ba..886a4a77c47f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -2044,19 +2044,24 @@ static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
 int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport,
 				u32 max_rate, u32 min_rate)
 {
-	u32 fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
-	bool min_rate_supported = MLX5_CAP_QOS(esw->dev, esw_bw_share) &&
-					fw_max_bw_share >= MLX5_MIN_BW_SHARE;
-	bool max_rate_supported = MLX5_CAP_QOS(esw->dev, esw_rate_limit);
 	struct mlx5_vport *evport;
+	u32 fw_max_bw_share;
 	u32 previous_min_rate;
 	u32 divider;
+	bool min_rate_supported;
+	bool max_rate_supported;
 	int err = 0;
 
 	if (!ESW_ALLOWED(esw))
 		return -EPERM;
 	if (!LEGAL_VPORT(esw, vport))
 		return -EINVAL;
+
+	fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
+	min_rate_supported = MLX5_CAP_QOS(esw->dev, esw_bw_share) &&
+				fw_max_bw_share >= MLX5_MIN_BW_SHARE;
+	max_rate_supported = MLX5_CAP_QOS(esw->dev, esw_rate_limit);
+
 	if ((min_rate && !min_rate_supported) || (max_rate && !max_rate_supported))
 		return -EOPNOTSUPP;
 
-- 
2.19.1


       reply	other threads:[~2019-03-27 19:11 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190327181025.13507-1-sashal@kernel.org>
2019-03-27 18:07 ` Sasha Levin [this message]
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 009/192] net/mlx5: Avoid panic when setting vport mac, getting vport config Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 013/192] net: stmmac: Avoid sometimes uninitialized Clang warnings Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 014/192] enic: fix build warning without CONFIG_CPUMASK_OFFSTACK Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 015/192] libbpf: force fixdep compilation at the start of the build Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 041/192] netfilter: nf_tables: check the result of dereferencing base_chain->stats Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 042/192] netfilter: conntrack: tcp: only close if RST matches exact sequence Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 047/192] wil6210: check null pointer in _wil_cfg80211_merge_extra_ies Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 048/192] mt76: fix a leaked reference by adding a missing of_node_put Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 063/192] net: dsa: mv88e6xxx: Add lockdep classes to fix false positive splat Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 064/192] e1000e: Fix -Wformat-truncation warnings Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 065/192] mlxsw: spectrum: Avoid " Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 081/192] mwifiex: don't advertise IBSS features without FW support Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 091/192] mt76: usb: do not run mt76u_queues_deinit twice Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 100/192] iwlwifi: pcie: fix emergency path Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 103/192] selftests: skip seccomp get_metadata test if not real root Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 106/192] netfilter: conntrack: fix cloned unconfirmed skb->_nfct race in __nf_conntrack_confirm Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 110/192] ath10k: fix shadow register implementation for WCN3990 Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 118/192] net: marvell: mvpp2: fix stuck in-band SGMII negotiation Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 120/192] net: phy: consider latched link-down status in polling mode Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 127/192] e1000e: fix cyclic resets at link up with active tx Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 128/192] e1000e: Exclude device from suspend direct complete optimization Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 132/192] iwlwifi: mvm: fix RFH config command with >=10 CPUs Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 142/192] mt7601u: bump supported EEPROM version Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 146/192] bpf: fix missing prototype warnings Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 147/192] selftests/bpf: skip verifier tests for unsupported program types Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 163/192] Bluetooth: Verify that l2cap_get_conf_opt provides large enough buffer Sasha Levin
2019-03-27 18:10 ` [PATCH AUTOSEL 4.19 171/192] netfilter: physdev: relax br_netfilter dependency Sasha Levin
2019-03-27 18:10 ` [PATCH AUTOSEL 4.19 180/192] brcmfmac: Use firmware_request_nowarn for the clm_blob Sasha Levin
2019-03-27 18:10 ` [PATCH AUTOSEL 4.19 181/192] wlcore: Fix memory leak in case wl12xx_fetch_firmware failure Sasha Levin
2019-03-27 18:10 ` [PATCH AUTOSEL 4.19 190/192] net: stmmac: Avoid one more sometimes uninitialized Clang warning Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190327181025.13507-8-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mohamad@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    --cc=stable@vger.kernel.org \
    --cc=xiangxia.m.yue@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).