Hi
The attached patch fixes a problem where non-drm ioctls are incorrectly handled by drm drivers.
This causes problems when isatty() is called on a file descriptor which was opened on a drm device node. Glibc implements isatty() by invoking the TCGETS ioctl on the fd. TCGETS is 0x5401, so this is handled by drm_ioctl as DRM_IOCTL_GET_UNIQUE, which succeeds, so isatty() returns true.
As a side effect, DRM_IOCTL_GET_UNIQUE also writes to a pointer, in the argument buffer, so the calling application's memory can be corrupted, causing a crash later.
Tested on an Ubuntu 20.10 VM under qemu with virgl: * "if [ -t 0 ]; then echo is a tty; fi < /dev/dri/card0" outputs nothing * glxgears still works
Thanks Charles