Re: [PATCH] drm/amdgpu: fix integer overflow test in amdgpu_bo_list_create()

2018-08-10 Thread Huang Rui
On Fri, Aug 10, 2018 at 06:50:32PM +0800, Dan Carpenter wrote:
> We accidentally left out the size of the amdgpu_bo_list struct.  It
> could lead to memory corruption on 32 bit systems.  You'd have to
> pick the absolute maximum and set "num_entries == 59652323" then size
> would wrap to 16 bytes.
> 
> Fixes: 920990cb080a ("drm/amdgpu: allocate the bo_list array after the list")
> Signed-off-by: Dan Carpenter 

Nice catch!
Acked-by: Huang Rui 

> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> index d472a2c8399f..b80243d3972e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> @@ -67,7 +67,8 @@ int amdgpu_bo_list_create(struct amdgpu_device *adev, 
> struct drm_file *filp,
>   unsigned i;
>   int r;
>  
> - if (num_entries > SIZE_MAX / sizeof(struct amdgpu_bo_list_entry))
> + if (num_entries > (SIZE_MAX - sizeof(struct amdgpu_bo_list))
> + / sizeof(struct amdgpu_bo_list_entry))
>   return -EINVAL;
>  
>   size = sizeof(struct amdgpu_bo_list);
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH] drm/amdgpu: fix integer overflow test in amdgpu_bo_list_create()

2018-08-10 Thread Bas Nieuwenhuizen
Reviewed-by: Bas Nieuwenhuizen 
On Fri, Aug 10, 2018 at 12:50 PM Dan Carpenter  wrote:
>
> We accidentally left out the size of the amdgpu_bo_list struct.  It
> could lead to memory corruption on 32 bit systems.  You'd have to
> pick the absolute maximum and set "num_entries == 59652323" then size
> would wrap to 16 bytes.
>
> Fixes: 920990cb080a ("drm/amdgpu: allocate the bo_list array after the list")
> Signed-off-by: Dan Carpenter 
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> index d472a2c8399f..b80243d3972e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> @@ -67,7 +67,8 @@ int amdgpu_bo_list_create(struct amdgpu_device *adev, 
> struct drm_file *filp,
> unsigned i;
> int r;
>
> -   if (num_entries > SIZE_MAX / sizeof(struct amdgpu_bo_list_entry))
> +   if (num_entries > (SIZE_MAX - sizeof(struct amdgpu_bo_list))
> +   / sizeof(struct amdgpu_bo_list_entry))
> return -EINVAL;
>
> size = sizeof(struct amdgpu_bo_list);
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx