[Intel-xe] [PATCH 1/3] drm/xe: Fix array bounds check for queries

Niranjana Vishwanathapura niranjana.vishwanathapura at intel.com
Sat Aug 5 06:46:38 UTC 2023


On Fri, Aug 04, 2023 at 02:32:51PM -0700, Umesh Nerlige Ramappa wrote:
>Queries are 0-indexed, so a query with value N is invalid if the
>ARRAY_SIZE is N. Modify the check to account for that.
>
>Fixes: 22504d560287 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
>Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>

Probably we need 'fixup!' commit tag here instead of 'Fixes' as this patch
can update the original patch.

Reviewed-by: Niranjana Vishwanathapura <niranjana.vishwanathapura at intel.com>

>---
> drivers/gpu/drm/xe/xe_query.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c
>index 7ea235c71385..297e93a0eb8c 100644
>--- a/drivers/gpu/drm/xe/xe_query.c
>+++ b/drivers/gpu/drm/xe/xe_query.c
>@@ -385,7 +385,7 @@ int xe_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> 	    XE_IOCTL_DBG(xe, query->reserved[0] || query->reserved[1]))
> 		return -EINVAL;
>
>-	if (XE_IOCTL_DBG(xe, query->query > ARRAY_SIZE(xe_query_funcs)))
>+	if (XE_IOCTL_DBG(xe, query->query >= ARRAY_SIZE(xe_query_funcs)))
> 		return -EINVAL;
>
> 	idx = array_index_nospec(query->query, ARRAY_SIZE(xe_query_funcs));
>-- 
>2.38.1
>


More information about the Intel-xe mailing list