switch compat_drm_addmap() to drm_ioctl_kernel()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2017-05-24 19:27:36 -04:00
parent 8547ee9d44
commit b36180a33b

View File

@ -194,35 +194,28 @@ static int compat_drm_addmap(struct file *file, unsigned int cmd,
{ {
drm_map32_t __user *argp = (void __user *)arg; drm_map32_t __user *argp = (void __user *)arg;
drm_map32_t m32; drm_map32_t m32;
struct drm_map __user *map; struct drm_map map;
int err; int err;
void *handle;
if (copy_from_user(&m32, argp, sizeof(m32))) if (copy_from_user(&m32, argp, sizeof(m32)))
return -EFAULT; return -EFAULT;
map = compat_alloc_user_space(sizeof(*map)); map.offset = m32.offset;
if (!map) map.size = m32.size;
return -EFAULT; map.type = m32.type;
if (__put_user(m32.offset, &map->offset) map.flags = m32.flags;
|| __put_user(m32.size, &map->size)
|| __put_user(m32.type, &map->type)
|| __put_user(m32.flags, &map->flags))
return -EFAULT;
err = drm_ioctl(file, DRM_IOCTL_ADD_MAP, (unsigned long)map); err = drm_ioctl_kernel(file, drm_legacy_addmap_ioctl, &map,
DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
if (err) if (err)
return err; return err;
if (__get_user(m32.offset, &map->offset) m32.offset = map.offset;
|| __get_user(m32.mtrr, &map->mtrr) m32.mtrr = map.mtrr;
|| __get_user(handle, &map->handle)) m32.handle = ptr_to_compat(map.handle);
return -EFAULT; if (map.handle != compat_ptr(m32.handle))
m32.handle = (unsigned long)handle;
if (m32.handle != (unsigned long)handle)
pr_err_ratelimited("compat_drm_addmap truncated handle %p for type %d offset %x\n", pr_err_ratelimited("compat_drm_addmap truncated handle %p for type %d offset %x\n",
handle, m32.type, m32.offset); map.handle, m32.type, m32.offset);
if (copy_to_user(argp, &m32, sizeof(m32))) if (copy_to_user(argp, &m32, sizeof(m32)))
return -EFAULT; return -EFAULT;
@ -1021,7 +1014,7 @@ static struct {
DRM_IOCTL32_DEF(DRM_IOCTL_GET_CLIENT, compat_drm_getclient), DRM_IOCTL32_DEF(DRM_IOCTL_GET_CLIENT, compat_drm_getclient),
DRM_IOCTL32_DEF(DRM_IOCTL_GET_STATS, compat_drm_getstats), DRM_IOCTL32_DEF(DRM_IOCTL_GET_STATS, compat_drm_getstats),
DRM_IOCTL32_DEF(DRM_IOCTL_SET_UNIQUE, compat_drm_setunique), DRM_IOCTL32_DEF(DRM_IOCTL_SET_UNIQUE, compat_drm_setunique),
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP32)].fn = compat_drm_addmap, DRM_IOCTL32_DEF(DRM_IOCTL_ADD_MAP, compat_drm_addmap),
DRM_IOCTL32_DEF(DRM_IOCTL_ADD_BUFS, compat_drm_addbufs), DRM_IOCTL32_DEF(DRM_IOCTL_ADD_BUFS, compat_drm_addbufs),
[DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS32)].fn = compat_drm_markbufs, [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS32)].fn = compat_drm_markbufs,
DRM_IOCTL32_DEF(DRM_IOCTL_INFO_BUFS, compat_drm_infobufs), DRM_IOCTL32_DEF(DRM_IOCTL_INFO_BUFS, compat_drm_infobufs),