[PATCH v5 3/6] drm/xe/vf: Add bounds checking for queried context and doorbell counts
Satyanarayana K V P <[email protected]>
| Newsgroups | org.freedesktop.lists.intel-xe |
|---|---|
| Message-ID | <[email protected]> |
Add explicit bounds checks for context and doorbells which can detect and reject invalid configuration data from a misconfigured or malfunctioning PF, preventing protocol violations and protecting VF initialization. Signed-off-by: Satyanarayana K V P <[email protected]> Cc: Michal Wajdeczko <[email protected]> --- V4 -> V5: - Fixed review comments (Michal W). V3 -> V4: - New commit --- drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c index 339ea0d3344c..81d68fe5ad7c 100644 --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c @@ -15,6 +15,7 @@ #include "abi/guc_klvs_abi.h" #include "abi/guc_relay_actions_abi.h" #include "regs/xe_gt_regs.h" +#include "regs/xe_guc_regs.h" #include "xe_assert.h" #include "xe_device.h" @@ -581,6 +582,11 @@ static int vf_get_ctxs_cfg(struct xe_gt *gt) if (unlikely(err)) return err; + if (num_ctxs > GUC_ID_MAX) { + xe_gt_sriov_err(gt, "Out of bound CTXs %u received\n", num_ctxs); + return -EPROTO; + } + if (config->num_ctxs && config->num_ctxs != num_ctxs) { xe_gt_sriov_err(gt, "Unexpected CTXs reassignment: %u != %u\n", num_ctxs, config->num_ctxs); @@ -607,6 +613,11 @@ static int vf_get_dbs_cfg(struct xe_gt *gt) if (unlikely(err)) return err; + if (num_dbs > GUC_NUM_DOORBELLS) { + xe_gt_sriov_err(gt, "Out of bound DBs %u received\n", num_dbs); + return -EPROTO; + } + if (config->num_dbs && config->num_dbs != num_dbs) { xe_gt_sriov_err(gt, "Unexpected DBs reassignment: %u != %u\n", num_dbs, config->num_dbs); -- 2.53.0