All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/5] drm/amdgpu: Add bounds checking to ib_{get,set}_value
@ 2026-03-30 19:57 Benjamin Cheng
  2026-03-30 19:57 ` [PATCH v4 2/5] drm/amdgpu/vce: Prevent partial address patches Benjamin Cheng
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Benjamin Cheng @ 2026-03-30 19:57 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David (Ming Qiang) Wu,
	amd-gfx
  Cc: Leo Liu, Ruijing Dong, Benjamin Cheng

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>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ruijing Dong <ruijing.dong@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,
-- 
2.53.0


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

end of thread, other threads:[~2026-07-24  7:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30 19:57 [PATCH v4 1/5] drm/amdgpu: Add bounds checking to ib_{get,set}_value Benjamin Cheng
2026-03-30 19:57 ` [PATCH v4 2/5] drm/amdgpu/vce: Prevent partial address patches Benjamin Cheng
2026-03-30 20:31   ` Alex Deucher
2026-07-23 10:55   ` Dan Carpenter
2026-07-23 12:09     ` Benjamin Cheng
2026-03-30 19:57 ` [PATCH v4 3/5] drm/amdgpu/vcn3: Prevent OOB reads when parsing dec msg Benjamin Cheng
2026-03-30 19:57 ` [PATCH v4 4/5] drm/amdgpu/vcn4: " Benjamin Cheng
2026-03-30 19:57 ` [PATCH v4 5/5] drm/amdgpu/vcn4: Prevent OOB reads when parsing IB Benjamin Cheng

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.