All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Brajesh Gupta" <brajesh.gupta@imgtec.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/imagination: Add padding field check for GPU info query
Date: Wed, 02 Dec 2026 06:21:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-244956@kernel.org> (raw)
In-Reply-To: <20261202-dev_query_ioctl_fix-v1-1-853cc03874b7@imgtec.com>

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

      reply	other threads:[~2026-12-02  6:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-244956@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=brajesh.gupta@imgtec.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.