Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

signal.c 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. /*
  2. * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  3. * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  4. * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
  5. * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  6. * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
  7. * Linux for s390 port by D.J. Barrow
  8. * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
  9. * Copyright (c) 2001-2019 The strace developers.
  10. * All rights reserved.
  11. *
  12. * SPDX-License-Identifier: LGPL-2.1-or-later
  13. */
  14. #include "defs.h"
  15. #include "nsig.h"
  16. #include "xstring.h"
  17. /* The libc headers do not define this constant since it should only be
  18. used by the implementation. So we define it here. */
  19. #ifndef SA_RESTORER
  20. # ifdef ASM_SA_RESTORER
  21. # define SA_RESTORER ASM_SA_RESTORER
  22. # endif
  23. #endif
  24. /*
  25. * Some architectures define SA_RESTORER in their headers,
  26. * but do not actually have sa_restorer.
  27. *
  28. * Some architectures, otherwise, do not define SA_RESTORER in their headers,
  29. * but actually have sa_restorer.
  30. */
  31. #ifdef HAVE_ARCH_SA_RESTORER
  32. # define HAVE_SA_RESTORER HAVE_ARCH_SA_RESTORER
  33. #else /* !HAVE_ARCH_SA_RESTORER */
  34. # ifdef SA_RESTORER
  35. # define HAVE_SA_RESTORER 1
  36. # else
  37. # define HAVE_SA_RESTORER 0
  38. # endif
  39. #endif /* HAVE_ARCH_SA_RESTORER */
  40. #include "xlat/sa_handler_values.h"
  41. #include "xlat/sigact_flags.h"
  42. #include "xlat/sigprocmaskcmds.h"
  43. /* Anonymous realtime signals. */
  44. #ifndef ASM_SIGRTMIN
  45. /* Linux kernel >= 3.18 defines SIGRTMIN to 32 on all architectures. */
  46. # define ASM_SIGRTMIN 32
  47. #endif
  48. #ifndef ASM_SIGRTMAX
  49. /* Under glibc 2.1, SIGRTMAX et al are functions, but __SIGRTMAX is a
  50. constant. This is what we want. Otherwise, just use SIGRTMAX. */
  51. # ifdef SIGRTMAX
  52. # ifndef __SIGRTMAX
  53. # define __SIGRTMAX SIGRTMAX
  54. # endif
  55. # endif
  56. # ifdef __SIGRTMAX
  57. # define ASM_SIGRTMAX __SIGRTMAX
  58. # endif
  59. #endif
  60. /* Note on the size of sigset_t:
  61. *
  62. * In glibc, sigset_t is an array with space for 1024 bits (!),
  63. * even though all arches supported by Linux have only 64 signals
  64. * except MIPS, which has 128. IOW, it is 128 bytes long.
  65. *
  66. * In-kernel sigset_t is sized correctly (it is either 64 or 128 bit long).
  67. * However, some old syscall return only 32 lower bits (one word).
  68. * Example: sys_sigpending vs sys_rt_sigpending.
  69. *
  70. * Be aware of this fact when you try to
  71. * memcpy(&tcp->u_arg[1], &something, sizeof(sigset_t))
  72. * - sizeof(sigset_t) is much bigger than you think,
  73. * it may overflow tcp->u_arg[] array, and it may try to copy more data
  74. * than is really available in <something>.
  75. * Similarly,
  76. * umoven(tcp, addr, sizeof(sigset_t), &sigset)
  77. * may be a bad idea: it'll try to read much more data than needed
  78. * to fetch a sigset_t.
  79. * Use NSIG_BYTES as a size instead.
  80. */
  81. static const char *
  82. get_sa_handler_str(kernel_ulong_t handler)
  83. {
  84. return xlookup(sa_handler_values, handler);
  85. }
  86. static void
  87. print_sa_handler(kernel_ulong_t handler)
  88. {
  89. const char *sa_handler_str = get_sa_handler_str(handler);
  90. if (sa_handler_str)
  91. print_xlat_ex(handler, sa_handler_str, XLAT_STYLE_DEFAULT);
  92. else
  93. printaddr(handler);
  94. }
  95. const char *
  96. signame(const int sig)
  97. {
  98. if (sig > 0) {
  99. const unsigned int s = sig;
  100. if (s < nsignals)
  101. return signalent[s];
  102. #ifdef ASM_SIGRTMAX
  103. if (s >= ASM_SIGRTMIN && s <= (unsigned int) ASM_SIGRTMAX) {
  104. static char buf[sizeof("SIGRT_%u") + sizeof(s) * 3];
  105. xsprintf(buf, "SIGRT_%u", s - ASM_SIGRTMIN);
  106. return buf;
  107. }
  108. #endif
  109. }
  110. return NULL;
  111. }
  112. const char *
  113. sprintsigname(const int sig)
  114. {
  115. const char *str = signame(sig);
  116. if (str)
  117. return str;
  118. static char buf[sizeof(sig) * 3 + 2];
  119. xsprintf(buf, "%d", sig);
  120. return buf;
  121. }
  122. const char *
  123. sprintsigmask_n(const char *prefix, const void *sig_mask, unsigned int bytes)
  124. {
  125. /*
  126. * The maximum number of signal names to be printed
  127. * is NSIG_BYTES * 8 * 2 / 3.
  128. * Most of signal names have length 7,
  129. * average length of signal names is less than 7.
  130. * The length of prefix string does not exceed 16.
  131. */
  132. static char outstr[128 + 8 * (NSIG_BYTES * 8 * 2 / 3)];
  133. char *s;
  134. const uint32_t *mask;
  135. uint32_t inverted_mask[NSIG_BYTES / 4];
  136. unsigned int size;
  137. int i;
  138. char sep;
  139. s = stpcpy(outstr, prefix);
  140. mask = sig_mask;
  141. /* length of signal mask in 4-byte words */
  142. size = (bytes >= NSIG_BYTES) ? NSIG_BYTES / 4 : (bytes + 3) / 4;
  143. /* check whether 2/3 or more bits are set */
  144. if (popcount32(mask, size) >= size * (4 * 8) * 2 / 3) {
  145. /* show those signals that are NOT in the mask */
  146. unsigned int j;
  147. for (j = 0; j < size; ++j)
  148. inverted_mask[j] = ~mask[j];
  149. mask = inverted_mask;
  150. *s++ = '~';
  151. }
  152. sep = '[';
  153. for (i = 0; (i = next_set_bit(mask, i, size * (4 * 8))) >= 0; ) {
  154. ++i;
  155. *s++ = sep;
  156. if ((unsigned) i < nsignals) {
  157. s = stpcpy(s, signalent[i] + 3);
  158. }
  159. #ifdef ASM_SIGRTMAX
  160. else if (i >= ASM_SIGRTMIN && i <= ASM_SIGRTMAX) {
  161. s = xappendstr(outstr, s, "RT_%u", i - ASM_SIGRTMIN);
  162. }
  163. #endif
  164. else {
  165. s = xappendstr(outstr, s, "%u", i);
  166. }
  167. sep = ' ';
  168. }
  169. if (sep == '[')
  170. *s++ = sep;
  171. *s++ = ']';
  172. *s = '\0';
  173. return outstr;
  174. }
  175. #define sprintsigmask_val(prefix, mask) \
  176. sprintsigmask_n((prefix), &(mask), sizeof(mask))
  177. #define tprintsigmask_val(prefix, mask) \
  178. tprints(sprintsigmask_n((prefix), &(mask), sizeof(mask)))
  179. static const char *
  180. sprint_old_sigmask_val(const char *const prefix, const unsigned long mask)
  181. {
  182. #if defined(current_wordsize) || !defined(WORDS_BIGENDIAN)
  183. return sprintsigmask_n(prefix, &mask, current_wordsize);
  184. #else /* !current_wordsize && WORDS_BIGENDIAN */
  185. if (current_wordsize == sizeof(mask)) {
  186. return sprintsigmask_val(prefix, mask);
  187. } else {
  188. uint32_t mask32 = mask;
  189. return sprintsigmask_val(prefix, mask32);
  190. }
  191. #endif
  192. }
  193. #define tprint_old_sigmask_val(prefix, mask) \
  194. tprints(sprint_old_sigmask_val((prefix), (mask)))
  195. void
  196. printsignal(int nr)
  197. {
  198. const char *str = signame(nr);
  199. if (!str || xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
  200. tprintf("%d", nr);
  201. if (!str || xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
  202. return;
  203. (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE
  204. ? tprints_comment : tprints)(str);
  205. }
  206. static void
  207. print_sigset_addr_len_limit(struct tcb *const tcp, const kernel_ulong_t addr,
  208. const kernel_ulong_t len, const unsigned int min_len)
  209. {
  210. /*
  211. * Here len is usually equal to NSIG_BYTES or current_wordsize.
  212. * But we code this defensively:
  213. */
  214. if (len < min_len || len > NSIG_BYTES) {
  215. printaddr(addr);
  216. return;
  217. }
  218. int mask[NSIG_BYTES / sizeof(int)] = {};
  219. if (umoven_or_printaddr(tcp, addr, len, mask))
  220. return;
  221. tprints(sprintsigmask_n("", mask, len));
  222. }
  223. void
  224. print_sigset_addr_len(struct tcb *const tcp, const kernel_ulong_t addr,
  225. const kernel_ulong_t len)
  226. {
  227. print_sigset_addr_len_limit(tcp, addr, len, current_wordsize);
  228. }
  229. void
  230. print_sigset_addr(struct tcb *const tcp, const kernel_ulong_t addr)
  231. {
  232. print_sigset_addr_len_limit(tcp, addr, NSIG_BYTES, NSIG_BYTES);
  233. }
  234. SYS_FUNC(ssetmask)
  235. {
  236. if (entering(tcp)) {
  237. tprint_old_sigmask_val("", (unsigned) tcp->u_arg[0]);
  238. } else if (!syserror(tcp)) {
  239. tcp->auxstr = sprint_old_sigmask_val("old mask ",
  240. (unsigned) tcp->u_rval);
  241. return RVAL_HEX | RVAL_STR;
  242. }
  243. return 0;
  244. }
  245. struct old_sigaction {
  246. /* sa_handler may be a libc #define, need to use other name: */
  247. #if defined MIPS
  248. unsigned int sa_flags;
  249. unsigned long sa_handler__;
  250. unsigned long sa_mask;
  251. #elif defined ALPHA
  252. unsigned long sa_handler__;
  253. unsigned long sa_mask;
  254. unsigned int sa_flags;
  255. #else
  256. unsigned long sa_handler__;
  257. unsigned long sa_mask;
  258. unsigned long sa_flags;
  259. unsigned long sa_restorer;
  260. #endif
  261. }
  262. #ifdef ALPHA
  263. ATTRIBUTE_PACKED
  264. #endif
  265. ;
  266. static void
  267. decode_old_sigaction(struct tcb *const tcp, const kernel_ulong_t addr)
  268. {
  269. struct old_sigaction sa;
  270. #ifndef current_wordsize
  271. if (current_wordsize < sizeof(sa.sa_handler__)) {
  272. struct old_sigaction32 {
  273. uint32_t sa_handler__;
  274. uint32_t sa_mask;
  275. uint32_t sa_flags;
  276. uint32_t sa_restorer;
  277. } sa32;
  278. if (umove_or_printaddr(tcp, addr, &sa32))
  279. return;
  280. memset(&sa, 0, sizeof(sa));
  281. sa.sa_handler__ = sa32.sa_handler__;
  282. sa.sa_flags = sa32.sa_flags;
  283. sa.sa_restorer = sa32.sa_restorer;
  284. sa.sa_mask = sa32.sa_mask;
  285. } else
  286. #endif
  287. if (umove_or_printaddr(tcp, addr, &sa))
  288. return;
  289. tprints("{sa_handler=");
  290. print_sa_handler(sa.sa_handler__);
  291. tprints(", sa_mask=");
  292. tprint_old_sigmask_val("", sa.sa_mask);
  293. tprints(", sa_flags=");
  294. printflags(sigact_flags, sa.sa_flags, "SA_???");
  295. #if !(defined ALPHA || defined MIPS)
  296. if (sa.sa_flags & 0x04000000U) {
  297. tprints(", sa_restorer=");
  298. printaddr(sa.sa_restorer);
  299. }
  300. #endif
  301. tprints("}");
  302. }
  303. SYS_FUNC(sigaction)
  304. {
  305. if (entering(tcp)) {
  306. int signo = tcp->u_arg[0];
  307. #if defined SPARC || defined SPARC64
  308. if (signo < 0) {
  309. tprints("-");
  310. signo = -signo;
  311. }
  312. #endif
  313. printsignal(signo);
  314. tprints(", ");
  315. decode_old_sigaction(tcp, tcp->u_arg[1]);
  316. tprints(", ");
  317. } else
  318. decode_old_sigaction(tcp, tcp->u_arg[2]);
  319. return 0;
  320. }
  321. SYS_FUNC(signal)
  322. {
  323. if (entering(tcp)) {
  324. printsignal(tcp->u_arg[0]);
  325. tprints(", ");
  326. print_sa_handler(tcp->u_arg[1]);
  327. return 0;
  328. } else if (!syserror(tcp)) {
  329. tcp->auxstr = get_sa_handler_str(tcp->u_rval);
  330. return RVAL_HEX | RVAL_STR;
  331. }
  332. return 0;
  333. }
  334. SYS_FUNC(sgetmask)
  335. {
  336. if (exiting(tcp) && !syserror(tcp)) {
  337. tcp->auxstr = sprint_old_sigmask_val("mask ", tcp->u_rval);
  338. return RVAL_HEX | RVAL_STR;
  339. }
  340. return 0;
  341. }
  342. SYS_FUNC(sigsuspend)
  343. {
  344. #ifdef MIPS
  345. print_sigset_addr_len(tcp, tcp->u_arg[n_args(tcp) - 1],
  346. current_wordsize);
  347. #else
  348. tprint_old_sigmask_val("", tcp->u_arg[n_args(tcp) - 1]);
  349. #endif
  350. return RVAL_DECODED;
  351. }
  352. #ifdef ALPHA
  353. /*
  354. * The OSF/1 sigprocmask is different: it doesn't pass in two pointers,
  355. * but rather passes in the new bitmask as an argument and then returns
  356. * the old bitmask. This "works" because we only have 64 signals to worry
  357. * about. If you want more, use of the rt_sigprocmask syscall is required.
  358. *
  359. * Alpha:
  360. * old = osf_sigprocmask(how, new);
  361. * Everyone else:
  362. * ret = sigprocmask(how, &new, &old, ...);
  363. */
  364. SYS_FUNC(osf_sigprocmask)
  365. {
  366. if (entering(tcp)) {
  367. printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
  368. tprintsigmask_val(", ", tcp->u_arg[1]);
  369. } else if (!syserror(tcp)) {
  370. tcp->auxstr = sprintsigmask_val("old mask ", tcp->u_rval);
  371. return RVAL_HEX | RVAL_STR;
  372. }
  373. return 0;
  374. }
  375. #else /* !ALPHA */
  376. /* "Old" sigprocmask, which operates with word-sized signal masks */
  377. SYS_FUNC(sigprocmask)
  378. {
  379. if (entering(tcp)) {
  380. printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
  381. tprints(", ");
  382. print_sigset_addr_len(tcp, tcp->u_arg[1], current_wordsize);
  383. tprints(", ");
  384. } else {
  385. print_sigset_addr_len(tcp, tcp->u_arg[2], current_wordsize);
  386. }
  387. return 0;
  388. }
  389. #endif /* !ALPHA */
  390. SYS_FUNC(kill)
  391. {
  392. /* pid */
  393. tprintf("%d, ", (int) tcp->u_arg[0]);
  394. /* signal */
  395. printsignal(tcp->u_arg[1]);
  396. return RVAL_DECODED;
  397. }
  398. SYS_FUNC(tgkill)
  399. {
  400. /* tgid, tid */
  401. tprintf("%d, %d, ", (int) tcp->u_arg[0], (int) tcp->u_arg[1]);
  402. /* signal */
  403. printsignal(tcp->u_arg[2]);
  404. return RVAL_DECODED;
  405. }
  406. SYS_FUNC(sigpending)
  407. {
  408. if (exiting(tcp))
  409. print_sigset_addr_len(tcp, tcp->u_arg[0], current_wordsize);
  410. return 0;
  411. }
  412. SYS_FUNC(rt_sigprocmask)
  413. {
  414. /* Note: arg[3] is the length of the sigset. Kernel requires NSIG_BYTES */
  415. if (entering(tcp)) {
  416. printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
  417. tprints(", ");
  418. print_sigset_addr_len(tcp, tcp->u_arg[1], tcp->u_arg[3]);
  419. tprints(", ");
  420. } else {
  421. print_sigset_addr_len(tcp, tcp->u_arg[2], tcp->u_arg[3]);
  422. tprintf(", %" PRI_klu, tcp->u_arg[3]);
  423. }
  424. return 0;
  425. }
  426. /* Structure describing the action to be taken when a signal arrives. */
  427. struct new_sigaction {
  428. /* sa_handler may be a libc #define, need to use other name: */
  429. #ifdef MIPS
  430. unsigned int sa_flags;
  431. unsigned long sa_handler__;
  432. #else
  433. unsigned long sa_handler__;
  434. unsigned long sa_flags;
  435. #endif /* !MIPS */
  436. #if HAVE_SA_RESTORER
  437. unsigned long sa_restorer;
  438. #endif
  439. /* Kernel treats sa_mask as an array of longs. */
  440. unsigned long sa_mask[NSIG / sizeof(long)];
  441. };
  442. /* Same for i386-on-x86_64 and similar cases */
  443. struct new_sigaction32 {
  444. uint32_t sa_handler__;
  445. uint32_t sa_flags;
  446. #if HAVE_SA_RESTORER
  447. uint32_t sa_restorer;
  448. #endif
  449. uint32_t sa_mask[2 * (NSIG / sizeof(long))];
  450. };
  451. static void
  452. decode_new_sigaction(struct tcb *const tcp, const kernel_ulong_t addr)
  453. {
  454. struct new_sigaction sa;
  455. #ifndef current_wordsize
  456. if (current_wordsize < sizeof(sa.sa_handler__)) {
  457. struct new_sigaction32 sa32;
  458. if (umove_or_printaddr(tcp, addr, &sa32))
  459. return;
  460. memset(&sa, 0, sizeof(sa));
  461. sa.sa_handler__ = sa32.sa_handler__;
  462. sa.sa_flags = sa32.sa_flags;
  463. # if HAVE_SA_RESTORER && defined SA_RESTORER
  464. sa.sa_restorer = sa32.sa_restorer;
  465. # endif
  466. /* Kernel treats sa_mask as an array of longs.
  467. * For 32-bit process, "long" is uint32_t, thus, for example,
  468. * 32th bit in sa_mask will end up as bit 0 in sa_mask[1].
  469. * But for (64-bit) kernel, 32th bit in sa_mask is
  470. * 32th bit in 0th (64-bit) long!
  471. * For little-endian, it's the same.
  472. * For big-endian, we swap 32-bit words.
  473. */
  474. sa.sa_mask[0] = ULONG_LONG(sa32.sa_mask[0], sa32.sa_mask[1]);
  475. } else
  476. #endif
  477. if (umove_or_printaddr(tcp, addr, &sa))
  478. return;
  479. tprints("{sa_handler=");
  480. print_sa_handler(sa.sa_handler__);
  481. tprints(", sa_mask=");
  482. /*
  483. * Sigset size is in tcp->u_arg[4] (SPARC)
  484. * or in tcp->u_arg[3] (all other),
  485. * but kernel won't handle sys_rt_sigaction
  486. * with wrong sigset size (just returns EINVAL instead).
  487. * We just fetch the right size, which is NSIG_BYTES.
  488. */
  489. tprintsigmask_val("", sa.sa_mask);
  490. tprints(", sa_flags=");
  491. printflags(sigact_flags, sa.sa_flags, "SA_???");
  492. #if HAVE_SA_RESTORER && defined SA_RESTORER
  493. if (sa.sa_flags & SA_RESTORER) {
  494. tprints(", sa_restorer=");
  495. printaddr(sa.sa_restorer);
  496. }
  497. #endif
  498. tprints("}");
  499. }
  500. SYS_FUNC(rt_sigaction)
  501. {
  502. if (entering(tcp)) {
  503. printsignal(tcp->u_arg[0]);
  504. tprints(", ");
  505. decode_new_sigaction(tcp, tcp->u_arg[1]);
  506. tprints(", ");
  507. } else {
  508. decode_new_sigaction(tcp, tcp->u_arg[2]);
  509. #if defined(SPARC) || defined(SPARC64)
  510. tprintf(", %#" PRI_klx ", %" PRI_klu, tcp->u_arg[3], tcp->u_arg[4]);
  511. #elif defined(ALPHA)
  512. tprintf(", %" PRI_klu ", %#" PRI_klx, tcp->u_arg[3], tcp->u_arg[4]);
  513. #else
  514. tprintf(", %" PRI_klu, tcp->u_arg[3]);
  515. #endif
  516. }
  517. return 0;
  518. }
  519. SYS_FUNC(rt_sigpending)
  520. {
  521. if (exiting(tcp)) {
  522. /*
  523. * One of the few syscalls where sigset size (arg[1])
  524. * is allowed to be <= NSIG_BYTES, not strictly ==.
  525. * This allows non-rt sigpending() syscall
  526. * to reuse rt_sigpending() code in kernel.
  527. */
  528. print_sigset_addr_len_limit(tcp, tcp->u_arg[0],
  529. tcp->u_arg[1], 1);
  530. tprintf(", %" PRI_klu, tcp->u_arg[1]);
  531. }
  532. return 0;
  533. }
  534. SYS_FUNC(rt_sigsuspend)
  535. {
  536. /* NB: kernel requires arg[1] == NSIG_BYTES */
  537. print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[1]);
  538. tprintf(", %" PRI_klu, tcp->u_arg[1]);
  539. return RVAL_DECODED;
  540. }
  541. static void
  542. print_sigqueueinfo(struct tcb *const tcp, const int sig,
  543. const kernel_ulong_t addr)
  544. {
  545. printsignal(sig);
  546. tprints(", ");
  547. printsiginfo_at(tcp, addr);
  548. }
  549. SYS_FUNC(rt_sigqueueinfo)
  550. {
  551. tprintf("%d, ", (int) tcp->u_arg[0]);
  552. print_sigqueueinfo(tcp, tcp->u_arg[1], tcp->u_arg[2]);
  553. return RVAL_DECODED;
  554. }
  555. SYS_FUNC(rt_tgsigqueueinfo)
  556. {
  557. tprintf("%d, %d, ", (int) tcp->u_arg[0], (int) tcp->u_arg[1]);
  558. print_sigqueueinfo(tcp, tcp->u_arg[2], tcp->u_arg[3]);
  559. return RVAL_DECODED;
  560. }
  561. SYS_FUNC(pidfd_send_signal)
  562. {
  563. /* int pidfd */
  564. printfd(tcp, tcp->u_arg[0]);
  565. /* int sig, siginfo_t *info */
  566. tprints(", ");
  567. print_sigqueueinfo(tcp, tcp->u_arg[1], tcp->u_arg[2]);
  568. /* unsigned int flags */
  569. tprintf(", %#x", (unsigned int) tcp->u_arg[3]);
  570. return RVAL_DECODED;
  571. }
  572. static int
  573. do_rt_sigtimedwait(struct tcb *const tcp, const print_obj_by_addr_fn print_ts,
  574. const sprint_obj_by_addr_fn sprint_ts)
  575. {
  576. /* NB: kernel requires arg[3] == NSIG_BYTES */
  577. if (entering(tcp)) {
  578. print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[3]);
  579. tprints(", ");
  580. if (!(tcp->u_arg[1] && verbose(tcp))) {
  581. /*
  582. * This is the only "return" parameter,
  583. * if we are not going to fetch it on exit,
  584. * decode all parameters on entry.
  585. */
  586. printaddr(tcp->u_arg[1]);
  587. tprints(", ");
  588. print_ts(tcp, tcp->u_arg[2]);
  589. tprintf(", %" PRI_klu, tcp->u_arg[3]);
  590. } else {
  591. char *sts = xstrdup(sprint_ts(tcp, tcp->u_arg[2]));
  592. set_tcb_priv_data(tcp, sts, free);
  593. }
  594. } else {
  595. if (tcp->u_arg[1] && verbose(tcp)) {
  596. printsiginfo_at(tcp, tcp->u_arg[1]);
  597. tprints(", ");
  598. tprints(get_tcb_priv_data(tcp));
  599. tprintf(", %" PRI_klu, tcp->u_arg[3]);
  600. }
  601. if (!syserror(tcp) && tcp->u_rval) {
  602. tcp->auxstr = signame(tcp->u_rval);
  603. return RVAL_STR;
  604. }
  605. }
  606. return 0;
  607. }
  608. #if HAVE_ARCH_TIME32_SYSCALLS
  609. SYS_FUNC(rt_sigtimedwait_time32)
  610. {
  611. return do_rt_sigtimedwait(tcp, print_timespec32, sprint_timespec32);
  612. }
  613. #endif
  614. SYS_FUNC(rt_sigtimedwait_time64)
  615. {
  616. return do_rt_sigtimedwait(tcp, print_timespec64, sprint_timespec64);
  617. }
  618. SYS_FUNC(restart_syscall)
  619. {
  620. tprintf("<... resuming interrupted %s ...>",
  621. tcp->s_prev_ent ? tcp->s_prev_ent->sys_name : "system call");
  622. return RVAL_DECODED;
  623. }