From: Nicholas Nethercote Date: Fri, 24 Jun 2005 21:41:28 +0000 (+0000) Subject: Fix bug #107524 -- epoll_ctl does not access 'events' if it's a X-Git-Tag: svn/VALGRIND_3_0_0~304 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5986d3e25f58f6773d0d27179a20f4ea6be415ba;p=thirdparty%2Fvalgrind.git Fix bug #107524 -- epoll_ctl does not access 'events' if it's a EPOLL_CTL_DEL invocation. Also renamed our "struct epoll_event" to "struct vki_epoll_event" as it should be called. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4014 --- diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index f98156ea9e..cec3d9dad1 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -567,8 +567,9 @@ PRE(sys_epoll_ctl) PRINT("sys_epoll_ctl ( %d, %s, %d, %p )", ARG1, ( ARG2<3 ? epoll_ctl_s[ARG2] : "?" ), ARG3, ARG4); PRE_REG_READ4(long, "epoll_ctl", - int, epfd, int, op, int, fd, struct epoll_event *, event); - PRE_MEM_READ( "epoll_ctl(event)", ARG4, sizeof(struct epoll_event) ); + int, epfd, int, op, int, fd, struct vki_epoll_event *, event); + if (ARG2 != VKI_EPOLL_CTL_DEL) + PRE_MEM_READ( "epoll_ctl(event)", ARG4, sizeof(struct vki_epoll_event) ); } PRE(sys_epoll_wait) @@ -576,15 +577,15 @@ PRE(sys_epoll_wait) *flags |= SfMayBlock; PRINT("sys_epoll_wait ( %d, %p, %d, %d )", ARG1, ARG2, ARG3, ARG4); PRE_REG_READ4(long, "epoll_wait", - int, epfd, struct epoll_event *, events, + int, epfd, struct vki_epoll_event *, events, int, maxevents, int, timeout); - PRE_MEM_WRITE( "epoll_wait(events)", ARG2, sizeof(struct epoll_event)*ARG3); + PRE_MEM_WRITE( "epoll_wait(events)", ARG2, sizeof(struct vki_epoll_event)*ARG3); } POST(sys_epoll_wait) { vg_assert(SUCCESS); if (RES > 0) - POST_MEM_WRITE( ARG2, sizeof(struct epoll_event)*RES ) ; + POST_MEM_WRITE( ARG2, sizeof(struct vki_epoll_event)*RES ) ; } PRE(sys_gettid) diff --git a/include/vki-linux.h b/include/vki-linux.h index 504570b554..951fb24ca3 100644 --- a/include/vki-linux.h +++ b/include/vki-linux.h @@ -845,16 +845,21 @@ struct vki_elf_prpsinfo }; //---------------------------------------------------------------------- -// From linux-2.6.8.1/include/linux/eventpoll.h +// From linux-2.6.12.1/include/linux/eventpoll.h //---------------------------------------------------------------------- +/* Valid opcodes to issue to sys_epoll_ctl() */ +#define VKI_EPOLL_CTL_ADD 1 +#define VKI_EPOLL_CTL_DEL 2 +#define VKI_EPOLL_CTL_MOD 3 + #ifdef __x86_64__ #define VKI_EPOLL_PACKED __attribute__((packed)) #else #define VKI_EPOLL_PACKED #endif -struct epoll_event { +struct vki_epoll_event { __vki_u32 events; __vki_u64 data; } VKI_EPOLL_PACKED;