| 1 |
/* COVERAGE: rt_sigprocmask rt_sigaction rt_sigpending rt_sigqueueinfo */ |
| 2 |
/* COVERAGE: rt_sigsuspend rt_tgsigqueueinfo rt_sigtimedwait */ |
| 3 |
|
| 4 |
#define _GNU_SOURCE |
| 5 |
#include <sys/types.h> |
| 6 |
#include <unistd.h> |
| 7 |
#include <signal.h> |
| 8 |
#include <sys/syscall.h> |
| 9 |
#include <string.h> |
| 10 |
#include <signal.h> |
| 11 |
#include <linux/version.h> |
| 12 |
#include <sys/mman.h> |
| 13 |
|
| 14 |
// Calling rt_tgsigqueueinfo() from a 32-bit executable on RHEL6 s390x |
| 15 |
// (2.6.32-554.el6.s390x) causes a kernel crash. So, don't test |
| 16 |
// rt_tgsigqueueinfo() on kernels less than version 3.0. |
| 17 |
|
| 18 |
#if defined(__NR_rt_tgsigqueueinfo) && defined(__s390__) \ |
| 19 |
&& LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) |
| 20 |
#undef __NR_rt_tgsigqueueinfo |
| 21 |
#endif |
| 22 |
|
| 23 |
static void |
| 24 |
sig_act_handler(int signo) |
| 25 |
{ |
| 26 |
} |
| 27 |
|
| 28 |
static inline int |
| 29 |
__rt_sigqueueinfo(pid_t tgid, int sig, siginfo_t *siginfo) |
| 30 |
{ |
| 31 |
return syscall(__NR_rt_sigqueueinfo, tgid, sig, siginfo); |
| 32 |
} |
| 33 |
|
| 34 |
// rt_tgsigqueueinfo() was added in kernel 2.6.31. |
| 35 |
#ifdef __NR_rt_tgsigqueueinfo |
| 36 |
static inline int |
| 37 |
__rt_tgsigqueueinfo(pid_t tgid, pid_t tid, int sig, siginfo_t *siginfo) |
| 38 |
{ |
| 39 |
return syscall(__NR_rt_tgsigqueueinfo, tgid, tid, sig, siginfo); |
| 40 |
} |
| 41 |
#endif |
| 42 |
|
| 43 |
int main() |
| 44 |
{ |
| 45 |
mlockall(MCL_CURRENT); |
| 46 |
|
| 47 |
sigset_t mask, mask2, omask, omask2; |
| 48 |
siginfo_t siginfo; |
| 49 |
struct sigaction sa; |
| 50 |
struct timespec timeout; |
| 51 |
|
| 52 |
sigemptyset(&mask); |
| 53 |
sigaddset(&mask, SIGUSR1); |
| 54 |
sigaddset(&mask, SIGUSR2); |
| 55 |
sigprocmask(SIG_BLOCK, &mask, &omask); |
| 56 |
//staptest// rt_sigprocmask (SIG_BLOCK, \[SIGUSR1|SIGUSR2\], XXXX, 8) = 0 |
| 57 |
|
| 58 |
sigdelset(&mask, SIGUSR2); |
| 59 |
sigprocmask(SIG_UNBLOCK, &mask, &omask2); |
| 60 |
//staptest// rt_sigprocmask (SIG_UNBLOCK, \[SIGUSR1\], XXXX, 8) = 0 |
| 61 |
|
| 62 |
// glibc handles this one |
| 63 |
//sigprocmask(-1, &mask, NULL); |
| 64 |
|
| 65 |
// Causes a SIGSEGV |
| 66 |
//sigprocmask(SIG_BLOCK, (sigset_t *)-1, NULL); |
| 67 |
|
| 68 |
sigprocmask(SIG_BLOCK, &mask, (sigset_t *)-1); |
| 69 |
#ifdef __s390__ |
| 70 |
//staptest// rt_sigprocmask (SIG_BLOCK, \[SIGUSR1\], 0x[7]?[f]+, 8) = -NNNN (EFAULT) |
| 71 |
#else |
| 72 |
//staptest// rt_sigprocmask (SIG_BLOCK, \[SIGUSR1\], 0x[f]+, 8) = -NNNN (EFAULT) |
| 73 |
#endif |
| 74 |
|
| 75 |
memset(&sa, 0, sizeof(sa)); |
| 76 |
sa.sa_handler = SIG_IGN; |
| 77 |
sigemptyset(&sa.sa_mask); |
| 78 |
sigaddset(&sa.sa_mask, SIGALRM); |
| 79 |
sa.sa_flags = 0; |
| 80 |
sigaction(SIGUSR1, &sa, NULL); |
| 81 |
//staptest// rt_sigaction (SIGUSR1, {SIG_IGN}, 0x[0]+, 8) = 0 |
| 82 |
|
| 83 |
sa.sa_handler = SIG_DFL; |
| 84 |
sigaction(SIGUSR1, &sa, NULL); |
| 85 |
//staptest// rt_sigaction (SIGUSR1, {SIG_DFL}, 0x[0]+, 8) = 0 |
| 86 |
|
| 87 |
#ifdef __NR_sigaction |
| 88 |
syscall(__NR_sigaction, -1, &sa, NULL); |
| 89 |
//staptest// rt_sigaction (0x[f]+, {SIG_DFL}, 0x[0]+, 8) = -NNNN |
| 90 |
#endif |
| 91 |
|
| 92 |
// Causes a SIGSEGV |
| 93 |
//sigaction(SIGUSR1, (struct sigaction *)-1, NULL); |
| 94 |
|
| 95 |
// Causes a SIGSEGV |
| 96 |
//sigaction(SIGUSR1, &sa, (struct sigaction *)-1); |
| 97 |
|
| 98 |
sa.sa_handler = sig_act_handler; |
| 99 |
sigaction(SIGUSR1, &sa, NULL); |
| 100 |
#ifdef __ia64__ |
| 101 |
//staptest// rt_sigaction (SIGUSR1, {XXXX, [^,]+, \[SIGALRM\]}, 0x[0]+, 8) = 0 |
| 102 |
#else |
| 103 |
//staptest// rt_sigaction (SIGUSR1, {XXXX, [^,]+, XXXX, \[SIGALRM\]}, 0x[0]+, 8) = 0 |
| 104 |
#endif |
| 105 |
|
| 106 |
sigpending(&mask); |
| 107 |
//staptest// rt_sigpending (XXXX, 8) = 0 |
| 108 |
|
| 109 |
sigpending((sigset_t *) 0); |
| 110 |
//staptest// rt_sigpending (0x0, 8) = -NNNN (EFAULT) |
| 111 |
|
| 112 |
sigpending((sigset_t *)-1); |
| 113 |
#ifdef __s390__ |
| 114 |
//staptest// rt_sigpending (0x[7]?[f]+, 8) = -NNNN (EFAULT) |
| 115 |
#else |
| 116 |
//staptest// rt_sigpending (0x[f]+, 8) = -NNNN (EFAULT) |
| 117 |
#endif |
| 118 |
|
| 119 |
siginfo.si_signo = SIGUSR1; |
| 120 |
siginfo.si_code = SI_USER; |
| 121 |
siginfo.si_pid = getpid(); |
| 122 |
siginfo.si_uid = getuid(); |
| 123 |
siginfo.si_value.sival_int = 1; |
| 124 |
|
| 125 |
__rt_sigqueueinfo(getpid(), SIGUSR1, &siginfo); |
| 126 |
//staptest// rt_sigqueueinfo (NNNN, SIGUSR1, {si_signo=SIGUSR1, si_code=SI_USER, si_pid=NNNN, si_uid=NNNN}) = NNNN |
| 127 |
|
| 128 |
__rt_sigqueueinfo(-1, SIGUSR1, &siginfo); |
| 129 |
//staptest// rt_sigqueueinfo (-1, SIGUSR1, {si_signo=SIGUSR1, si_code=SI_USER, si_pid=NNNN, si_uid=NNNN}) = NNNN |
| 130 |
|
| 131 |
__rt_sigqueueinfo(getpid(), -1, &siginfo); |
| 132 |
//staptest// rt_sigqueueinfo (NNNN, 0x[f]+, {si_signo=SIGUSR1, si_code=SI_USER, si_pid=NNNN, si_uid=NNNN}) = NNNN |
| 133 |
|
| 134 |
__rt_sigqueueinfo(getpid(), SIGUSR1, (siginfo_t *)-1); |
| 135 |
#ifdef __s390__ |
| 136 |
//staptest// rt_sigqueueinfo (NNNN, SIGUSR1, 0x[7]?[f]+) = NNNN |
| 137 |
#else |
| 138 |
//staptest// rt_sigqueueinfo (NNNN, SIGUSR1, 0x[f]+) = NNNN |
| 139 |
#endif |
| 140 |
|
| 141 |
#ifdef __NR_rt_tgsigqueueinfo |
| 142 |
memset(&siginfo, 0, sizeof(siginfo)); |
| 143 |
siginfo.si_signo = SIGUSR1; |
| 144 |
siginfo.si_code = SI_USER; |
| 145 |
siginfo.si_pid = getpid(); |
| 146 |
siginfo.si_uid = getuid(); |
| 147 |
siginfo.si_value.sival_int = 1; |
| 148 |
__rt_tgsigqueueinfo(getpid(), getpid(), SIGUSR1, &siginfo); |
| 149 |
//staptest// [[[[rt_tgsigqueueinfo (NNNN, NNNN, SIGUSR1, {si_signo=SIGUSR1, si_code=SI_USER, si_pid=NNNN, si_uid=NNNN})!!!!ni_syscall ()]]]] = NNNN |
| 150 |
|
| 151 |
__rt_tgsigqueueinfo(-1, getpid(), SIGUSR1, &siginfo); |
| 152 |
//staptest// [[[[rt_tgsigqueueinfo (-1, NNNN, SIGUSR1, {si_signo=SIGUSR1, si_code=SI_USER, si_pid=NNNN, si_uid=NNNN})!!!!ni_syscall ()]]]] = NNNN |
| 153 |
|
| 154 |
__rt_tgsigqueueinfo(getpid(), -1, SIGUSR1, &siginfo); |
| 155 |
//staptest// [[[[rt_tgsigqueueinfo (NNNN, -1, SIGUSR1, {si_signo=SIGUSR1, si_code=SI_USER, si_pid=NNNN, si_uid=NNNN})!!!!ni_syscall ()]]]] = NNNN |
| 156 |
|
| 157 |
__rt_tgsigqueueinfo(getpid(), getpid(), -1, &siginfo); |
| 158 |
//staptest// [[[[rt_tgsigqueueinfo (NNNN, NNNN, 0x[f]+, {si_signo=SIGUSR1, si_code=SI_USER, si_pid=NNNN, si_uid=NNNN})!!!!ni_syscall ()]]]] = NNNN |
| 159 |
|
| 160 |
__rt_tgsigqueueinfo(getpid(), getpid(), SIGUSR1, (siginfo_t *)-1); |
| 161 |
#ifdef __s390__ |
| 162 |
//staptest// [[[[rt_tgsigqueueinfo (NNNN, NNNN, SIGUSR1, 0x[7]?[f]+)!!!!ni_syscall ()]]]] = NNNN |
| 163 |
#else |
| 164 |
//staptest// [[[[rt_tgsigqueueinfo (NNNN, NNNN, SIGUSR1, 0x[f]+)!!!!ni_syscall ()]]]] = NNNN |
| 165 |
#endif |
| 166 |
#endif |
| 167 |
|
| 168 |
// Restore the original signal masks. |
| 169 |
sigprocmask(SIG_BLOCK, &omask, NULL); |
| 170 |
//staptest// rt_sigprocmask (SIG_BLOCK, \[EMPTY\], 0x0, 8) = NNNN |
| 171 |
|
| 172 |
// The following SEGVs if compiled as a 32-on-64 bit binary on x86_64 |
| 173 |
#if __WORDSIZE == 64 |
| 174 |
sigprocmask(SIG_UNBLOCK, &omask2, NULL); |
| 175 |
//staptest// rt_sigprocmask (SIG_UNBLOCK, \[SIGUSR1|SIGUSR2\], 0x0, 8) = NNNN |
| 176 |
#endif |
| 177 |
|
| 178 |
sigemptyset(&mask); |
| 179 |
sigemptyset(&mask2); |
| 180 |
memset(&sa, 0, sizeof(sa)); |
| 181 |
sa.sa_handler = sig_act_handler; |
| 182 |
sigaction(SIGALRM, &sa, NULL); |
| 183 |
#ifdef __ia64__ |
| 184 |
//staptest// rt_sigaction (SIGALRM, {XXXX, 0x0, \[EMPTY\]}, 0x[0]+, 8) = 0 |
| 185 |
#else |
| 186 |
//staptest// rt_sigaction (SIGALRM, {XXXX, [^,]+, XXXX, \[EMPTY\]}, 0x[0]+, 8) = 0 |
| 187 |
#endif |
| 188 |
|
| 189 |
sigprocmask(SIG_UNBLOCK, &mask2, NULL); |
| 190 |
//staptest// rt_sigprocmask (SIG_UNBLOCK, \[EMPTY\], 0x[0]+, 8) = 0 |
| 191 |
|
| 192 |
alarm(5); |
| 193 |
#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) |
| 194 |
//staptest// setitimer (ITIMER_REAL, \[0.000000,5.000000\], XXXX) = NNNN |
| 195 |
#else |
| 196 |
//staptest// alarm (5) = NNNN |
| 197 |
#endif |
| 198 |
|
| 199 |
// The following SEGVs if compiled as a 32-on-64 bit binary on x86_64 |
| 200 |
#if __WORDSIZE == 64 |
| 201 |
sigsuspend(&mask); |
| 202 |
//staptest// rt_sigsuspend (\[EMPTY\], 8) = NNNN |
| 203 |
#endif |
| 204 |
|
| 205 |
alarm(0); |
| 206 |
#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) |
| 207 |
//staptest// setitimer (ITIMER_REAL, \[0.000000,0.000000\], XXXX) = NNNN |
| 208 |
#else |
| 209 |
//staptest// alarm (0) = NNNN |
| 210 |
#endif |
| 211 |
|
| 212 |
sigsuspend((sigset_t *)-1); |
| 213 |
#ifdef __s390__ |
| 214 |
//staptest// rt_sigsuspend (0x[7]?[f]+, 8) = NNNN |
| 215 |
#else |
| 216 |
//staptest// rt_sigsuspend (0x[f]+, 8) = NNNN |
| 217 |
#endif |
| 218 |
|
| 219 |
alarm(5); |
| 220 |
#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) |
| 221 |
//staptest// setitimer (ITIMER_REAL, \[0.000000,5.000000\], XXXX) = NNNN |
| 222 |
#else |
| 223 |
//staptest// alarm (5) = NNNN |
| 224 |
#endif |
| 225 |
|
| 226 |
timeout.tv_sec = 6; |
| 227 |
timeout.tv_nsec = 0; |
| 228 |
sigemptyset(&mask); |
| 229 |
sigaddset(&mask, SIGALRM); |
| 230 |
memset(&siginfo, 0, sizeof(siginfo)); |
| 231 |
siginfo.si_signo = SIGALRM; |
| 232 |
siginfo.si_code = SI_USER; |
| 233 |
siginfo.si_pid = getpid(); |
| 234 |
siginfo.si_uid = getuid(); |
| 235 |
siginfo.si_value.sival_int = 1; |
| 236 |
|
| 237 |
sigtimedwait(&mask, &siginfo, &timeout); |
| 238 |
//staptest// rt_sigtimedwait (\[SIGALRM\], {si_signo=SIGALRM, si_code=SI_USER, si_pid=NNNN, si_uid=NNNN}, \[6.000000000\], 8) = NNNN |
| 239 |
|
| 240 |
alarm(0); |
| 241 |
#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) |
| 242 |
//staptest// setitimer (ITIMER_REAL, \[0.000000,0.000000\], XXXX) = NNNN |
| 243 |
#else |
| 244 |
//staptest// alarm (0) = NNNN |
| 245 |
#endif |
| 246 |
|
| 247 |
// Causes a SIGSEGV... |
| 248 |
//sigtimedwait((sigset_t *)-1, &siginfo, &timeout); |
| 249 |
|
| 250 |
sigtimedwait(&mask, (siginfo_t *)-1, &timeout); |
| 251 |
#ifdef __s390__ |
| 252 |
//staptest// rt_sigtimedwait (\[SIGALRM\], 0x[7]?[f]+, \[6.000000000\], 8) = NNNN |
| 253 |
#else |
| 254 |
//staptest// rt_sigtimedwait (\[SIGALRM\], 0x[f]+, \[6.000000000\], 8) = NNNN |
| 255 |
#endif |
| 256 |
|
| 257 |
// The following SEGVs if compiled as a 32-on-64 bit binary on x86_64 in valid_timespec_to_timespec64() |
| 258 |
#if __WORDSIZE == 64 |
| 259 |
sigtimedwait(&mask, &siginfo, (struct timespec *)-1); |
| 260 |
#ifdef __s390__ |
| 261 |
//staptest// rt_sigtimedwait (\[SIGALRM\], {si_signo=SIGALRM, si_code=SI_KERNEL}, 0x[7]?[f]+, 8) = NNNN |
| 262 |
#else |
| 263 |
//staptest// rt_sigtimedwait (\[SIGALRM\], {si_signo=SIGALRM, si_code=SI_KERNEL}, 0x[f]+, 8) = NNNN |
| 264 |
#endif |
| 265 |
#endif |
| 266 |
|
| 267 |
return 0; |
| 268 |
} |
| 269 |
|