]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
epoll_pwait can have a NULL sigmask.
authorMark Wielaard <mark@klomp.org>
Sat, 17 Jun 2017 13:49:22 +0000 (13:49 +0000)
committerMark Wielaard <mark@klomp.org>
Sat, 17 Jun 2017 13:49:22 +0000 (13:49 +0000)
According to the epoll_pwait(2) man page:

       The  sigmask  argument  may  be  specified  as  NULL,  in  which  case
       epoll_pwait() is equivalent to epoll_wait().

But doing that under valgrind gives:

==13887== Syscall param epoll_pwait(sigmask) points to unaddressable byte(s)
==13887==    at 0x4F2B940: epoll_pwait (epoll_pwait.c:43)
==13887==    by 0x400ADE: main (syscalls-2007.c:89)
==13887==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

This is because the sys_epoll_pwait wrapper has:

   if (ARG4)
      PRE_MEM_READ( "epoll_pwait(sigmask)", ARG5, sizeof(vki_sigset_t) );

Which looks like a typo (ARG4 is timeout and ARG5 is sigmask).

This shows up with newer glibc which translates an epoll_wait call into
an epoll_pwait call with NULL sigmask.

Fix typo and add a testcase.

https://bugs.kde.org/show_bug.cgi?id=381289

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16451

NEWS
coregrind/m_syswrap/syswrap-linux.c
memcheck/tests/linux/syscalls-2007.c

diff --git a/NEWS b/NEWS
index 722910729dd69e34cd9e55254111caf53ce311da..1ed3e067d0538d20eaa85218f6d1f3caa591441c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,7 @@ where XXXXXX is the bug number as listed below.
 380397  s390x: __GI_strcspn() replacemenet needed
 381162  possible array overrun in VEX register allocator
 381272  ppc64 doesn't compile test_isa_2_06_partx.c without VSX support
+381289  epoll_pwait can have a NULL sigmask
 
 
 Release 3.13.0 (15 June 2017)
index 26e02fd02d74e37db809450f79647ce38a305274..4120c1d09d545de035021af0a310b95c1a3e97ba 100644 (file)
@@ -1901,7 +1901,7 @@ PRE(sys_epoll_pwait)
                  int, maxevents, int, timeout, vki_sigset_t *, sigmask,
                  vki_size_t, sigsetsize);
    PRE_MEM_WRITE( "epoll_pwait(events)", ARG2, sizeof(struct vki_epoll_event)*ARG3);
-   if (ARG4)
+   if (ARG5)
       PRE_MEM_READ( "epoll_pwait(sigmask)", ARG5, sizeof(vki_sigset_t) );
 }
 POST(sys_epoll_pwait)
index b61c6d56e2b9f0f73a0c65d6412d0b374e94fb7c..54946237eb1567084aa678dd802bcb1558843c2c 100644 (file)
@@ -79,5 +79,16 @@ int main (void)
   }
 #endif
 
+#if defined(HAVE_EPOLL_CREATE) && defined(HAVE_EPOLL_PWAIT)
+  {
+    int fd3;
+    struct epoll_event evs[10];
+
+    fd3 = epoll_create (10);
+    /* epoll_pwait can take a NULL sigmask. */
+    epoll_pwait (fd3, evs, 10, 1, NULL);
+  }
+#endif
+
   return 0;
 }