diff options
author | Kasin Li <donglil@codeaurora.org> | 2017-06-19 17:36:53 -0400 |
---|---|---|
committer | Rob Clark <robdclark@gmail.com> | 2017-06-19 19:58:57 -0400 |
commit | 4a630fadbb29d9efaedb525f1a8f7449ad107641 (patch) | |
tree | 20c23954ea7db38a5c7fdd4c5d9914dbf3c85950 | |
parent | 51c9fbe69486c9143877f5d26a575b16588eb08a (diff) |
drm/msm: Fix potential buffer overflow issue
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>
-rw-r--r-- | drivers/gpu/drm/msm/msm_gem_submit.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 179cfc60b6ca..6bfca7470141 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c | |||
@@ -31,11 +31,14 @@ | |||
31 | #define BO_PINNED 0x2000 | 31 | #define BO_PINNED 0x2000 |
32 | 32 | ||
33 | static struct msm_gem_submit *submit_create(struct drm_device *dev, | 33 | static struct msm_gem_submit *submit_create(struct drm_device *dev, |
34 | struct msm_gpu *gpu, int nr_bos, int nr_cmds) | 34 | struct msm_gpu *gpu, uint32_t nr_bos, uint32_t nr_cmds) |
35 | { | 35 | { |
36 | struct msm_gem_submit *submit; | 36 | struct msm_gem_submit *submit; |
37 | int sz = sizeof(*submit) + (nr_bos * sizeof(submit->bos[0])) + | 37 | uint64_t sz = sizeof(*submit) + (nr_bos * sizeof(submit->bos[0])) + |
38 | (nr_cmds * sizeof(*submit->cmd)); | 38 | (nr_cmds * sizeof(submit->cmd[0])); |
39 | |||
40 | if (sz > SIZE_MAX) | ||
41 | return NULL; | ||
39 | 42 | ||
40 | submit = kmalloc(sz, GFP_TEMPORARY | __GFP_NOWARN | __GFP_NORETRY); | 43 | submit = kmalloc(sz, GFP_TEMPORARY | __GFP_NOWARN | __GFP_NORETRY); |
41 | if (!submit) | 44 | if (!submit) |