[PATCH xf86-video-ati] DRI3: Refuse to open DRM file descriptor for ssh clients
Alex Deucher
alexdeucher at gmail.com
Mon Mar 28 16:32:11 UTC 2016
On Mon, Mar 28, 2016 at 5:45 AM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> Fixes hangs when attempting to use DRI3 on display connections forwarded
> via SSH.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93261
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
> ---
> src/radeon_dri3.c | 39 ++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c
> index 1415a0d..faaf4eb 100644
> --- a/src/radeon_dri3.c
> +++ b/src/radeon_dri3.c
> @@ -38,6 +38,7 @@
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <errno.h>
> +#include <libgen.h>
>
>
> static int
> @@ -86,6 +87,38 @@ radeon_dri3_open(ScreenPtr screen, RRProviderPtr provider, int *out)
> return Success;
> }
>
> +#if DRI3_SCREEN_INFO_VERSION >= 1
> +
> +static int
> +radeon_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 radeon_dri3_open(screen, provider, out);
> +
> + return BadAccess;
> +}
> +
> +#endif /* DRI3_SCREEN_INFO_VERSION >= 1 */
> +
> static PixmapPtr radeon_dri3_pixmap_from_fd(ScreenPtr screen,
> int fd,
> CARD16 width,
> @@ -179,9 +212,13 @@ static int radeon_dri3_fd_from_pixmap(ScreenPtr screen,
> }
>
> static dri3_screen_info_rec radeon_dri3_screen_info = {
> +#if DRI3_SCREEN_INFO_VERSION >= 1
> + .version = 1,
> + .open_client = radeon_dri3_open_client,
> +#else
> .version = 0,
> -
> .open = radeon_dri3_open,
> +#endif
> .pixmap_from_fd = radeon_dri3_pixmap_from_fd,
> .fd_from_pixmap = radeon_dri3_fd_from_pixmap
> };
> --
> 2.8.0.rc3
>
> _______________________________________________
> xorg-driver-ati mailing list
> xorg-driver-ati at lists.x.org
> https://lists.x.org/mailman/listinfo/xorg-driver-ati
More information about the xorg-driver-ati
mailing list