Skip to content

Commit

Permalink
drm/savage: fix integer overflows in savage_bci_cmdbuf()
Browse files Browse the repository at this point in the history
Since cmdbuf->size and cmdbuf->nbox are from userspace, a large value
would overflow the allocation size, leading to out-of-bounds access.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Xi Wang authored and Dave Airlie committed Apr 10, 2012
1 parent 4de833c commit 6587eb8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/gpu/drm/savage/savage_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
* for locking on FreeBSD.
*/
if (cmdbuf->size) {
kcmd_addr = kmalloc(cmdbuf->size * 8, GFP_KERNEL);
kcmd_addr = kmalloc_array(cmdbuf->size, 8, GFP_KERNEL);
if (kcmd_addr == NULL)
return -ENOMEM;

Expand All @@ -1015,8 +1015,8 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
cmdbuf->vb_addr = kvb_addr;
}
if (cmdbuf->nbox) {
kbox_addr = kmalloc(cmdbuf->nbox * sizeof(struct drm_clip_rect),
GFP_KERNEL);
kbox_addr = kmalloc_array(cmdbuf->nbox, sizeof(struct drm_clip_rect),
GFP_KERNEL);
if (kbox_addr == NULL) {
ret = -ENOMEM;
goto done;
Expand Down

0 comments on commit 6587eb8

Please sign in to comment.