* [PATCH] drm/amdgpu: Fix size overflow
@ 2021-04-07 11:35 xinhui pan
2021-04-07 12:00 ` Christian König
0 siblings, 1 reply; 3+ messages in thread
From: xinhui pan @ 2021-04-07 11:35 UTC (permalink / raw)
To: amd-gfx; +Cc: alexander.deucher, xinhui pan, christian.koenig
ttm->num_pages is uint32. Hit overflow when << PAGE_SHIFT directly
Fix: 230c079fd (drm/ttm: make num_pages uint32_t)
Signed-off-by: xinhui pan <xinhui.pan@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index fbaa4c148cca..01a5c487505c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -830,7 +830,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_device *bdev,
/* Allocate an SG array and squash pages into it */
r = sg_alloc_table_from_pages(ttm->sg, ttm->pages, ttm->num_pages, 0,
- ttm->num_pages << PAGE_SHIFT,
+ ttm->num_pages * (1ULL << PAGE_SHIFT),
GFP_KERNEL);
if (r)
goto release_sg;
--
2.25.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdgpu: Fix size overflow
2021-04-07 11:35 [PATCH] drm/amdgpu: Fix size overflow xinhui pan
@ 2021-04-07 12:00 ` Christian König
2021-04-07 12:06 ` Nirmoy
0 siblings, 1 reply; 3+ messages in thread
From: Christian König @ 2021-04-07 12:00 UTC (permalink / raw)
To: xinhui pan, amd-gfx; +Cc: alexander.deucher
Am 07.04.21 um 13:35 schrieb xinhui pan:
> ttm->num_pages is uint32. Hit overflow when << PAGE_SHIFT directly
>
> Fix: 230c079fd (drm/ttm: make num_pages uint32_t)
>
> Signed-off-by: xinhui pan <xinhui.pan@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index fbaa4c148cca..01a5c487505c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -830,7 +830,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_device *bdev,
>
> /* Allocate an SG array and squash pages into it */
> r = sg_alloc_table_from_pages(ttm->sg, ttm->pages, ttm->num_pages, 0,
> - ttm->num_pages << PAGE_SHIFT,
> + ttm->num_pages * (1ULL << PAGE_SHIFT),
Good catch, but please make this ((u64)ttm->num_pages) << PAGE_SHIFT
Christian.
> GFP_KERNEL);
> if (r)
> goto release_sg;
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdgpu: Fix size overflow
2021-04-07 12:00 ` Christian König
@ 2021-04-07 12:06 ` Nirmoy
0 siblings, 0 replies; 3+ messages in thread
From: Nirmoy @ 2021-04-07 12:06 UTC (permalink / raw)
To: Christian König, xinhui pan, amd-gfx; +Cc: alexander.deucher
We need this for radeon too.
On 4/7/21 2:00 PM, Christian König wrote:
> Am 07.04.21 um 13:35 schrieb xinhui pan:
>> ttm->num_pages is uint32. Hit overflow when << PAGE_SHIFT directly
>>
>> Fix: 230c079fd (drm/ttm: make num_pages uint32_t)
>>
>> Signed-off-by: xinhui pan <xinhui.pan@amd.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> index fbaa4c148cca..01a5c487505c 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> @@ -830,7 +830,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct
>> ttm_device *bdev,
>> /* Allocate an SG array and squash pages into it */
>> r = sg_alloc_table_from_pages(ttm->sg, ttm->pages,
>> ttm->num_pages, 0,
>> - ttm->num_pages << PAGE_SHIFT,
>> + ttm->num_pages * (1ULL << PAGE_SHIFT),
>
> Good catch, but please make this ((u64)ttm->num_pages) << PAGE_SHIFT
>
> Christian.
>
>> GFP_KERNEL);
>> if (r)
>> goto release_sg;
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Cnirmoy.das%40amd.com%7Cbc310f437f814ed8f93b08d8f9bcbb55%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637533936286970681%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=8Q2Qbnd0JK288d5PXys%2B%2B8ADCKa9xshtE5kLwRprhJc%3D&reserved=0
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-07 12:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 11:35 [PATCH] drm/amdgpu: Fix size overflow xinhui pan
2021-04-07 12:00 ` Christian König
2021-04-07 12:06 ` Nirmoy
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.