Skip to contentSkip to conversation

drm/radeon: Fix integer overflow in radeon_cs_parser_init

PATCH Applied hackyzh002 3 participants 4 messages Apr 19, 2023 – Apr 27, 2023

Subsystems (3)
lore
Share & tools
lore

hackyzh002

author
#0 lore raw

PATCH v3 1/2 drm/radeon: Fix integer overflow in radeon_cs_parser_init

The type of size is unsigned, if size is 0x40000000, there will be an integer overflow, size will be zero after size *= sizeof(uint32_t), will cause uninitialized memory to be referenced later

---
 drivers/gpu/drm/radeon/radeon_cs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_cs.c +2 -1
index 46a27ebf4..a6700d727 100644
@@ -270,7 +270,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
 {
 	struct drm_radeon_cs *cs = data;
 	uint64_t *chunk_array_ptr;
-	unsigned size, i;
+	u64 size;
+	unsigned i;
 	u32 ring = RADEON_CS_RING_GFX;
 	s32 priority = 0;
 
Signature · 1 line
2.34.1
maintainer Reviewed-by on v3 1/2
#1 lore raw

Am 19.04.23 um 14:20 schrieb hackyzh002:

Quoted 5 lines

The type of size is unsigned, if size is 0x40000000, there will be an integer overflow, size will be zero after size *= sizeof(uint32_t), will cause uninitialized memory to be referenced later

Quoted 18 lines
---
  drivers/gpu/drm/radeon/radeon_cs.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_cs.c +2 -1
index 46a27ebf4..a6700d727 100644
@@ -270,7 +270,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
  {
  	struct drm_radeon_cs *cs = data;
  	uint64_t *chunk_array_ptr;
-	unsigned size, i;
+	u64 size;
+	unsigned i;
  	u32 ring = RADEON_CS_RING_GFX;
  	s32 priority = 0;
 
Applied
#2 lore raw

Applied. Thanks!

Alex

Quoted 29 lines · Christian König

Am 19.04.23 um 14:20 schrieb hackyzh002:

Quoted 5 lines

The type of size is unsigned, if size is 0x40000000, there will be an integer overflow, size will be zero after size *= sizeof(uint32_t), will cause uninitialized memory to be referenced later

Quoted 18 lines
---
  drivers/gpu/drm/radeon/radeon_cs.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_cs.c +2 -1
index 46a27ebf4..a6700d727 100644
@@ -270,7 +270,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
  {
      struct drm_radeon_cs *cs = data;
      uint64_t *chunk_array_ptr;
-     unsigned size, i;
+     u64 size;
+     unsigned i;
      u32 ring = RADEON_CS_RING_GFX;
      s32 priority = 0;
 
#3 lore raw

Hello,

What is the current status of this patch, has it been applied?

Quoted 38 lines · Alex Deucher <[email protected]> 于2023年4月19日周三 21:49写道:

Applied. Thanks!

Alex

Quoted 8 lines · Christian König

Am 19.04.23 um 14:20 schrieb hackyzh002:

Quoted 5 lines

The type of size is unsigned, if size is 0x40000000, there will be an integer overflow, size will be zero after size *= sizeof(uint32_t), will cause uninitialized memory to be referenced later

Quoted 7 lines

Review

Quoted 5 lines
---
  drivers/gpu/drm/radeon/radeon_cs.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/radeon/radeon_cs.c

Quoted 4 lines

drivers/gpu/drm/radeon/radeon_cs.c int radeon_cs_parser_init(struct radeon_cs_parser

Quoted 4 lines

index 46a27ebf4..a6700d727 100644

drivers/gpu/drm/radeon/radeon_cs.c +0 -0
@@ -270,7 +270,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser

*p, void *data)

Quoted 10 lines
Quoted 9 lines
drivers/gpu/drm/radeon/radeon_cs.c +2 -1
  {
      struct drm_radeon_cs *cs = data;
      uint64_t *chunk_array_ptr;
-     unsigned size, i;
+     u64 size;
+     unsigned i;
      u32 ring = RADEON_CS_RING_GFX;
      s32 priority = 0;