Skip to content

Commit e547816

Browse files
arndbDanilo Krummrich
authored andcommitted
drm/nouveau: check ioctl command codes better
nouveau_drm_ioctl() only checks the _IOC_NR() bits in the DRM_NOUVEAU_NVIF command, but ignores the type and direction bits, so any command with '7' in the low eight bits gets passed into nouveau_abi16_ioctl() instead of drm_ioctl(). Check for all the bits except the size that is handled inside of the handler. Fixes: 27111a2 ("drm/nouveau: expose the full object/event interfaces to userspace") Signed-off-by: Arnd Bergmann <[email protected]> [ Fix up two checkpatch warnings and a typo. - Danilo ] Signed-off-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent bd46cec commit e547816

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/gpu/drm/nouveau/nouveau_drm.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,9 @@ nouveau_ioctls[] = {
12841284
DRM_IOCTL_DEF_DRV(NOUVEAU_EXEC, nouveau_exec_ioctl_exec, DRM_RENDER_ALLOW),
12851285
};
12861286

1287+
#define DRM_IOCTL_NOUVEAU_NVIF _IOC(_IOC_READ | _IOC_WRITE, DRM_IOCTL_BASE, \
1288+
DRM_COMMAND_BASE + DRM_NOUVEAU_NVIF, 0)
1289+
12871290
long
12881291
nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
12891292
{
@@ -1297,14 +1300,10 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
12971300
return ret;
12981301
}
12991302

1300-
switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
1301-
case DRM_NOUVEAU_NVIF:
1303+
if ((cmd & ~IOCSIZE_MASK) == DRM_IOCTL_NOUVEAU_NVIF)
13021304
ret = nouveau_abi16_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
1303-
break;
1304-
default:
1305+
else
13051306
ret = drm_ioctl(file, cmd, arg);
1306-
break;
1307-
}
13081307

13091308
pm_runtime_mark_last_busy(dev->dev);
13101309
pm_runtime_put_autosuspend(dev->dev);

0 commit comments

Comments
 (0)