Unverified Commit 259fa9f3 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!8949 CVE-2022-48652

Merge Pull Request from: @ci-robot 
 
PR sync from: Guo Mengqi <guomengqi3@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/2HVMHGMIMCQDTCAR7M2RBICA46SPSMRG/ 
CVE-2022-48652

Anatolii Gerasymenko (1):
  ice: ethtool: Prohibit improper channel config for DCB

Ding Hui (1):
  ice: Fix crash by keep old cfg when update TCs more than queues


-- 
2.17.1
 
https://gitee.com/src-openeuler/kernel/issues/I9KHI8 
 
Link:https://gitee.com/openeuler/kernel/pulls/8949

 

Reviewed-by: default avatarYue Haibing <yuehaibing@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 84f8079f eca05c98
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3431,6 +3431,16 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
	new_rx = ch->combined_count + ch->rx_count;
	new_tx = ch->combined_count + ch->tx_count;

	if (new_rx < vsi->tc_cfg.numtc) {
		netdev_err(dev, "Cannot set less Rx channels, than Traffic Classes you have (%u)\n",
			   vsi->tc_cfg.numtc);
		return -EINVAL;
	}
	if (new_tx < vsi->tc_cfg.numtc) {
		netdev_err(dev, "Cannot set less Tx channels, than Traffic Classes you have (%u)\n",
			   vsi->tc_cfg.numtc);
		return -EINVAL;
	}
	if (new_rx > ice_get_max_rxq(pf)) {
		netdev_err(dev, "Maximum allowed Rx channels is %d\n",
			   ice_get_max_rxq(pf));
+30 −6
Original line number Diff line number Diff line
@@ -734,9 +734,9 @@ static void ice_set_dflt_vsi_ctx(struct ice_vsi_ctx *ctxt)
 * @vsi: the VSI being configured
 * @ctxt: VSI context structure
 */
static void ice_vsi_setup_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt)
static int ice_vsi_setup_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt)
{
	u16 offset = 0, qmap = 0, tx_count = 0;
	u16 offset = 0, qmap = 0, tx_count = 0, rx_count = 0;
	u16 qcount_tx = vsi->alloc_txq;
	u16 qcount_rx = vsi->alloc_rxq;
	u16 tx_numq_tc, rx_numq_tc;
@@ -829,11 +829,24 @@ static void ice_vsi_setup_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt)
	 * at least 1)
	 */
	if (offset)
		vsi->num_rxq = offset;
		rx_count = offset;
	else
		vsi->num_rxq = qcount_rx;
		rx_count = qcount_rx;

	if (rx_count > vsi->alloc_rxq) {
		dev_err(ice_pf_to_dev(vsi->back), "Trying to use more Rx queues (%u), than were allocated (%u)!\n",
			vsi->num_rxq, vsi->alloc_rxq);
		return -EINVAL;
	}

	if (tx_count > vsi->alloc_txq) {
		dev_err(ice_pf_to_dev(vsi->back), "Trying to use more Tx queues (%u), than were allocated (%u)!\n",
			vsi->num_txq, vsi->alloc_txq);
		return -EINVAL;
	}

	vsi->num_txq = tx_count;
	vsi->num_rxq = rx_count;

	if (vsi->type == ICE_VSI_VF && vsi->num_txq != vsi->num_rxq) {
		dev_dbg(ice_pf_to_dev(vsi->back), "VF VSI should have same number of Tx and Rx queues. Hence making them equal\n");
@@ -851,6 +864,8 @@ static void ice_vsi_setup_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt)
	 */
	ctxt->info.q_mapping[0] = cpu_to_le16(vsi->rxq_map[0]);
	ctxt->info.q_mapping[1] = cpu_to_le16(vsi->num_rxq);

	return 0;
}

/**
@@ -991,7 +1006,10 @@ static int ice_vsi_init(struct ice_vsi *vsi, bool init_vsi)
	}

	ctxt->info.sw_id = vsi->port_info->sw_id;
	ice_vsi_setup_q_map(vsi, ctxt);
	ret = ice_vsi_setup_q_map(vsi, ctxt);
	if (ret)
		goto out;

	if (!init_vsi) /* means VSI being updated */
		/* must to indicate which section of VSI context are
		 * being modified
@@ -3043,6 +3061,7 @@ int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc)
{
	u16 max_txqs[ICE_MAX_TRAFFIC_CLASS] = { 0 };
	struct ice_pf *pf = vsi->back;
	struct ice_tc_cfg old_tc_cfg;
	struct ice_vsi_ctx *ctx;
	enum ice_status status;
	struct device *dev;
@@ -3059,6 +3078,7 @@ int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc)
		max_txqs[i] = vsi->alloc_txq;
	}

	memcpy(&old_tc_cfg, &vsi->tc_cfg, sizeof(old_tc_cfg));
	vsi->tc_cfg.ena_tc = ena_tc;
	vsi->tc_cfg.numtc = num_tc;

@@ -3069,7 +3089,11 @@ int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc)
	ctx->vf_num = 0;
	ctx->info = vsi->info;

	ice_vsi_setup_q_map(vsi, ctx);
	ret = ice_vsi_setup_q_map(vsi, ctx);
	if (ret) {
		memcpy(&vsi->tc_cfg, &old_tc_cfg, sizeof(vsi->tc_cfg));
		goto out;
	}

	/* must to indicate which section of VSI context are being modified */
	ctx->info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_RXQ_MAP_VALID);