]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
sigprocmask should ignore HOW argument when SET is NULL.
authorNikola Milutinovic <nikola.milutinovic@rt-rk.com>
Sun, 22 Dec 2019 14:49:04 +0000 (15:49 +0100)
committerMark Wielaard <mark@klomp.org>
Sun, 22 Dec 2019 14:51:36 +0000 (15:51 +0100)
Specific use case bug found in SysRes VG_(do_sys_sigprocmask).

Fix for case when ,,set,, parameter is NULL.
In this case ,,how,, parameter should be ignored because we are
only requesting from kernel to put current signal mask into ,,oldset,,.
But instead we determine the action based on ,,how,, parameter and
therefore make the system call fail when it should pass.
Taken from linux man pages (sigprocmask).

The same is specified for POSIX.

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

NEWS
coregrind/m_signals.c

diff --git a/NEWS b/NEWS
index e0689d58462de062c65ecf433ee1b8176b35b2ac..12cd501e2c4219efe3d44b5b21747bded740b595 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -85,6 +85,7 @@ where XXXXXX is the bug number as listed below.
 412344  Problem setting mips flags with specific paths
 413330  avx-1 test fails on AMD EPYC 7401P 24-Core Processor
 413603  callgrind_annotate/cg_annotate truncate function names at '#'
+414565  Specific use case bug found in SysRes VG_(do_sys_sigprocmask)
 
 n-i-bz  Fix minor one time leaks in dhat.
 n-i-bz  Add --run-cxx-freeres=no in outer args to avoid inner crashes.
index a316ed873539892121dbafd3634c9a345ed7e24e..4c3e3db177d0ce96418bc05a90f9580632eb906a 100644 (file)
@@ -1350,18 +1350,29 @@ SysRes VG_(do_sys_sigprocmask) ( ThreadId tid,
                                  vki_sigset_t* set,
                                  vki_sigset_t* oldset )
 {
-   switch(how) {
-      case VKI_SIG_BLOCK:
-      case VKI_SIG_UNBLOCK:
-      case VKI_SIG_SETMASK:
-         vg_assert(VG_(is_valid_tid)(tid));
-         do_setmask ( tid, how, set, oldset );
-         return VG_(mk_SysRes_Success)( 0 );
+   /* Fix for case when ,,set,, is NULL.
+      In this case ,,how,, flag should be ignored
+      because we are only requesting from kernel
+      to put current mask into ,,oldset,,.
+      Taken from linux man pages (sigprocmask).
+      The same is specified for POSIX.
+   */
+   if (set != NULL) {
+      switch(how) {
+         case VKI_SIG_BLOCK:
+         case VKI_SIG_UNBLOCK:
+         case VKI_SIG_SETMASK:
+            break;
 
-      default:
-         VG_(dmsg)("sigprocmask: unknown 'how' field %d\n", how);
-         return VG_(mk_SysRes_Error)( VKI_EINVAL );
+         default:
+            VG_(dmsg)("sigprocmask: unknown 'how' field %d\n", how);
+            return VG_(mk_SysRes_Error)( VKI_EINVAL );
+      }
    }
+
+   vg_assert(VG_(is_valid_tid)(tid));
+   do_setmask(tid, how, set, oldset);
+   return VG_(mk_SysRes_Success)( 0 );
 }