The VIRTCHNL_ACTION_Q_REGION filter covers 2^region queues starting at
the index the VF supplies. The index and the region go into the
programming descriptor (TO_Q), which the hardware interprets relative
to the VF's VSI, so a region extending past the VSI's Rx queues lets
the VF steer matched packets to queues belonging to another VF or to
the PF.
Reject a region that does not fit the 3-bit TO_Q field (it would be
silently truncated) and require the whole range to fit within the
VSI's Rx queues. No alignment of the index is required for this to
hold: however the hardware combines the index with the hash bits, no
queue it selects from the region is at or above index + 2^region.
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: 346bf2504397 ("ice: Add new actions support for VF FDIR")
Signed-off-by: Aleksandr Loktionov <[email protected]>
---
drivers/net/ethernet/intel/ice/virt/fdir.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/virt/fdir.c
b/drivers/net/ethernet/intel/ice/virt/fdir.c
index f3af7de..244da64 100644
--- a/drivers/net/ethernet/intel/ice/virt/fdir.c
+++ b/drivers/net/ethernet/intel/ice/virt/fdir.c
@@ -1192,6 +1192,17 @@ ice_vc_fdir_parse_action(struct ice_vf *vf, struct
virtchnl_fdir_add *fltr,
break;
case VIRTCHNL_ACTION_Q_REGION:
dest_num++;
+ if (action->act_conf.queue.region >
+ FIELD_MAX(ICE_FXD_FLTR_QW0_TO_Q_M) ||
+ action->act_conf.queue.index +
+ BIT(action->act_conf.queue.region) > vsi->num_rxq) {
+ dev_dbg(dev,
+ "Invalid queue region %u/%u for VF
%d\n",
+ action->act_conf.queue.index,
+ action->act_conf.queue.region,
+ vf->vf_id);
+ return -EINVAL;
+ }
input->dest_ctl =
ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP;
input->q_index = action->act_conf.queue.index;
input->q_region = action->act_conf.queue.region;
--
2.56.0