Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH] drm/msm: fixes for 4.12
@ 2017-06-19 21:36 Jordan Crouse
  2017-06-19 21:36 ` [PATCH] drm/msm: Fix potential buffer overflow issue Jordan Crouse
  0 siblings, 1 reply; 2+ messages in thread
From: Jordan Crouse @ 2017-06-19 21:36 UTC (permalink / raw)
  To: freedreno; +Cc: linux-arm-msm, dri-devel

Hey Rob, here is a late breaking overflow fix suitable for sending up to Linus
for 4.12 if you are so inclined.

Kasin Li (1):
  drm/msm: Fix potential buffer overflow issue

 drivers/gpu/drm/msm/msm_gem_submit.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] drm/msm: Fix potential buffer overflow issue
  2017-06-19 21:36 [PATCH] drm/msm: fixes for 4.12 Jordan Crouse
@ 2017-06-19 21:36 ` Jordan Crouse
  0 siblings, 0 replies; 2+ messages in thread
From: Jordan Crouse @ 2017-06-19 21:36 UTC (permalink / raw)
  To: freedreno; +Cc: linux-arm-msm, dri-devel, Kasin Li

From: Kasin Li <donglil@codeaurora.org>

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>
---
 drivers/gpu/drm/msm/msm_gem_submit.c | 9 ++++++---
 1 file 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 7832e64..8264a53 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -31,11 +31,14 @@
 #define BO_PINNED   0x2000
 
 static struct msm_gem_submit *submit_create(struct drm_device *dev,
-		struct msm_gpu *gpu, int nr_bos, int nr_cmds)
+		struct msm_gpu *gpu, uint32_t nr_bos, uint32_t nr_cmds)
 {
 	struct msm_gem_submit *submit;
-	int sz = sizeof(*submit) + (nr_bos * sizeof(submit->bos[0])) +
-			(nr_cmds * sizeof(*submit->cmd));
+	uint64_t sz = sizeof(*submit) + (nr_bos * sizeof(submit->bos[0])) +
+		(nr_cmds * sizeof(submit->cmd[0]));
+
+	if (sz > SIZE_MAX)
+		return NULL;
 
 	submit = kmalloc(sz, GFP_TEMPORARY | __GFP_NOWARN | __GFP_NORETRY);
 	if (!submit)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-19 21:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-19 21:36 [PATCH] drm/msm: fixes for 4.12 Jordan Crouse
2017-06-19 21:36 ` [PATCH] drm/msm: Fix potential buffer overflow issue Jordan Crouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox