From e0a254f6dfad4586cd80b4873904e6ef8720e180 Mon Sep 17 00:00:00 2001 From: Dmitry Chagin Date: Sun, 26 Feb 2017 19:51:44 +0000 Subject: [PATCH] Return EINVAL when an invalid file descriptor is specified. MFC after: 1 month --- sys/compat/linux/linux_event.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c index 544914794df..973b5ea44b7 100644 --- a/sys/compat/linux/linux_event.c +++ b/sys/compat/linux/linux_event.c @@ -462,8 +462,10 @@ linux_epoll_ctl(struct thread *td, struct linux_epoll_ctl_args *args) cap_rights_init(&rights, CAP_KQUEUE_CHANGE), &epfp); if (error != 0) return (error); - if (epfp->f_type != DTYPE_KQUEUE) + if (epfp->f_type != DTYPE_KQUEUE) { + error = EINVAL; goto leave1; + } /* Protect user data vector from incorrectly supplied fd. */ error = fget(td, args->fd, cap_rights_init(&rights, CAP_POLL_EVENT), &fp); @@ -560,6 +562,10 @@ linux_epoll_wait_common(struct thread *td, int epfd, struct epoll_event *events, cap_rights_init(&rights, CAP_KQUEUE_EVENT), &epfp); if (error != 0) return (error); + if (epfp->f_type != DTYPE_KQUEUE) { + error = EINVAL; + goto leave; + } coargs.leventlist = events; coargs.p = td->td_proc;