Skip to content

Commit e2f7d3f

Browse files
jglazaanguy11
authored andcommitted
ice: validate queue quanta parameters to prevent OOB access
Add queue wraparound prevention in quanta configuration. Ensure end_qid does not overflow by validating start_qid and num_queues. Fixes: 0153077 ("ice: Support VF queue rate limit and quanta size configuration") Reviewed-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Jan Glaza <jan.glaza@intel.com> Signed-off-by: Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent f91d0ef commit e2f7d3f

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,13 +1900,21 @@ static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8 *msg)
19001900
*/
19011901
static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
19021902
{
1903+
u16 quanta_prof_id, quanta_size, start_qid, num_queues, end_qid, i;
19031904
enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
1904-
u16 quanta_prof_id, quanta_size, start_qid, end_qid, i;
19051905
struct virtchnl_quanta_cfg *qquanta =
19061906
(struct virtchnl_quanta_cfg *)msg;
19071907
struct ice_vsi *vsi;
19081908
int ret;
19091909

1910+
start_qid = qquanta->queue_select.start_queue_id;
1911+
num_queues = qquanta->queue_select.num_queues;
1912+
1913+
if (check_add_overflow(start_qid, num_queues, &end_qid)) {
1914+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1915+
goto err;
1916+
}
1917+
19101918
if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
19111919
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
19121920
goto err;
@@ -1918,8 +1926,6 @@ static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
19181926
goto err;
19191927
}
19201928

1921-
end_qid = qquanta->queue_select.start_queue_id +
1922-
qquanta->queue_select.num_queues;
19231929
if (end_qid > ICE_MAX_RSS_QS_PER_VF ||
19241930
end_qid > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
19251931
dev_err(ice_pf_to_dev(vf->pf), "VF-%d trying to configure more than allocated number of queues: %d\n",
@@ -1948,7 +1954,6 @@ static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
19481954
goto err;
19491955
}
19501956

1951-
start_qid = qquanta->queue_select.start_queue_id;
19521957
for (i = start_qid; i < end_qid; i++)
19531958
vsi->tx_rings[i]->quanta_prof_id = quanta_prof_id;
19541959

0 commit comments

Comments
 (0)