[Libva] [PATCH] drm: improve check for authentication.
Gwenole Beauchesne
gb.devel at gmail.com
Tue Jul 16 05:38:10 PDT 2013
Hi,
2013/7/16 Daniel Vetter <daniel at ffwll.ch>:
> On Mon, Jul 15, 2013 at 6:30 PM, Gwenole Beauchesne <gb.devel at gmail.com> wrote:
>> On Linux systems, the drmGetClient() function would return the thread ID
>> instead of the actual process ID.
>>
>> Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
>
> Oh dear, why is it always libva. I've prepared a patch to kill this
> ioctl (almost) completely since it's imo rather pointless. Now I've
> just discovered that libva uses it and will make it much harder to
> fake things in the kernel! Or have I just misread the code and it's
> actually possible to return -EINVAL for this ioctl and libva will
> transparently fall back to doing the X11 auth stuff?
Yes, we will transparently fallback to X11 auth. In this case, we
should not check auth status again if X11 auth was successful.
However, drmGetClient() was used to check we are already
authenticated. What would the alternative be?
Thanks,
Gwenole.
> Any reason we
> can't just rip this out?
>
> http://www.spinics.net/lists/dri-devel/msg41204.html
>
> Cheers, Daniel
>
>> ---
>> va/drm/va_drm_auth.c | 19 ++++++++++++++++++-
>> 1 file changed, 18 insertions(+), 1 deletion(-)
>>
>> 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;
>> }
>> --
>> 1.7.9.5
>>
>> _______________________________________________
>> Libva mailing list
>> Libva at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/libva
>
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
More information about the Libva
mailing list