|
From: Nicholas N. <nj...@ca...> - 2004-02-09 09:39:45
|
[moving to valgrind-developers]
On Thu, 5 Feb 2004, Jeremy Fitzhardinge wrote:
> > Jeremy, can you take a look at the patch and tell me whether the
> > fd_allowed() call is needed in POST(epoll_create)? Thanks.
>
> fd_allowed is to check FDs as they're passed into syscalls; it shouldn't
> be necessary for FDs created by a syscall (ie, they should always be in
> a PRE(x)).
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)?
N
|