All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/imagination: Add padding field check for GPU info query
@ 2026-12-02  6:12 Brajesh Gupta
  2026-12-02  6:21 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Brajesh Gupta @ 2026-12-02  6:12 UTC (permalink / raw)
  To: Alessio Belle, Luigi Santivetti, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Frank Binns,
	Matt Coster
  Cc: imagination, dri-devel, linux-kernel, stable, Brajesh Gupta

Update pvr_dev_query_gpu_info_get to check and handle the non zero
padding field.

Fixes: f99f5f3ea7ef ("drm/imagination: Add GPU ID parsing and firmware loading")
Signed-off-by: Brajesh Gupta <brajesh.gupta@imgtec.com>
---
 drivers/gpu/drm/imagination/pvr_drv.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/imagination/pvr_drv.c b/drivers/gpu/drm/imagination/pvr_drv.c
index 2d522a8e46ad..566d5d373862 100644
--- a/drivers/gpu/drm/imagination/pvr_drv.c
+++ b/drivers/gpu/drm/imagination/pvr_drv.c
@@ -365,6 +365,12 @@ pvr_dev_query_gpu_info_get(struct pvr_device *pvr_dev,
 		return 0;
 	}
 
+	err = PVR_UOBJ_GET(gpu_info, args->size, args->pointer);
+	if (err < 0)
+		return err;
+	if (gpu_info._padding_c)
+		return -EINVAL;
+
 	gpu_info.gpu_id =
 		pvr_gpu_id_to_packed_bvnc(&pvr_dev->gpu_id);
 	gpu_info.num_phantoms = rogue_get_num_phantoms(pvr_dev);

---
base-commit: c88084027d0e922dd925b96e5a0d184ba04a8f43
change-id: 20261202-dev_query_ioctl_fix-08c929a51644

Best regards,
--  
Brajesh Gupta <brajesh.gupta@imgtec.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/imagination: Add padding field check for GPU info query
  2026-12-02  6:12 [PATCH] drm/imagination: Add padding field check for GPU info query Brajesh Gupta
@ 2026-12-02  6:21 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-02  6:21 UTC (permalink / raw)
  To: Brajesh Gupta; +Cc: dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/imagination: PVR_UOBJ_MIN_SIZE() omits _padding_c for
  gpu_info query
--

commit cd677bd5a1613ad8844eebb1535c2ad50d57f5e9
Author: Brajesh Gupta <brajesh.gupta@imgtec.com>

drm/imagination: Add padding field check for GPU info query

This commit updates pvr_dev_query_gpu_info_get() to copy the userspace
struct drm_pvr_dev_query_gpu_info and reject non-zero _padding_c values.

> diff --git a/drivers/gpu/drm/imagination/pvr_drv.c b/drivers/gpu/drm/imagination/pvr_drv.c
> index 2d522a8e46ad6..566d5d3738622 100644
> --- a/drivers/gpu/drm/imagination/pvr_drv.c
> +++ b/drivers/gpu/drm/imagination/pvr_drv.c
> @@ -365,6 +365,12 @@ pvr_dev_query_gpu_info_get(struct pvr_device *pvr_dev,
>  		return 0;
>  	}
>  
> +	err = PVR_UOBJ_GET(gpu_info, args->size, args->pointer);
> +	if (err < 0)
> +		return err;
> +	if (gpu_info._padding_c)
> +		return -EINVAL;

[Severity: Medium]
Can userspace bypass the gpu_info._padding_c check by passing args->size
== 12?

In drivers/gpu/drm/imagination/pvr_drv.h, PVR_UOBJ_MIN_SIZE() still
declares struct drm_pvr_dev_query_gpu_info with num_phantoms as its last
required field rather than _padding_c:

drivers/gpu/drm/imagination/pvr_drv.h:
	PVR_UOBJ_DECL(struct drm_pvr_dev_query_gpu_info, num_phantoms) \
	PVR_UOBJ_DECL(struct drm_pvr_dev_query_runtime_info, cdm_max_local_mem_size_regs) \
	PVR_UOBJ_DECL(struct drm_pvr_dev_query_quirks, _padding_c) \
	PVR_UOBJ_DECL(struct drm_pvr_dev_query_enhancements, _padding_c) \

Because min_stride is 12 bytes instead of 16, PVR_UOBJ_GET() accepts
args->size values in the range 12..15, copies only those bytes from
userspace, and leaves the uncopied bytes of gpu_info._padding_c zeroed in
kernel memory.  Updating PVR_UOBJ_DECL() for struct
drm_pvr_dev_query_gpu_info to use _padding_c, matching the quirks and
enhancements queries, would enforce the full 16-byte minimum size.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-dev_query_ioctl_fix-v1-1-853cc03874b7@imgtec.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02  6:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  6:12 [PATCH] drm/imagination: Add padding field check for GPU info query Brajesh Gupta
2026-12-02  6:21 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.