Skip to contentSkip to conversation

drm/vmwgfx: Work around VMW_ALLOC_DMABUF

PATCH Superseded Meng Tang 1 participant 1 message Feb 23, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Meng Tang

author
#0 lore raw

PATCH 1/1 drm/vmwgfx: Work around VMW_ALLOC_DMABUF

A privilege escalation vulnerability was found in vmwgfx driver in drivers/gpu/drm/vmwgfx/vmwgfx_drv.c in GPU component of Linux kernel with device file '/dev/dri/renderD128 (or Dxxx)'. This flaw allows a local attacker with a user account on the system to gain privilege, causing a denial of service(DoS).

This vulnerability can be quickly verified by the following code logic:
...
dri_fd = open("/dev/dri/renderD128", O_RDWR);
ret = ioctl(dri_fd, 0xC0186441, &arg);

if (ret == 0) {
	printf("[*] VMW_ALLOC_DMABUF Success!\n");
}

...

Submit this commit to fix it.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +5 -0
index bd02cb0e6837..0166f98be9df 100644
@@ -1244,6 +1244,7 @@ static long vmw_generic_ioctl(struct file *filp, unsigned int cmd,
 						 unsigned long))
 {
 	struct drm_file *file_priv = filp->private_data;
+
 	struct drm_device *dev = file_priv->minor->dev;
 	unsigned int nr = DRM_IOCTL_NR(cmd);
 	unsigned int flags;
@@ -1263,6 +1264,10 @@ static long vmw_generic_ioctl(struct file *filp, unsigned int cmd,
 			if (!drm_is_current_master(file_priv) &&
 			    !capable(CAP_SYS_ADMIN))
 				return -EACCES;
+		} else if (nr == DRM_COMMAND_BASE + DRM_VMW_ALLOC_DMABUF) {
+			if (!drm_is_current_master(file_priv) &&
+			    !capable(CAP_SYS_ADMIN))
+				return -EPERM;
 		}
 
 		if (unlikely(ioctl->cmd != cmd))
Signature · 1 line
2.20.1