Commit c968dc0c authored by Dan Carpenter's avatar Dan Carpenter Committed by Thadeu Lima de Souza Cascardo

drm/msm: fix an integer overflow test

BugLink: http://bugs.launchpad.net/bugs/1731915

commit 65e93108 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: 4a630fad ("drm/msm: Fix potential buffer overflow issue")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
parent d979f59a
......@@ -37,7 +37,7 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev,
struct msm_gpu *gpu, uint32_t nr)
{
struct msm_gem_submit *submit;
uint64_t sz = sizeof(*submit) + (nr * sizeof(submit->bos[0]));
uint64_t sz = sizeof(*submit) + ((u64)nr * sizeof(submit->bos[0]));
if (sz > SIZE_MAX)
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment