diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-29 03:09:18 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-29 03:09:18 +0000 |
commit | 4f0fdd7d6a9fc1249fb7bb52893b5593a1786851 (patch) | |
tree | 6a0265aaba3cbc5b26bf624f8c7f423af606cc8f | |
parent | 70411a54d4d3a713c9c70c36cd2d86b49955e423 (diff) |
drm: Return -ENOTTY for non-drm ioctls
From Charles Baylis
69a603aa170e1c145b93d5d7efcca83a8b1268fe in linux 5.10.y/5.10.54
3abab27c322e0f2acf981595aa8040c9164dc9fb in mainline linux
-rw-r--r-- | sys/dev/pci/drm/drm_ioctl.c | 3 | ||||
-rw-r--r-- | sys/dev/pci/drm/include/drm/drm_ioctl.h | 2 |
2 files changed, 5 insertions, 0 deletions
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 /** |