xf86-video-intel: src/intel_device.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Apr 9 10:56:29 PDT 2014


 src/intel_device.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

New commits:
commit e0c93a3e53a624beb5d3a15631237ac33b8c92cd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Apr 9 18:51:23 2014 +0100

    intel: If a non-root user starts X, don't release master
    
    SET_MASTER and DROP_MASTER are only available to the root user. If we
    are started as an ordinary user, and we are master by virtue of being
    the first user of the device, never release our fd or master.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel_device.c b/src/intel_device.c
index a55f62b..4337228 100644
--- a/src/intel_device.c
+++ b/src/intel_device.c
@@ -270,6 +270,18 @@ static int get_fd(struct xf86_platform_device *dev)
 }
 #endif
 
+static int is_master(int fd)
+{
+	drmSetVersion sv;
+
+	sv.drm_di_major = 1;
+	sv.drm_di_minor = 1;
+	sv.drm_dd_major = -1;
+	sv.drm_dd_minor = -1;
+
+	return drmIoctl(fd, DRM_IOCTL_SET_VERSION, &sv) == 0;
+}
+
 int intel_open_device(int entity_num,
 		      const struct pci_device *pci,
 		      struct xf86_platform_device *platform)
@@ -316,6 +328,10 @@ int intel_open_device(int entity_num,
 	if (hosted())
 		master_count++;
 
+	/* Non-root user holding MASTER, don't let go */
+	if (geteuid() && is_master(fd))
+		master_count++;
+
 	dev->fd = fd;
 	dev->open_count = master_count;
 	dev->master_count = master_count;


More information about the xorg-commit mailing list