Skip to contentSkip to conversation

drm: fix NULL pointer access by wrong ioctl

PATCH New [email protected] 1 participant 1 message Jun 18, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: fix NULL pointer access by wrong ioctl

From: Zhaowei Yuan <[email protected]>

If user uses wrong ioctl command with _IOC_NONE and argument size greater than 0, it can cause NULL pointer access from memset of line
463. If _IOC_NONE, don't memset to 0 for kdata.

---
 drivers/gpu/drm/drm_drv.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 drivers/gpu/drm/drm_drv.c
drivers/gpu/drm/drm_drv.c +2 -1
old mode 100644
new mode 100755
index 2ab782c..1a92bcb
@@ -459,8 +459,9 @@ long drm_ioctl(struct file *filp,
 				retcode = -EFAULT;
 				goto err_i1;
 			}
-		} else
+		} else if (cmd & IOC_OUT) {
 			memset(kdata, 0, usize);
+		}
 
 		if (ioctl->flags & DRM_UNLOCKED)
 			retcode = func(dev, kdata, file_priv);

--
1.7.9.5