git: addf706f6ff0 - stable/13 - linux(4): Check fd passed to unlockpt()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 29 Jun 2023 08:20:33 UTC
The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=addf706f6ff0214cc19fb6ad17b9994e91292065 commit addf706f6ff0214cc19fb6ad17b9994e91292065 Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2023-05-18 07:55:39 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> CommitDate: 2023-06-29 08:15:58 +0000 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 (cherry picked from commit 0f62290e7f749b7a453d413dd72c406129a9aba5) --- sys/compat/linux/linux_ioctl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index fd4afd3004be..25f5e6d8df0b 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -1010,8 +1010,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;