Skip to content

Commit 3a47f4b

Browse files
Dan Carpenterrobclark
authored andcommitted
drm/msm/gem: prevent integer overflow in msm_ioctl_gem_submit()
The "submit->cmd[i].size" and "submit->cmd[i].offset" variables are u32 values that come from the user via the submit_lookup_cmds() function. This addition could lead to an integer wrapping bug so use size_add() to prevent that. Fixes: 1987253 ("drm/msm: fix cmdstream size check") Cc: [email protected] Signed-off-by: Dan Carpenter <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/624696/ Signed-off-by: Rob Clark <[email protected]>
1 parent 7a637e5 commit 3a47f4b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/gpu/drm/msm/msm_gem_submit.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
787787
goto out;
788788

789789
if (!submit->cmd[i].size ||
790-
((submit->cmd[i].size + submit->cmd[i].offset) >
791-
obj->size / 4)) {
790+
(size_add(submit->cmd[i].size, submit->cmd[i].offset) > obj->size / 4)) {
792791
SUBMIT_ERROR(submit, "invalid cmdstream size: %u\n", submit->cmd[i].size * 4);
793792
ret = -EINVAL;
794793
goto out;

0 commit comments

Comments
 (0)