Skip to content

Commit 28a5dfd

Browse files
en4bzzackr
authored andcommitted
drm/vmwgfx: Limit display layout ioctl array size to VMWGFX_NUM_DISPLAY_UNITS
Currently the array size is only limited by the largest kmalloc size which is incorrect. This change will also return a more specific error message than ENOMEM to userspace. Signed-off-by: Ian Forbes <[email protected]> Reviewed-by: Zack Rusin <[email protected]> Reviewed-by: Martin Krastev <[email protected]> Signed-off-by: Zack Rusin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent fcddc71 commit 28a5dfd

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_drv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
#define VMWGFX_DRIVER_MINOR 20
6363
#define VMWGFX_DRIVER_PATCHLEVEL 0
6464
#define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
65-
#define VMWGFX_MAX_DISPLAYS 16
65+
#define VMWGFX_NUM_DISPLAY_UNITS 8
6666
#define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768
6767

6868
#define VMWGFX_MIN_INITIAL_WIDTH 1280
@@ -82,7 +82,7 @@
8282
#define VMWGFX_NUM_GB_CONTEXT 256
8383
#define VMWGFX_NUM_GB_SHADER 20000
8484
#define VMWGFX_NUM_GB_SURFACE 32768
85-
#define VMWGFX_NUM_GB_SCREEN_TARGET VMWGFX_MAX_DISPLAYS
85+
#define VMWGFX_NUM_GB_SCREEN_TARGET VMWGFX_NUM_DISPLAY_UNITS
8686
#define VMWGFX_NUM_DXCONTEXT 256
8787
#define VMWGFX_NUM_DXQUERY 512
8888
#define VMWGFX_NUM_MOB (VMWGFX_NUM_GB_CONTEXT +\

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2225,7 +2225,7 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
22252225
struct drm_mode_config *mode_config = &dev->mode_config;
22262226
struct drm_vmw_update_layout_arg *arg =
22272227
(struct drm_vmw_update_layout_arg *)data;
2228-
void __user *user_rects;
2228+
const void __user *user_rects;
22292229
struct drm_vmw_rect *rects;
22302230
struct drm_rect *drm_rects;
22312231
unsigned rects_size;
@@ -2237,6 +2237,8 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
22372237
VMWGFX_MIN_INITIAL_HEIGHT};
22382238
vmw_du_update_layout(dev_priv, 1, &def_rect);
22392239
return 0;
2240+
} else if (arg->num_outputs > VMWGFX_NUM_DISPLAY_UNITS) {
2241+
return -E2BIG;
22402242
}
22412243

22422244
rects_size = arg->num_outputs * sizeof(struct drm_vmw_rect);

drivers/gpu/drm/vmwgfx/vmwgfx_kms.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ struct vmw_kms_dirty {
199199
s32 unit_y2;
200200
};
201201

202-
#define VMWGFX_NUM_DISPLAY_UNITS 8
203-
204-
205202
#define vmw_framebuffer_to_vfb(x) \
206203
container_of(x, struct vmw_framebuffer, base)
207204
#define vmw_framebuffer_to_vfbs(x) \

0 commit comments

Comments
 (0)