diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2019-05-18 22:26:06 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2019-05-18 22:26:06 +0000 |
commit | f625d610c7018cef0380f81e513695c66615443c (patch) | |
tree | 76bc7f72b6e5291bc9d25b811c26747416e7d98e | |
parent | 9a2457d7cedef53d2890c38a7cd12af3c2c22c78 (diff) | |
download | strace-f625d610c7018cef0380f81e513695c66615443c.tar.gz |
Implement decoding of pidfd_send_signal syscall
... introduced by Linux kernel commit v5.1-rc1~6^2~1.
* signal.c (SYS_FUNC(pidfd_send_signal)): New function.
* linux/32/syscallent.h [424]: Wire up pidfd_send_signal.
* linux/64/syscallent.h: Likewise.
* linux/arm/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/powerpc64/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* linux/xtensa/syscallent.h: Likewise.
* linux/alpha/syscallent.h [534]: Likewise.
* linux/ia64/syscallent.h [1024 + 424]: Likewise.
* linux/mips/syscallent-n32.h [6424]: Likewise.
* linux/mips/syscallent-n64.h [5424]: Likewise.
* linux/mips/syscallent-o32.h [4424]: Likewise.
* NEWS: Mention this change.
* tests/pidfd_send_signal.c: New file.
* tests/gen_tests.in (pidfd_send_signal): New entry.
* tests/pure_executables.list: Add pidfd_send_signal.
* tests/.gitignore: Likewise.
29 files changed, 114 insertions, 3 deletions
@@ -7,13 +7,13 @@ Noteworthy changes in release ?.? (????-??-??) * Improvements * Added C-SKY architecture support. * Implemented decoding of SO_TIMESTAMP*_NEW control messages. - * Wired up clock_gettime64, clock_settime64, clock_adjtime64, + * Implemented decoding of clock_gettime64, clock_settime64, clock_adjtime64, clock_getres_time64, clock_nanosleep_time64, timer_gettime64, timer_settime64, timerfd_gettime64, timerfd_settime64, utimensat_time64, pselect6_time64, ppoll_time64, io_pgetevents_time64, recvmmsg_time64, mq_timedsend_time64, mq_timedreceive_time64, semtimedop_time64, - rt_sigtimedwait_time64, futex_time64, and sched_rr_get_interval_time64 - syscalls. + rt_sigtimedwait_time64, futex_time64, sched_rr_get_interval_time64, + and pidfd_send_signal syscalls. * Wired up getegid, geteuid, getppid, io_pgetevents, statfs64, and fstatfs64 syscalls on alpha. * Wired up kexec_file_load and migrate_pages syscalls on arm. diff --git a/linux/32/syscallent.h b/linux/32/syscallent.h index 3fba90512..0d78f42e9 100644 --- a/linux/32/syscallent.h +++ b/linux/32/syscallent.h @@ -312,6 +312,7 @@ [421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #undef sys_ARCH_mmap #undef ARCH_WANT_SYNC_FILE_RANGE2 diff --git a/linux/64/syscallent.h b/linux/64/syscallent.h index 4335145dc..7188f73bd 100644 --- a/linux/64/syscallent.h +++ b/linux/64/syscallent.h @@ -286,3 +286,4 @@ [293] = { 4, 0, SEN(rseq), "rseq" }, [294] = { 5, TD, SEN(kexec_file_load), "kexec_file_load" }, /* [295 ... 423] - reserved to sync up with other architectures */ +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, diff --git a/linux/alpha/syscallent.h b/linux/alpha/syscallent.h index a48e5a75c..c78a120a0 100644 --- a/linux/alpha/syscallent.h +++ b/linux/alpha/syscallent.h @@ -476,3 +476,5 @@ [530] = { 0, PU|NF, SEN(getegid), "getegid" }, [531] = { 0, PU|NF, SEN(geteuid), "geteuid" }, [532] = { 0, PU|NF, SEN(getppid), "getppid" }, +/* all other architectures have common numbers for new syscalls, alpha is the exception */ +[534] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, diff --git a/linux/arm/syscallent.h b/linux/arm/syscallent.h index f17b85b20..73d29eff2 100644 --- a/linux/arm/syscallent.h +++ b/linux/arm/syscallent.h @@ -430,6 +430,7 @@ [421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #ifdef __ARM_EABI__ # define ARM_FIRST_SHUFFLED_SYSCALL 500 diff --git a/linux/hppa/syscallent.h b/linux/hppa/syscallent.h index ebeaa1839..56f5682be 100644 --- a/linux/hppa/syscallent.h +++ b/linux/hppa/syscallent.h @@ -379,3 +379,4 @@ [421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, diff --git a/linux/i386/syscallent.h b/linux/i386/syscallent.h index 123c74b40..fee1cddf8 100644 --- a/linux/i386/syscallent.h +++ b/linux/i386/syscallent.h @@ -424,6 +424,7 @@ [421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #define SYS_socket_subcall 500 #include "subcall32.h" diff --git a/linux/ia64/syscallent.h b/linux/ia64/syscallent.h index bdbf44726..1e3934be5 100644 --- a/linux/ia64/syscallent.h +++ b/linux/ia64/syscallent.h @@ -342,3 +342,4 @@ [1024 + 332] = { 1, 0, SEN(pkey_free), "pkey_free" }, [1024 + 333] = { 4, 0, SEN(rseq), "rseq" }, /* [1024 + 334 ... 1024 + 423] - reserved to sync up with other architectures */ +[1024 + 424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, diff --git a/linux/m68k/syscallent.h b/linux/m68k/syscallent.h index 2e9dc8351..c35b0765e 100644 --- a/linux/m68k/syscallent.h +++ b/linux/m68k/syscallent.h @@ -422,6 +422,7 @@ [421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #define SYS_socket_subcall 500 #include "subcall32.h" diff --git a/linux/microblaze/syscallent.h b/linux/microblaze/syscallent.h index ad23bee82..aeda7b84e 100644 --- a/linux/microblaze/syscallent.h +++ b/linux/microblaze/syscallent.h @@ -428,3 +428,4 @@ [421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, diff --git a/linux/mips/syscallent-n32.h b/linux/mips/syscallent-n32.h index 7f7aa07b3..e9c5e5d23 100644 --- a/linux/mips/syscallent-n32.h +++ b/linux/mips/syscallent-n32.h @@ -361,6 +361,7 @@ [6421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [6422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [6423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[6424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, # define SYS_socket_subcall 6500 # include "subcall32.h" diff --git a/linux/mips/syscallent-n64.h b/linux/mips/syscallent-n64.h index baaab654b..f2bb30c52 100644 --- a/linux/mips/syscallent-n64.h +++ b/linux/mips/syscallent-n64.h @@ -337,6 +337,7 @@ [5327] = { 4, 0, SEN(rseq), "rseq" }, [5328] = { 6, 0, SEN(io_pgetevents_time64), "io_pgetevents" }, /* [5329 ... 5423] - reserved to sync up with other architectures */ +[5424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, # define SYS_socket_subcall 5500 # include "subcall64.h" diff --git a/linux/mips/syscallent-o32.h b/linux/mips/syscallent-o32.h index df0c98a58..9cd3b1d0c 100644 --- a/linux/mips/syscallent-o32.h +++ b/linux/mips/syscallent-o32.h @@ -408,6 +408,7 @@ [4421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [4422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [4423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[4424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, # define SYS_socket_subcall 4500 # include "subcall32.h" diff --git a/linux/powerpc/syscallent.h b/linux/powerpc/syscallent.h index b5eeaece2..ecda494c2 100644 --- a/linux/powerpc/syscallent.h +++ b/linux/powerpc/syscallent.h @@ -416,6 +416,7 @@ [421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #define SYS_socket_subcall 500 #include "subcall32.h" diff --git a/linux/powerpc64/syscallent.h b/linux/powerpc64/syscallent.h index e282198b1..3352b346e 100644 --- a/linux/powerpc64/syscallent.h +++ b/linux/powerpc64/syscallent.h @@ -393,6 +393,7 @@ [401] = { 5, TI, SEN(msgrcv), "msgrcv" }, [402] = { 3, TI, SEN(msgctl), "msgctl" }, /* [403 ... 423] - reserved to sync up with other architectures */ +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #define SYS_socket_subcall 500 #include "subcall64.h" diff --git a/linux/s390/syscallent.h b/linux/s390/syscallent.h index eff90fc06..8eaeae737 100644 --- a/linux/s390/syscallent.h +++ b/linux/s390/syscallent.h @@ -427,6 +427,7 @@ [421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #define SYS_socket_subcall 500 #include "subcall32.h" diff --git a/linux/s390x/syscallent.h b/linux/s390x/syscallent.h index 8561fdd16..3cf61144c 100644 --- a/linux/s390x/syscallent.h +++ b/linux/s390x/syscallent.h @@ -393,6 +393,7 @@ [401] = { 5, TI, SEN(msgrcv), "msgrcv" }, [402] = { 3, TI, SEN(msgctl), "msgctl" }, /* [403 ... 423] - reserved to sync up with other architectures */ +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #define SYS_socket_subcall 500 #include "subcall64.h" diff --git a/linux/sh/syscallent.h b/linux/sh/syscallent.h index d97f0aaae..b14d7ed1a 100644 --- a/linux/sh/syscallent.h +++ b/linux/sh/syscallent.h @@ -425,6 +425,7 @@ [421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #define SYS_socket_subcall 500 #include "subcall32.h" diff --git a/linux/sh64/syscallent.h b/linux/sh64/syscallent.h index c5a8fdea0..8a068ce5c 100644 --- a/linux/sh64/syscallent.h +++ b/linux/sh64/syscallent.h @@ -399,6 +399,7 @@ [392] = { 6, TD, SEN(preadv2), "preadv2" }, [393] = { 6, TD, SEN(pwritev2), "pwritev2" }, /* [403 ... 423] - reserved to sync up with other architectures */ +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #define SYS_socket_subcall 500 #include "subcall64.h" diff --git a/linux/sparc/syscallent.h b/linux/sparc/syscallent.h index 18aa94f99..19900af32 100644 --- a/linux/sparc/syscallent.h +++ b/linux/sparc/syscallent.h @@ -402,6 +402,7 @@ [421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #define SYS_socket_subcall 500 #include "subcall32.h" diff --git a/linux/sparc64/syscallent.h b/linux/sparc64/syscallent.h index 77123091f..1ed0dc234 100644 --- a/linux/sparc64/syscallent.h +++ b/linux/sparc64/syscallent.h @@ -382,6 +382,7 @@ [401] = { 5, TI, SEN(msgrcv), "msgrcv" }, [402] = { 3, TI, SEN(msgctl), "msgctl" }, /* [403 ... 423] - reserved to sync up with other architectures */ +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, #define SYS_socket_subcall 500 #include "subcall64.h" diff --git a/linux/x32/syscallent.h b/linux/x32/syscallent.h index 2446f0b30..d0f8e8db0 100644 --- a/linux/x32/syscallent.h +++ b/linux/x32/syscallent.h @@ -341,6 +341,7 @@ [333] = { 6, 0, SEN(io_pgetevents_time64), "io_pgetevents" }, [334] = { 4, 0, SEN(rseq), "rseq" }, /* [335 ... 423] - reserved to sync up with other architectures */ +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, /* * x32-specific system call numbers start at 512 to avoid cache impact * for native 64-bit operation. diff --git a/linux/x86_64/syscallent.h b/linux/x86_64/syscallent.h index 3e0ce6198..2ac8dc6c1 100644 --- a/linux/x86_64/syscallent.h +++ b/linux/x86_64/syscallent.h @@ -341,3 +341,4 @@ [333] = { 6, 0, SEN(io_pgetevents_time64), "io_pgetevents" }, [334] = { 4, 0, SEN(rseq), "rseq" }, /* [335 ... 423] - reserved to sync up with other architectures */ +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, diff --git a/linux/xtensa/syscallent.h b/linux/xtensa/syscallent.h index d01c7957d..6d0925710 100644 --- a/linux/xtensa/syscallent.h +++ b/linux/xtensa/syscallent.h @@ -369,3 +369,4 @@ [421] = { 4, TS, SEN(rt_sigtimedwait_time64), "rt_sigtimedwait_time64"}, [422] = { 6, 0, SEN(futex_time64), "futex_time64" }, [423] = { 2, 0, SEN(sched_rr_get_interval_time64), "sched_rr_get_interval_time64" }, +[424] = { 4, TD|TS, SEN(pidfd_send_signal), "pidfd_send_signal" }, @@ -648,6 +648,19 @@ SYS_FUNC(rt_tgsigqueueinfo) return RVAL_DECODED; } +SYS_FUNC(pidfd_send_signal) +{ + /* int pidfd */ + printfd(tcp, tcp->u_arg[0]); + /* int sig, siginfo_t *info */ + tprints(", "); + print_sigqueueinfo(tcp, tcp->u_arg[1], tcp->u_arg[2]); + /* unsigned int flags */ + tprintf(", %#x", (unsigned int) tcp->u_arg[3]); + + return RVAL_DECODED; +} + static int do_rt_sigtimedwait(struct tcb *const tcp, const print_obj_by_addr_fn print_ts, const sprint_obj_by_addr_fn sprint_ts) diff --git a/tests/.gitignore b/tests/.gitignore index 0d881d935..40380ac6e 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -374,6 +374,7 @@ personality personality-Xabbrev personality-Xraw personality-Xverbose +pidfd_send_signal pipe pipe2 pkey_alloc diff --git a/tests/gen_tests.in b/tests/gen_tests.in index 8bdf6ba82..b81e67d02 100644 --- a/tests/gen_tests.in +++ b/tests/gen_tests.in @@ -319,6 +319,7 @@ perf_event_open_unabbrev -a1 -v -e trace=perf_event_open personality-Xabbrev +personality.test -Xabbrev personality-Xraw +personality.test -a15 -Xraw personality-Xverbose +personality.test -Xverbose +pidfd_send_signal pipe2 -a15 pkey_alloc -a17 pkey_free -a13 diff --git a/tests/pidfd_send_signal.c b/tests/pidfd_send_signal.c new file mode 100644 index 000000000..014e43de0 --- /dev/null +++ b/tests/pidfd_send_signal.c @@ -0,0 +1,71 @@ +/* + * Check decoding of pidfd_send_signal syscall. + * + * Copyright (c) 2015-2019 The strace developers. + * All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "tests.h" +#include <unistd.h> +#include <asm/unistd.h> +#include "scno.h" + +#ifdef __NR_pidfd_send_signal + +# include <fcntl.h> +# include <stdio.h> +# include <signal.h> + +static const char *errstr; + +static long +sys_pidfd_send_signal(int pidfd, int sig, const void *info, int flags) +{ + kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL; + kernel_ulong_t arg1 = fill | (unsigned int) pidfd; + kernel_ulong_t arg2 = fill | (unsigned int) sig; + kernel_ulong_t arg3 = (unsigned long) info; + kernel_ulong_t arg4 = fill | (unsigned int) flags; + + long rc = syscall(__NR_pidfd_send_signal, arg1, arg2, arg3, arg4); + errstr = sprintrc(rc); + return rc; +} + +int +main(void) +{ + static const char null_path[] = "/dev/null"; + + int fd = open(null_path, O_RDONLY); + if (fd < 0) + perror_msg_and_fail("open: %s", null_path); + + TAIL_ALLOC_OBJECT_CONST_PTR(siginfo_t, si); + const void *esi = (const void *) si + 1; + + sys_pidfd_send_signal(fd, SIGUSR1, esi, 0); + printf("pidfd_send_signal(%d, SIGUSR1, %p, 0) = %s\n", + fd, esi, errstr); + + si->si_signo = SIGUSR1; + si->si_code = SI_QUEUE; + + sys_pidfd_send_signal(fd, SIGUSR2, si, -1); + printf("pidfd_send_signal(%d, SIGUSR2, {si_signo=SIGUSR1" + ", si_code=SI_QUEUE, si_errno=%d, si_pid=%u, si_uid=%u" + ", si_value={int=%d, ptr=%p}}, %#x) = %s\n", + fd, si->si_errno, si->si_pid, si->si_uid, si->si_int, si->si_ptr, + -1U, errstr); + + puts("+++ exited with 0 +++"); + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_pidfd_send_signal") + +#endif diff --git a/tests/pure_executables.list b/tests/pure_executables.list index 502ce5b37..258b8c65f 100755 --- a/tests/pure_executables.list +++ b/tests/pure_executables.list @@ -318,6 +318,7 @@ personality personality-Xabbrev personality-Xraw personality-Xverbose +pidfd_send_signal pipe pipe2 pkey_alloc |