AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Benjamin Cheng <benjamin.cheng@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	amd-gfx@lists.freedesktop.org
Cc: Leo Liu <leo.liu@amd.com>, Ruijing Dong <ruijing.dong@amd.com>,
	"David (Ming Qiang) Wu" <David.Wu3@amd.com>
Subject: Re: [PATCH v2 1/4] drm/amdgpu: Add bounds checking to ib_{get,set}_value
Date: Thu, 26 Mar 2026 13:54:37 +0100	[thread overview]
Message-ID: <3d933ac4-e1f2-4304-97d7-706b1f85c4df@amd.com> (raw)
In-Reply-To: <20260326122918.3486416-2-benjamin.cheng@amd.com>

On 3/26/26 13:29, Benjamin Cheng wrote:
> The uvd/vce/vcn code accesses the IB at predefined offsets without
> checking that the IB is large enough. Check the bounds here. The caller
> is responsible for making sure it can handle arbitrary return values.
> 
> Also make the idx a uint32_t to prevent overflows causing the condition
> to fail.
> 
> Signed-off-by: Benjamin Cheng <benjamin.cheng@amd.com>

Patches #1-#3 are Reviewed-by: Christian König <christian.koenig@amd.com>

Patch #4 is Acked-by: Christian König <christian.koenig@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> index ce5af137ee40..715c9e43e13a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> @@ -559,15 +559,18 @@ void amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
>  
>  int amdgpu_ring_init_mqd(struct amdgpu_ring *ring);
>  
> -static inline u32 amdgpu_ib_get_value(struct amdgpu_ib *ib, int idx)
> +static inline u32 amdgpu_ib_get_value(struct amdgpu_ib *ib, uint32_t idx)
>  {
> -	return ib->ptr[idx];
> +	if (idx < ib->length_dw)
> +		return ib->ptr[idx];
> +	return 0;
>  }
>  
> -static inline void amdgpu_ib_set_value(struct amdgpu_ib *ib, int idx,
> +static inline void amdgpu_ib_set_value(struct amdgpu_ib *ib, uint32_t idx,
>  				       uint32_t value)
>  {
> -	ib->ptr[idx] = value;
> +	if (idx < ib->length_dw)
> +		ib->ptr[idx] = value;
>  }
>  
>  int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,


      parent reply	other threads:[~2026-03-26 12:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26 12:29 [PATCH v2 1/4] drm/amdgpu: Add bounds checking to ib_{get,set}_value Benjamin Cheng
2026-03-26 12:29 ` [PATCH v2 2/4] drm/amdgpu/vcn3: Prevent OOB reads when parsing dec msg Benjamin Cheng
2026-04-09 18:09   ` SDL
2026-03-26 12:29 ` [PATCH v2 3/4] drm/amdgpu/vcn4: " Benjamin Cheng
2026-03-26 12:29 ` [PATCH v2 4/4] drm/amdgpu/vcn4: Prevent OOB reads when parsing IB Benjamin Cheng
2026-03-26 12:54 ` Christian König [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=3d933ac4-e1f2-4304-97d7-706b1f85c4df@amd.com \
    --to=christian.koenig@amd.com \
    --cc=David.Wu3@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=benjamin.cheng@amd.com \
    --cc=leo.liu@amd.com \
    --cc=ruijing.dong@amd.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox