From: Ivo Raisr Date: Sun, 20 Nov 2016 05:19:02 +0000 (+0000) Subject: Solaris: Add syscall wrapper for sigsendsys(108) X-Git-Tag: svn/VALGRIND_3_13_0~276 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f6ff4a27bcf7b3431725dd1226465fddbf9c339;p=thirdparty%2Fvalgrind.git Solaris: Add syscall wrapper for sigsendsys(108) n-i-bz git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16145 --- diff --git a/coregrind/m_syswrap/syswrap-solaris.c b/coregrind/m_syswrap/syswrap-solaris.c index edc6672993..674674f77a 100644 --- a/coregrind/m_syswrap/syswrap-solaris.c +++ b/coregrind/m_syswrap/syswrap-solaris.c @@ -966,6 +966,7 @@ DECL_TEMPLATE(solaris, sys_statvfs); DECL_TEMPLATE(solaris, sys_fstatvfs); DECL_TEMPLATE(solaris, sys_nfssys); DECL_TEMPLATE(solaris, sys_waitid); +DECL_TEMPLATE(solaris, sys_sigsendsys); #if defined(SOLARIS_UTIMESYS_SYSCALL) DECL_TEMPLATE(solaris, sys_utimesys); #endif /* SOLARIS_UTIMESYS_SYSCALL */ @@ -5130,6 +5131,57 @@ POST(sys_waitid) POST_MEM_WRITE(ARG3, sizeof(vki_siginfo_t)); } +PRE(sys_sigsendsys) +{ + /* int sigsendsys(procset_t *psp, int sig); */ + PRINT("sys_sigsendsys( %#lx, %ld )", ARG1, SARG2); + PRE_REG_READ2(long, "sigsendsys", vki_procset_t *, psp, int, signal); + PRE_MEM_READ("sigsendsys(psp)", ARG1, sizeof(vki_procset_t)); + + if (!ML_(client_signal_OK)(ARG1)) { + SET_STATUS_Failure(VKI_EINVAL); + } + if (!ML_(safe_to_deref)((void *) ARG1, sizeof(vki_procset_t))) { + SET_STATUS_Failure(VKI_EFAULT); + } + + /* Exit early if there are problems. */ + if (FAILURE) + return; + + vki_procset_t *psp = (vki_procset_t *) ARG1; + switch (psp->p_op) { + case VKI_POP_AND: + break; + default: + VG_(unimplemented)("Syswrap of the sigsendsys call with op %u.", + psp->p_op); + } + + vki_id_t pid; + if ((psp->p_lidtype == VKI_P_PID) && (psp->p_ridtype == VKI_P_ALL)) { + pid = psp->p_lid; + } else if ((psp->p_lidtype == VKI_P_ALL) && (psp->p_ridtype == VKI_P_PID)) { + pid = psp->p_rid; + } else { + VG_(unimplemented)("Syswrap of the sigsendsys call with lidtype %u and" + "ridtype %u.", psp->p_lidtype, psp->p_ridtype); + } + + if (VG_(clo_trace_signals)) + VG_(message)(Vg_DebugMsg, "sigsendsys: sending signal to process %u\n", + pid); + + /* Handle SIGKILL specially. */ + if (ARG2 == VKI_SIGKILL && ML_(do_sigkill)(pid, -1)) { + SET_STATUS_Success(0); + return; + } + + /* Check to see if this gave us a pending signal. */ + *flags |= SfPollAfter; +} + #if defined(SOLARIS_UTIMESYS_SYSCALL) PRE(sys_utimesys) { @@ -10749,6 +10801,7 @@ static SyscallTableEntry syscall_table[] = { SOLXY(__NR_fstatvfs, sys_fstatvfs), /* 104 */ SOLXY(__NR_nfssys, sys_nfssys), /* 106 */ SOLXY(__NR_waitid, sys_waitid), /* 107 */ + SOLX_(__NR_sigsendsys, sys_sigsendsys), /* 108 */ #if defined(SOLARIS_UTIMESYS_SYSCALL) SOLX_(__NR_utimesys, sys_utimesys), /* 110 */ #endif /* SOLARIS_UTIMESYS_SYSCALL */ diff --git a/include/vki/vki-scnums-solaris.h b/include/vki/vki-scnums-solaris.h index aba743c13e..a788801da6 100644 --- a/include/vki/vki-scnums-solaris.h +++ b/include/vki/vki-scnums-solaris.h @@ -157,7 +157,7 @@ #define __NR_nfssys SYS_nfssys #define __NR_waitid SYS_waitid #define __NR_waitsys SYS_waitsys /* = SYS_waitid (historical) */ -//#define __NR_sigsendsys SYS_sigsendsys +#define __NR_sigsendsys SYS_sigsendsys //#define __NR_hrtsys SYS_hrtsys #if defined(SOLARIS_UTIMESYS_SYSCALL) #define __NR_utimesys SYS_utimesys diff --git a/include/vki/vki-solaris.h b/include/vki/vki-solaris.h index 4a74698e2c..eb6d82a8a8 100644 --- a/include/vki/vki-solaris.h +++ b/include/vki/vki-solaris.h @@ -814,6 +814,7 @@ typedef struct vki_kcf_door_arg_s { #define VKI_P_PID P_PID #define VKI_P_PGID P_PGID #define VKI_P_ALL P_ALL +#define VKI_POP_AND POP_AND #define vki_procset_t procset_t diff --git a/memcheck/tests/solaris/scalar.c b/memcheck/tests/solaris/scalar.c index 36bd4090a2..c96b6626ab 100644 --- a/memcheck/tests/solaris/scalar.c +++ b/memcheck/tests/solaris/scalar.c @@ -1934,7 +1934,8 @@ int main(void) SY(SYS_waitid, x0 - 1, x0, x0, x0); FAIL; /* SYS_sigsendsys 108 */ - /* XXX Missing wrapper. */ + GO(SYS_sigsendsys, "2s 1m"); + SY(SYS_sigsendsys, x0 - 1, x0); FAIL; /* SYS_hrtsys 109 */ /* XXX Missing wrapper. */ diff --git a/memcheck/tests/solaris/scalar.stderr.exp b/memcheck/tests/solaris/scalar.stderr.exp index c9c9d58625..274345483e 100644 --- a/memcheck/tests/solaris/scalar.stderr.exp +++ b/memcheck/tests/solaris/scalar.stderr.exp @@ -1850,6 +1850,19 @@ Syscall param waitid(infop) points to unaddressable byte(s) ... Address 0x........ is not stack'd, malloc'd or (recently) free'd +--------------------------------------------------------- +108: SYS_sigsendsys 2s 1m +--------------------------------------------------------- +Syscall param sigsendsys(psp) contains uninitialised byte(s) + ... + +Syscall param sigsendsys(signal) contains uninitialised byte(s) + ... + +Syscall param sigsendsys(psp) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + --------------------------------------------------------- 111: SYS_sigresend 3s 2m ---------------------------------------------------------