Skip to content

Commit c5be656

Browse files
lczapnikanguy11
authored andcommitted
ice: fix input validation for virtchnl BW
Add missing validation of tc and queue id values sent by a VF in ice_vc_cfg_q_bw(). Additionally fixed logged value in the warning message, where max_tx_rate was incorrectly referenced instead of min_tx_rate. Also correct error handling in this function by properly exiting when invalid configuration is detected. Fixes: 0153077 ("ice: Support VF queue rate limit and quanta size configuration") Reviewed-by: Jedrzej Jagielski <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Lukasz Czapnik <[email protected]> Co-developed-by: Martyna Szapar-Mudlaw <[email protected]> Signed-off-by: Martyna Szapar-Mudlaw <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent e2f7d3f commit c5be656

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

drivers/net/ethernet/intel/ice/ice_virtchnl.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,15 +1862,33 @@ static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8 *msg)
18621862

18631863
for (i = 0; i < qbw->num_queues; i++) {
18641864
if (qbw->cfg[i].shaper.peak != 0 && vf->max_tx_rate != 0 &&
1865-
qbw->cfg[i].shaper.peak > vf->max_tx_rate)
1865+
qbw->cfg[i].shaper.peak > vf->max_tx_rate) {
18661866
dev_warn(ice_pf_to_dev(vf->pf), "The maximum queue %d rate limit configuration may not take effect because the maximum TX rate for VF-%d is %d\n",
18671867
qbw->cfg[i].queue_id, vf->vf_id,
18681868
vf->max_tx_rate);
1869+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1870+
goto err;
1871+
}
18691872
if (qbw->cfg[i].shaper.committed != 0 && vf->min_tx_rate != 0 &&
1870-
qbw->cfg[i].shaper.committed < vf->min_tx_rate)
1873+
qbw->cfg[i].shaper.committed < vf->min_tx_rate) {
18711874
dev_warn(ice_pf_to_dev(vf->pf), "The minimum queue %d rate limit configuration may not take effect because the minimum TX rate for VF-%d is %d\n",
18721875
qbw->cfg[i].queue_id, vf->vf_id,
1873-
vf->max_tx_rate);
1876+
vf->min_tx_rate);
1877+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1878+
goto err;
1879+
}
1880+
if (qbw->cfg[i].queue_id > vf->num_vf_qs) {
1881+
dev_warn(ice_pf_to_dev(vf->pf), "VF-%d trying to configure invalid queue_id\n",
1882+
vf->vf_id);
1883+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1884+
goto err;
1885+
}
1886+
if (qbw->cfg[i].tc >= ICE_MAX_TRAFFIC_CLASS) {
1887+
dev_warn(ice_pf_to_dev(vf->pf), "VF-%d trying to configure a traffic class higher than allowed\n",
1888+
vf->vf_id);
1889+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1890+
goto err;
1891+
}
18741892
}
18751893

18761894
for (i = 0; i < qbw->num_queues; i++) {

0 commit comments

Comments
 (0)