Skip to content

Commit ded34f9

Browse files
Dan Carpentergregkh
authored andcommitted
drm/msm: fix an integer overflow test
commit 65e93108891e571f177c202add9288eda9ac4100 upstream. We recently added an integer overflow check but it needs an additional tweak to work properly on 32 bit systems. The problem is that we're doing the right hand side of the assignment as type unsigned long so the max it will have an integer overflow instead of being larger than SIZE_MAX. That means the "sz > SIZE_MAX" condition is never true even on 32 bit systems. We need to first cast it to u64 and then do the math. Fixes: 4a630fadbb29 ("drm/msm: Fix potential buffer overflow issue") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Rob Clark <robdclark@gmail.com> Cc: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 031b02b commit ded34f9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/gpu/drm/msm/msm_gem_submit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev,
3737
struct msm_gpu *gpu, uint32_t nr)
3838
{
3939
struct msm_gem_submit *submit;
40-
uint64_t sz = sizeof(*submit) + (nr * sizeof(submit->bos[0]));
40+
uint64_t sz = sizeof(*submit) + ((u64)nr * sizeof(submit->bos[0]));
4141

4242
if (sz > SIZE_MAX)
4343
return NULL;

0 commit comments

Comments
 (0)