|
From: Jeremy F. <je...@go...> - 2004-02-10 01:22:16
|
On Mon, 2004-02-09 at 01:39, Nicholas Nethercote wrote: > Are you sure? > > AFAICT, fd_allowed() is used in the PRE() for all syscalls that take an fd > as an argument: > > readv, writev, close, dup2, read, write > > It is also used in the POST() for syscalls that produce a new fd: > > dup, open, creat, pipe, socketcall > > Generally, the fd opened is checked, and if it's not one allowed by > Valgrind, we close it again and return VKI_EMFILE. > > However, the following syscalls produce an fd but do not have the > fd_allowed check: > > dup2, fcntl(dup), fcntl64(dup), socketcall, futex > > POST(socketcall) even has the following comment: > > /* XXX TODO: check return fd against VG_(max_fd) */ > > So it seems these last ones should be checked, as should > POST(epoll_create)? You're right. The check in the POST() functions is to make sure that the kernel didn't allocate a client FD in Valgrind's reserved range. Some syscalls, like dup2, allow the client to ask for any FD they want, and others will just return the next available one, which may be in Valgrind's range. In these cases we should close the FD and return ENFILE (or maybe EMFILE). epoll should be the same. J |