@@ -517,6 +517,13 @@ int drm_version(struct drm_device *dev, void *data,
return err;
}
+static inline bool
+drm_render_driver_and_ioctl(const struct drm_device *dev, u32 flags)
+{
+ return drm_core_check_feature(dev, DRIVER_RENDER) &&
+ (flags & DRM_RENDER_ALLOW);
+}
+
/**
* drm_ioctl_permit - Check ioctl permissions against caller
*
@@ -531,6 +538,8 @@ int drm_version(struct drm_device *dev, void *data,
*/
int drm_ioctl_permit(u32 flags, struct drm_file *file_priv)
{
+ const struct drm_device *dev = file_priv->minor->dev;
+
/* ROOT_ONLY is only for CAP_SYS_ADMIN */
if (unlikely((flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)))
return -EACCES;
@@ -538,7 +547,14 @@ int drm_ioctl_permit(u32 flags, struct drm_file *file_priv)
/* AUTH is only for authenticated or render client */
if (unlikely((flags & DRM_AUTH) && !drm_is_render_client(file_priv) &&
!file_priv->authenticated))
- return -EACCES;
+ /*
+ * Although we allow:
+ * - render drivers with DRM_RENDER_ALLOW ioctls, when
+ * - drivers do not explicitly mandate authentication.
+ */
+ if (!drm_render_driver_and_ioctl(dev, flags) ||
+ drm_core_check_feature(dev, DRIVER_FORCE_AUTH))
+ return -EACCES;
/* MASTER is only for master or control clients */
if (unlikely((flags & DRM_MASTER) &&