diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2016-03-30 18:33:00 +0900 |
---|---|---|
committer | Michel Dänzer <michel.daenzer@amd.com> | 2016-03-30 18:33:00 +0900 |
commit | 8ecfa69b5a833bd4c39e773a6acfd7eef9144d13 (patch) | |
tree | 19e1560eb8a4c56df68ef3a2c7e301434d71a06f /src | |
parent | b2a2e114eec0967f7b67f030fbab8983cf980489 (diff) |
DRI3: Refuse to open DRM file descriptor for ssh clients
Fixes hangs when attempting to use DRI3 on display connections forwarded
via SSH.
Don't do this for Xorg > 1.18.99.1 since the corresponding xserver
change has landed in Git master.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93261
(Ported from radeon commit 0b3aac1de9db42bfca545fa331e4985836682ec7)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/amdgpu_dri3.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/amdgpu_dri3.c b/src/amdgpu_dri3.c index 06d0668..c3042e7 100644 --- a/src/amdgpu_dri3.c +++ b/src/amdgpu_dri3.c @@ -38,6 +38,7 @@ #include <sys/stat.h> #include <fcntl.h> #include <errno.h> +#include <libgen.h> static int @@ -87,6 +88,38 @@ amdgpu_dri3_open(ScreenPtr screen, RRProviderPtr provider, int *out) return Success; } +#if DRI3_SCREEN_INFO_VERSION >= 1 && XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(1,18,99,1,0) + +static int +amdgpu_dri3_open_client(ClientPtr client, ScreenPtr screen, + RRProviderPtr provider, int *out) +{ + const char *cmdname = GetClientCmdName(client); + Bool is_ssh = FALSE; + + /* If the executable name is "ssh", assume that this client connection + * is forwarded from another host via SSH + */ + if (cmdname) { + char *cmd = strdup(cmdname); + + /* Cut off any colon and whatever comes after it, see + * https://lists.freedesktop.org/archives/xorg-devel/2015-December/048164.html + */ + cmd = strtok(cmd, ":"); + + is_ssh = strcmp(basename(cmd), "ssh") == 0; + free(cmd); + } + + if (!is_ssh) + return amdgpu_dri3_open(screen, provider, out); + + return BadAccess; +} + +#endif /* DRI3_SCREEN_INFO_VERSION >= 1 && XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(1,18,99,1,0) */ + static PixmapPtr amdgpu_dri3_pixmap_from_fd(ScreenPtr screen, int fd, CARD16 width, @@ -172,9 +205,13 @@ static int amdgpu_dri3_fd_from_pixmap(ScreenPtr screen, } static dri3_screen_info_rec amdgpu_dri3_screen_info = { +#if DRI3_SCREEN_INFO_VERSION >= 1 && XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(1,18,99,1,0) + .version = 1, + .open_client = amdgpu_dri3_open_client, +#else .version = 0, - .open = amdgpu_dri3_open, +#endif .pixmap_from_fd = amdgpu_dri3_pixmap_from_fd, .fd_from_pixmap = amdgpu_dri3_fd_from_pixmap }; |