|
From: Mark W. <ma...@so...> - 2019-12-22 15:02:24
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=b70d208e97336fff617892f88d63afc97983d619 commit b70d208e97336fff617892f88d63afc97983d619 Author: Nikola Milutinovic <nik...@rt...> Date: Sun Dec 22 15:49:04 2019 +0100 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: --- NEWS | 1 + coregrind/m_signals.c | 31 +++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index e0689d5..12cd501 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 a316ed8..4c3e3db 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 ); } |