summaryrefslogtreecommitdiff
path: root/va
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-07-15 10:45:16 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-07-15 10:52:12 +0200
commitd2dbc3f69c69e5933e7b3da429c0fb0cae5b98b0 (patch)
tree4f79b244a612d7bc52f21abf494ee13d0c3b1096 /va
parentb927627beb3a3fbc8d2aa238ee47d8d0727a4a33 (diff)
drm: improve check for authentication.
On Linux systems, the drmGetClient() function would return the thread ID instead of the actual process ID. Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Diffstat (limited to 'va')
-rw-r--r--va/drm/va_drm_auth.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/va/drm/va_drm_auth.c b/va/drm/va_drm_auth.c
index 59aecaf..53794d3 100644
--- a/va/drm/va_drm_auth.c
+++ b/va/drm/va_drm_auth.c
@@ -28,6 +28,23 @@
#include "va_drm_auth.h"
#include "va_drm_auth_x11.h"
+#if defined __linux__
+# include <sys/syscall.h>
+#endif
+
+/* Checks whether the thread id is the current thread */
+static bool
+is_local_tid(pid_t tid)
+{
+#if defined __linux__
+ /* On Linux systems, drmGetClient() would return the thread ID
+ instead of the actual process ID */
+ return syscall(SYS_gettid) == tid;
+#else
+ return false;
+#endif
+}
+
/* Checks whether DRM connection is authenticated */
bool
va_drm_is_authenticated(int fd)
@@ -41,7 +58,7 @@ va_drm_is_authenticated(int fd)
for (i = 0; !is_authenticated; i++) {
if (drmGetClient(fd, i, &auth, &pid, &uid, &magic, &iocs) != 0)
break;
- is_authenticated = auth && pid == client_pid;
+ is_authenticated = auth && (pid == client_pid || is_local_tid(pid));
}
return is_authenticated;
}