Skip to content

Commit 031b02b

Browse files
Kasin Ligregkh
authored andcommitted
drm/msm: Fix potential buffer overflow issue
commit 4a630fadbb29d9efaedb525f1a8f7449ad107641 upstream. In function submit_create, if nr_cmds or nr_bos is assigned with negative value, the allocated buffer may be small than intended. Using this buffer will lead to buffer overflow issue. Signed-off-by: Kasin Li <donglil@codeaurora.org> Signed-off-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 6e6eba5 commit 031b02b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/gpu/drm/msm/msm_gem_submit.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ static inline void __user *to_user_ptr(u64 address)
3434
}
3535

3636
static struct msm_gem_submit *submit_create(struct drm_device *dev,
37-
struct msm_gpu *gpu, int nr)
37+
struct msm_gpu *gpu, uint32_t nr)
3838
{
3939
struct msm_gem_submit *submit;
40-
int sz = sizeof(*submit) + (nr * sizeof(submit->bos[0]));
40+
uint64_t sz = sizeof(*submit) + (nr * sizeof(submit->bos[0]));
41+
42+
if (sz > SIZE_MAX)
43+
return NULL;
4144

4245
submit = kmalloc(sz, GFP_TEMPORARY | __GFP_NOWARN | __GFP_NORETRY);
4346
if (submit) {

0 commit comments

Comments
 (0)