Skip to contentSkip to conversation

drm/amdgpu: Fix integer overflow in amdgpu_gem_add_input_fence()

PATCH Applied Dan Carpenter 2 participants 2 messages May 23, 2025 – May 30, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix integer overflow in amdgpu_gem_add_input_fence()

The "num_syncobj_handles" is a u32 value that comes from the user via the ioctl. On 32bit systems the "sizeof(uint32_t) * num_syncobj_handles" multiplication can have an integer overflow. Use size_mul() to fix that.

Fixes 38c67ec9aa4b ("drm/amdgpu: Add input fence to sync bo map/unmap")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -1
index 2c68118fe9fd..0ecc88df7208 100644
@@ -58,7 +58,7 @@ amdgpu_gem_add_input_fence(struct drm_file *filp,
 		return 0;
 
 	syncobj_handles = memdup_user(u64_to_user_ptr(syncobj_handles_array),
-				      sizeof(uint32_t) * num_syncobj_handles);
+				      size_mul(sizeof(uint32_t), num_syncobj_handles));
 	if (IS_ERR(syncobj_handles))
 		return PTR_ERR(syncobj_handles);
 
Signature · 1 line
2.47.2
Applied
#1 lore raw

Applied. Thanks!

Alex

Quoted 28 lines · Dan Carpenter

The "num_syncobj_handles" is a u32 value that comes from the user via the ioctl. On 32bit systems the "sizeof(uint32_t) * num_syncobj_handles" multiplication can have an integer overflow. Use size_mul() to fix that.

Fixes 38c67ec9aa4b ("drm/amdgpu: Add input fence to sync bo map/unmap")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -2
index 2c68118fe9fd..0ecc88df7208 100644
@@ -58,7 +58,7 @@ amdgpu_gem_add_input_fence(struct drm_file *filp,
                return 0;
 
        syncobj_handles = memdup_user(u64_to_user_ptr(syncobj_handles_array),
-                                     sizeof(uint32_t) * num_syncobj_handles);
+                                     size_mul(sizeof(uint32_t), num_syncobj_handles));
        if (IS_ERR(syncobj_handles))
                return PTR_ERR(syncobj_handles);
 
--

2.47.2