switch compat_drm_getsareactx() to drm_ioctl_kernel()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 25 May 2017 16:50:51 +0000 (12:50 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 27 May 2017 19:39:36 +0000 (15:39 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/gpu/drm/drm_ioc32.c

index e808121..2f017e3 100644 (file)
@@ -517,28 +517,21 @@ static int compat_drm_setsareactx(struct file *file, unsigned int cmd,
 static int compat_drm_getsareactx(struct file *file, unsigned int cmd,
                                  unsigned long arg)
 {
-       struct drm_ctx_priv_map __user *request;
+       struct drm_ctx_priv_map req;
+       drm_ctx_priv_map32_t req32;
        drm_ctx_priv_map32_t __user *argp = (void __user *)arg;
        int err;
-       unsigned int ctx_id;
-       void *handle;
-
-       if (!access_ok(VERIFY_WRITE, argp, sizeof(*argp))
-           || __get_user(ctx_id, &argp->ctx_id))
-               return -EFAULT;
 
-       request = compat_alloc_user_space(sizeof(*request));
-       if (!request)
-               return -EFAULT;
-       if (__put_user(ctx_id, &request->ctx_id))
+       if (copy_from_user(&req32, argp, sizeof(req32)))
                return -EFAULT;
 
-       err = drm_ioctl(file, DRM_IOCTL_GET_SAREA_CTX, (unsigned long)request);
+       req.ctx_id = req32.ctx_id;
+       err = drm_ioctl_kernel(file, drm_legacy_getsareactx, &req, DRM_AUTH);
        if (err)
                return err;
 
-       if (__get_user(handle, &request->handle)
-           || __put_user((unsigned long)handle, &argp->handle))
+       req32.handle = ptr_to_compat(req.handle);
+       if (copy_to_user(argp, &req32, sizeof(req32)))
                return -EFAULT;
 
        return 0;
@@ -1007,7 +1000,7 @@ static struct {
        DRM_IOCTL32_DEF(DRM_IOCTL_FREE_BUFS, compat_drm_freebufs),
        [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP32)].fn = compat_drm_rmmap,
        DRM_IOCTL32_DEF(DRM_IOCTL_SET_SAREA_CTX, compat_drm_setsareactx),
-       [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX32)].fn = compat_drm_getsareactx,
+       DRM_IOCTL32_DEF(DRM_IOCTL_GET_SAREA_CTX, compat_drm_getsareactx),
        [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX32)].fn = compat_drm_resctx,
        [DRM_IOCTL_NR(DRM_IOCTL_DMA32)].fn = compat_drm_dma,
 #if IS_ENABLED(CONFIG_AGP)