From: Greg Kroah-Hartman Date: Mon, 26 Jul 2021 09:06:10 +0000 (+0200) Subject: 4.14-stable patches X-Git-Tag: v4.4.277~41 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ffe2c3c5190a0630facc29f974eb128b73bdb8b2;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: drm-return-enotty-for-non-drm-ioctls.patch --- diff --git a/queue-4.14/drm-return-enotty-for-non-drm-ioctls.patch b/queue-4.14/drm-return-enotty-for-non-drm-ioctls.patch new file mode 100644 index 00000000000..542cd06d707 --- /dev/null +++ b/queue-4.14/drm-return-enotty-for-non-drm-ioctls.patch @@ -0,0 +1,56 @@ +From 3abab27c322e0f2acf981595aa8040c9164dc9fb Mon Sep 17 00:00:00 2001 +From: Charles Baylis +Date: Fri, 16 Jul 2021 17:43:12 +0100 +Subject: drm: Return -ENOTTY for non-drm ioctls + +From: Charles Baylis + +commit 3abab27c322e0f2acf981595aa8040c9164dc9fb upstream. + +drm: Return -ENOTTY for non-drm ioctls + +Return -ENOTTY from drm_ioctl() when userspace passes in a cmd number +which doesn't relate to the drm subsystem. + +Glibc uses the TCGETS ioctl to implement isatty(), and without this +change isatty() returns it incorrectly returns true for drm devices. + +To test run this command: +$ if [ -t 0 ]; then echo is a tty; fi < /dev/dri/card0 +which shows "is a tty" without this patch. + +This may also modify memory which the userspace application is not +expecting. + +Signed-off-by: Charles Baylis +Cc: stable@vger.kernel.org +Signed-off-by: Daniel Vetter +Link: https://patchwork.freedesktop.org/patch/msgid/YPG3IBlzaMhfPqCr@stando.fishzet.co.uk +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/drm_ioctl.c | 3 +++ + include/drm/drm_ioctl.h | 1 + + 2 files changed, 4 insertions(+) + +--- a/drivers/gpu/drm/drm_ioctl.c ++++ b/drivers/gpu/drm/drm_ioctl.c +@@ -776,6 +776,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) { +--- a/include/drm/drm_ioctl.h ++++ b/include/drm/drm_ioctl.h +@@ -68,6 +68,7 @@ typedef int drm_ioctl_compat_t(struct fi + unsigned long arg); + + #define DRM_IOCTL_NR(n) _IOC_NR(n) ++#define DRM_IOCTL_TYPE(n) _IOC_TYPE(n) + #define DRM_MAJOR 226 + + /** diff --git a/queue-4.14/series b/queue-4.14/series index d84dc14ce7f..723c402d59a 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -73,3 +73,4 @@ tracing-fix-bug-in-rb_per_cpu_empty-that-might-cause-deadloop.patch media-ngene-fix-out-of-bounds-bug-in-ngene_command_config_free_buf.patch ixgbe-fix-packet-corruption-due-to-missing-dma-sync.patch selftest-use-mmap-instead-of-posix_memalign-to-allocate-memory.patch +drm-return-enotty-for-non-drm-ioctls.patch