]> git.baikalelectronics.ru Git - kernel.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Jul 2021 11:31:01 +0000 (13:31 +0200)
commitcfaad266b5cc7d641793a15e62f2c1c0ff970b26
treedb12c45c46c9d40bb4f77e4b5e59bdd95c6ee94b
parentd61e5e6986c25a5625f6dad3512d61413e322e60
drm: Return -ENOTTY for non-drm ioctls

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 <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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/drm_ioctl.c
include/drm/drm_ioctl.h