ice_vc_fdir_parse_action() copies the VF supplied queue index straight
into the flow director programming descriptor (QINDEX), which the
hardware interprets relative to the VF's VSI, so a VF can steer
matched packets to queues beyond its own range, i.e. queues belonging
to another VF or to the PF.
For VIRTCHNL_ACTION_QUEUE reject an index that is not below the VSI's
Rx queue count; the rejected action fails the whole add request.
v2 -> v3:
- split out from the single queue and queue-region validation
commit of the v2 posting, one commit per Fixes tag
- rewrap the dev_dbg() call to fit within 80 columns
Fixes: 0ce332fd62f6 ("ice: Add FDIR pattern action parser for VF")
Signed-off-by: Aleksandr Loktionov <[email protected]>
---
drivers/net/ethernet/intel/ice/virt/fdir.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/virt/fdir.c
b/drivers/net/ethernet/intel/ice/virt/fdir.c
index b6e3097..f3af7de 100644
--- a/drivers/net/ethernet/intel/ice/virt/fdir.c
+++ b/drivers/net/ethernet/intel/ice/virt/fdir.c
@@ -1151,6 +1151,7 @@ ice_vc_fdir_parse_action(struct ice_vf *vf, struct
virtchnl_fdir_add *fltr,
struct virtchnl_filter_action_set *as = &fltr->rule_cfg.action_set;
struct ice_ntuple_fltr *input = &conf->input;
struct device *dev = ice_pf_to_dev(vf->pf);
+ struct ice_vsi *vsi;
u32 dest_num = 0;
u32 mark_num = 0;
int i;
@@ -1161,6 +1162,10 @@ ice_vc_fdir_parse_action(struct ice_vf *vf, struct
virtchnl_fdir_add *fltr,
return -EINVAL;
}
+ vsi = ice_get_vf_vsi(vf);
+ if (!vsi)
+ return -EINVAL;
+
for (i = 0; i < as->count; i++) {
struct virtchnl_filter_action *action = &as->actions[i];
@@ -1175,6 +1180,13 @@ ice_vc_fdir_parse_action(struct ice_vf *vf, struct
virtchnl_fdir_add *fltr,
break;
case VIRTCHNL_ACTION_QUEUE:
dest_num++;
+ if (action->act_conf.queue.index >= vsi->num_rxq) {
+ dev_dbg(dev,
+ "Invalid queue index %u for VF %d\n",
+ action->act_conf.queue.index,
+ vf->vf_id);
+ return -EINVAL;
+ }
input->dest_ctl =
ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX;
input->q_index = action->act_conf.queue.index;
break;
--
2.56.0