Return EINVAL when an invalid file descriptor is specified.

MFC after:	1 month
This commit is contained in:
Dmitry Chagin 2017-02-26 19:51:44 +00:00
parent 92e10562d4
commit e0a254f6df

View file

@ -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;