From: Nikola Milutinovic Date: Sun, 22 Dec 2019 14:49:04 +0000 (+0100) Subject: sigprocmask should ignore HOW argument when SET is NULL. X-Git-Tag: VALGRIND_3_16_0~189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b70d208e97336fff617892f88d63afc97983d619;p=thirdparty%2Fvalgrind.git sigprocmask should ignore HOW argument when SET is NULL. 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 --- diff --git a/NEWS b/NEWS index e0689d5846..12cd501e2c 100644 --- 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. diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c index a316ed8735..4c3e3db177 100644 --- a/coregrind/m_signals.c +++ b/coregrind/m_signals.c @@ -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 ); }