From e0c93a3e53a624beb5d3a15631237ac33b8c92cd Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 9 Apr 2014 18:51:23 +0100 Subject: [PATCH] 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 --- src/intel_device.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/intel_device.c b/src/intel_device.c index a55f62b2..43372284 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;