From: jsg Date: Thu, 29 Jul 2021 03:09:17 +0000 (+0000) Subject: drm: Return -ENOTTY for non-drm ioctls X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f1185129969c41237a8dab6c94976bf794523a5f;p=openbsd drm: Return -ENOTTY for non-drm ioctls From Charles Baylis 69a603aa170e1c145b93d5d7efcca83a8b1268fe in linux 5.10.y/5.10.54 3abab27c322e0f2acf981595aa8040c9164dc9fb in mainline linux --- diff --git a/sys/dev/pci/drm/drm_ioctl.c b/sys/dev/pci/drm/drm_ioctl.c index 336b8a37f79..c0b6abd206c 100644 --- a/sys/dev/pci/drm/drm_ioctl.c +++ b/sys/dev/pci/drm/drm_ioctl.c @@ -902,6 +902,9 @@ long drm_ioctl(struct file *filp, if (drm_dev_is_unplugged(dev)) return -ENODEV; + if (DRM_IOCTL_TYPE(cmd) != DRM_IOCTL_BASE) + return -ENOTTY; + is_driver_ioctl = nr >= DRM_COMMAND_BASE && nr < DRM_COMMAND_END; if (is_driver_ioctl) { diff --git a/sys/dev/pci/drm/include/drm/drm_ioctl.h b/sys/dev/pci/drm/include/drm/drm_ioctl.h index ca79b07962c..b597ec64f19 100644 --- a/sys/dev/pci/drm/include/drm/drm_ioctl.h +++ b/sys/dev/pci/drm/include/drm/drm_ioctl.h @@ -69,9 +69,11 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, #ifdef __linux__ #define DRM_IOCTL_NR(n) _IOC_NR(n) +#define DRM_IOCTL_TYPE(n) _IOC_TYPE(n) #define DRM_MAJOR 226 #else #define DRM_IOCTL_NR(n) ((n) & 0xff) +#define DRM_IOCTL_TYPE(n) IOCGROUP(n) #endif /**