]> www.infradead.org Git - users/dwmw2/linux.git/commit
drm: Return -ENOTTY for non-drm ioctls
authorCharles Baylis <cb-kernel@fishzet.co.uk>
Fri, 16 Jul 2021 16:43:12 +0000 (17:43 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 20 Jul 2021 13:57:43 +0000 (15:57 +0200)
commit3abab27c322e0f2acf981595aa8040c9164dc9fb
tree5044eea200c44d741c9f5f54b7e0fda2aef91145
parenta3a9ee4b5254f212c2adaa8cd8ca03bfa112f49d
drm: Return -ENOTTY for non-drm ioctls

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 <cb-kernel@fishzet.co.uk>
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/YPG3IBlzaMhfPqCr@stando.fishzet.co.uk
drivers/gpu/drm/drm_ioctl.c
include/drm/drm_ioctl.h