[Libva] using libva video compression on system with no monitor
Xiang, Haihao
haihao.xiang at intel.com
Thu Aug 16 23:25:18 PDT 2012
On Fri, 2012-08-17 at 06:10 +0200, Gwenole Beauchesne wrote:
> 2012/8/16 Xiang, Haihao <haihao.xiang at intel.com>:
> > On Thu, 2012-08-16 at 10:25 +0200, Gwenole Beauchesne wrote:
> >> Hi,
> >>
> >> 2012/8/16 Xiang, Haihao <haihao.xiang at intel.com>:
> >>
> >> >> I see a comment in /va/drm/va_drm_auth.c
> >> >>
> >> >> /* Default: root + master privs are needed for the following call */
> >> >
> >> > Master is enough.
> >>
> >> Master requires "root" privileges.
> >
> > It works for me with just my user name.
>
> You only need to be authenticated to submit drm commands, you don't
> necessarily need master privs for that. Master privs requires root.
It is drmSetMaster()/drmDropMaster() requires root, not master itself.
It is possible that a fd opened by a normal user is the master fd too .
See drm_open_helper() in drm_fops.c
static int drm_open_helper(struct inode *inode, struct file *filp,
struct drm_device * dev)
{
...
if (!priv->minor->master) {
/* create a new master */
priv->minor->master = drm_master_create(priv->minor);
if (!priv->minor->master) {
mutex_unlock(&dev->struct_mutex);
ret = -ENOMEM;
goto out_free;
}
priv->is_master = 1; <==== It doesn't require root.
...
}
...
}
> > xhh at xhh-snb32:~/graphics/ex/vaapi/libva/test/vainfo$ ./vainfo
> > error: can't connect to X server! <------ Without X server
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> This is what I am saying. If you don't have an X server running, then
> a simple user can get authenticated, should he have the correct access
> rights to the device. In this case, you are authenticated and you
> don't call into drmAuthMagic(), unlike what you suggested.
Yes. My previous email also mentioned drmAuthMagic() isn't called in
this case.
However according to the ioctl table in drm_drv.c
...
DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, DRM_AUTH|DRM_MASTER),
...
root isn't needed for DRM_IOCTL_AUTH_MAGIC, so calling into
drmAuthMagic() doesn't require root. Actually if we change
if (!va_drm_is_authenticated(drm_state->fd)) {
if (!va_drm_authenticate(drm_state->fd, magic))
return VA_STATUS_ERROR_OPERATION_FAILED;
if (!va_drm_is_authenticated(drm_state->fd))
return VA_STATUS_ERROR_OPERATION_FAILED;
}
to
if (1) {
if (!va_drm_authenticate(drm_state->fd, magic))
return VA_STATUS_ERROR_OPERATION_FAILED;
if (!va_drm_is_authenticated(drm_state->fd))
return VA_STATUS_ERROR_OPERATION_FAILED;
}
A normal user can also run vainfo on DRM too if drm_state->fd is the
master fd.
Thanks
Haihao
More information about the Libva
mailing list