Skip to content

Commit 91c97c6

Browse files
committed
ice: validate queue quanta parameters to prevent OOB access
jira LE-4694 Rebuild_History Non-Buildable kernel-6.12.0-55.43.1.el10_0 commit-author Jan Glaza <jan.glaza@intel.com> commit e2f7d3f 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> (cherry picked from commit e2f7d3f) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 881c39d commit 91c97c6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,13 +1903,21 @@ static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8 *msg)
19031903
*/
19041904
static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
19051905
{
1906+
u16 quanta_prof_id, quanta_size, start_qid, num_queues, end_qid, i;
19061907
enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
1907-
u16 quanta_prof_id, quanta_size, start_qid, end_qid, i;
19081908
struct virtchnl_quanta_cfg *qquanta =
19091909
(struct virtchnl_quanta_cfg *)msg;
19101910
struct ice_vsi *vsi;
19111911
int ret;
19121912

1913+
start_qid = qquanta->queue_select.start_queue_id;
1914+
num_queues = qquanta->queue_select.num_queues;
1915+
1916+
if (check_add_overflow(start_qid, num_queues, &end_qid)) {
1917+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1918+
goto err;
1919+
}
1920+
19131921
if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
19141922
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
19151923
goto err;
@@ -1921,8 +1929,6 @@ static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
19211929
goto err;
19221930
}
19231931

1924-
end_qid = qquanta->queue_select.start_queue_id +
1925-
qquanta->queue_select.num_queues;
19261932
if (end_qid > ICE_MAX_RSS_QS_PER_VF ||
19271933
end_qid > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
19281934
dev_err(ice_pf_to_dev(vf->pf), "VF-%d trying to configure more than allocated number of queues: %d\n",
@@ -1951,7 +1957,6 @@ static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
19511957
goto err;
19521958
}
19531959

1954-
start_qid = qquanta->queue_select.start_queue_id;
19551960
for (i = start_qid; i < end_qid; i++)
19561961
vsi->tx_rings[i]->quanta_prof_id = quanta_prof_id;
19571962

0 commit comments

Comments
 (0)