public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: check a user-provided number of BOs in list
@ 2025-04-08  9:17 Denis Arefev
  2025-04-08  9:26 ` Christian König
  2025-04-14  9:27 ` Christian König
  0 siblings, 2 replies; 13+ messages in thread
From: Denis Arefev @ 2025-04-08  9:17 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Christian König, David Airlie, Simona Vetter,
	Andrey Grodzovsky, Chunming Zhou, amd-gfx, dri-devel,
	linux-kernel, lvc-project, stable

The user can set any value to the variable ‘bo_number’, via the ioctl
command DRM_IOCTL_AMDGPU_BO_LIST. This will affect the arithmetic
expression ‘in->bo_number * in->bo_info_size’, which is prone to
overflow. Add a valid value check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 964d0fbf6301 ("drm/amdgpu: Allow to create BO lists in CS ioctl v3")
Cc: stable@vger.kernel.org
Signed-off-by: Denis Arefev <arefev@swemel.ru>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
index 702f6610d024..dd30d2426ff7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
@@ -189,6 +189,9 @@ int amdgpu_bo_create_list_entry_array(struct drm_amdgpu_bo_list_in *in,
 	struct drm_amdgpu_bo_list_entry *info;
 	int r;
 
+	if (!in->bo_number || in->bo_number > UINT_MAX / info_size)
+		return -EINVAL;
+
 	info = kvmalloc_array(in->bo_number, info_size, GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
-- 
2.43.0


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

end of thread, other threads:[~2025-04-14  9:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-08  9:17 [PATCH] drm/amdgpu: check a user-provided number of BOs in list Denis Arefev
2025-04-08  9:26 ` Christian König
2025-04-08  9:39   ` [lvc-project] " Fedor Pchelkin
2025-04-08 11:37     ` Christian König
2025-04-08 11:54       ` Fedor Pchelkin
     [not found]         ` <edc08eb4-63dd-402c-82df-af6898d499a9@amd.com>
2025-04-08 16:07           ` Fedor Pchelkin
2025-04-09  2:39             ` Linus Torvalds
2025-04-09  7:29               ` Christian König
2025-04-09 17:27                 ` Linus Torvalds
2025-04-10  9:07                   ` Christian König
2025-04-13 11:31                     ` Fedor Pchelkin
2025-04-14  9:35                       ` Christian König
2025-04-14  9:27 ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox