linux(4): Check fd passed to unlockpt()

In our implementation, grantpt() and unlockpt() don't actually have
any use, because PTY's are created on the fly and already have proper
permissions upon creation.
Atleast check that a proper fd passed to unlockpt(). For grantpt()
Glibc calls TIOCGPTN ioctl which would fail if fd is not a master.

Differential Revision:	https://reviews.freebsd.org/D40100
MFC after:		1 week
This commit is contained in:
Dmitry Chagin
2023-05-18 10:55:39 +03:00
parent 743516d51f
commit 0f62290e7f
+6 -2
View File
@@ -1009,8 +1009,12 @@ linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args)
error = ENOIOCTL;
break;
case LINUX_TIOCSPTLCK:
/* Our unlockpt() does nothing. */
error = 0;
/*
* Our unlockpt() does nothing. Check that fd refers
* to a pseudo-terminal master device.
*/
args->cmd = TIOCPTMASTER;
error = (sys_ioctl(td, (struct ioctl_args *)args));
break;
default:
error = ENOIOCTL;