]> granicus.if.org Git - strace/log
strace
6 years agoAdd pure syscall flag
Eugene Syromyatnikov [Wed, 7 Feb 2018 17:46:54 +0000 (18:46 +0100)]
Add pure syscall flag

* basic_filters.c (lookup_class) <syscall_class>: Add "%pure" for
TRACE_PURE.
* sysent.h (TRACE_PURE): New syscall flag.
* sysent_shorthand_defs.h (PU): New shorthand macro.
* linux/32/syscallent.h ([172], [173], [174], [175], [176], [177],
[178]): Add PU flag to getpid, getppid, getuid, geteuid, getgid,
getegid, gettid syscalls.
* linux/64/syscallent.h ([172], [173], [174], [175], [176], [177],
[178]): Add PU flag to getpid, getppid, getuid, geteuid, getgid,
getegid, gettid syscalls.
* linux/aarch64/syscallent.h ([1060]): Add PU flag to getpgrp syscalls.
* linux/alpha/syscallent.h ([20], [24], [47], [63], [64], [89],
[378]): Add PU flag to getxpid, getxuid, getxgid, getpgrp, getpagesize,
getdtablesize, gettid syscalls.
* linux/arc/syscallent.h ([246]): Add PU flag to arc_gettls syscalls.
* linux/arm/syscallent.h ([20], [24], [47], [49], [50], [64], [65],
[199], [200], [201], [202], [224], [ARM_FIRST_SHUFFLED_SYSCALL+1+6]):
Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid,
getpgrp, getuid32, getgid32, geteuid32, getegid32, gettid, get_tls
syscalls.
* linux/avr32/syscallent.h ([20], [24], [47], [49], [50], [64], [65],
[176]): Add PU flag to getpid, getuid, getgid, geteuid, getegid,
getppid, getpgrp, gettid syscalls.
* linux/bfin/syscallent.h ([20], [24], [47], [49], [50], [64], [65],
[199], [200], [201], [202], [224]): Add PU flag to getpid, getuid,
getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32,
geteuid32, getegid32, gettid syscalls.
* linux/hppa/syscallent.h ([20], [24], [47], [49], [50], [64], [65],
[206]): Add PU flag to getpid, getuid, getgid, geteuid, getegid,
getppid, getpgrp, gettid syscalls.
* linux/i386/syscallent.h ([20], [24], [47], [49], [50], [64], [65],
[199], [200], [201], [202], [224]): Add PU flag to getpid, getuid,
getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32,
geteuid32, getegid32, gettid syscalls.
* linux/ia64/syscallent.h ([1041], [1042], [1046], [1047], [1062],
[1063], [1105], [1171]): Add PU flag to getpid, getppid, getuid,
geteuid, getgid, getegid, gettid, getpagesize syscalls.
* linux/m68k/syscallent.h ([20], [24], [47], [49], [50], [64],
[65], [166], [199], [200], [201], [202], [221], [333]): Add PU flag
to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp,
getpagesize, getuid32, getgid32, geteuid32, getegid32, gettid,
get_thread_area syscalls.
* linux/metag/syscallent.h ([248]): Add PU flag to metag_get_tls
syscalls.
* linux/microblaze/syscallent.h ([20], [24], [47], [49], [50], [64],
[65], [199], [200], [201], [202], [224]): Add PU flag to getpid,
getuid, getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32,
geteuid32, getegid32, gettid syscalls.
* linux/powerpc64/syscallent.h ([20], [24], [47], [49], [50], [64],
[65], [207]): Add PU flag to getpid, getuid, getgid, geteuid, getegid,
getppid, getpgrp, gettid syscalls.
* linux/powerpc/syscallent.h ([20], [24], [47], [49], [50], [64],
[65], [207]): Add PU flag to getpid, getuid, getgid, geteuid, getegid,
getppid, getpgrp, gettid syscalls.
* linux/s390/syscallent.h ([20], [24], [47], [49], [50], [64], [65],
[199], [200], [201], [202], [236]): Add PU flag to getpid, getuid,
getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32,
geteuid32, getegid32, gettid syscalls.
* linux/s390x/syscallent.h ([20], [64], [65], [199], [200], [201],
[202], [236]): Add PU flag to getpid, getppid, getpgrp, getuid,
getgid, geteuid, getegid, gettid syscalls.
* linux/sh64/syscallent.h ([20], [24], [47], [49], [50], [64], [65],
[199], [200], [201], [202], [252]): Add PU flag to getpid, getuid,
getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32,
geteuid32, getegid32, gettid syscalls.
* linux/sh/syscallent.h ([20], [24], [47], [49], [50], [64], [65],
[199], [200], [201], [202], [224]): Add PU flag to getpid, getuid,
getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32,
geteuid32, getegid32, gettid syscalls.
* linux/sparc64/syscallent.h ([20], [24], [47], [49], [50], [64], [81],
[143], [197], [340]): Add PU flag to getpid, getuid, getgid, geteuid,
getegid, getpagesize, getpgrp, gettid, getppid, kern_features syscalls.
* linux/sparc/syscallent.h ([20], [24], [44], [47], [49], [50], [53],
[64], [69], [70], [81], [143], [197], [340]): Add PU flag to getpid,
getuid, getuid32, getgid, geteuid, getegid, getgid32, getpagesize,
geteuid32, getegid32, getpgrp, gettid, getppid, kern_features syscalls.
* linux/x32/syscallent.h ([39], [102], [104], [107], [108], [110],
[111], [186]): Add PU flag to getpid, getuid, getgid, geteuid, getegid,
getppid, getpgrp, gettid syscalls.
* linux/x86_64/syscallent.h ([39], [102], [104], [107], [108], [110],
[111], [186]): Add PU flag to getpid, getuid, getgid, geteuid, getegid,
getppid, getpgrp, gettid syscalls.
* linux/xtensa/syscallent.h ([120], [127], [137], [139], [140], [141],
[150], [151]): Add PU flag to getpid, gettid, getuid, getgid, geteuid,
getegid, getppid, getpgrp syscalls.
* strace.1.in (.SS Filtering): Document it.
* NEWS: Mention it.

6 years agosyscall.c: warn if tampering failed
Eugene Syromyatnikov [Wed, 7 Feb 2018 01:16:50 +0000 (02:16 +0100)]
syscall.c: warn if tampering failed

6 years agosyscall.c: set errno if syscall is tampered
Eugene Syromyatnikov [Wed, 7 Feb 2018 01:17:18 +0000 (02:17 +0100)]
syscall.c: set errno if syscall is tampered

6 years agotests/nsyscall-d.test: swap exp and log in diff calls
Eugene Syromyatnikov [Fri, 9 Feb 2018 20:48:16 +0000 (21:48 +0100)]
tests/nsyscall-d.test: swap exp and log in diff calls

In line with the rest of the tests.

* tests/nsyscalls-d.test: swap arguments of match_diff calls.

6 years agolinux/arm/get_scno.c: use debug_msg
Eugene Syromyatnikov [Fri, 9 Feb 2018 20:47:16 +0000 (21:47 +0100)]
linux/arm/get_scno.c: use debug_msg

* linux/arm/get_scno.c (arch_get_scno): replace if (debug_flag) {
error_msg() } with debug_msg() call.

6 years agoDo not shuffle scno inside syscall_name
Eugene Syromyatnikov [Thu, 1 Feb 2018 11:50:31 +0000 (12:50 +0100)]
Do not shuffle scno inside syscall_name

This makes interface a bit irregular otherwise.

* defs.h (syscall_name): Clarify description.
* syscall.c (syscall_name): Do not call shuffle_scno.
* printsiginfo.c (print_si_info) <case SIGSYS>: Use shuffle_scno.

6 years agoHandle very special __ARM_NR_-prefixed syscalls
Eugene Syromyatnikov [Wed, 31 Jan 2018 19:28:56 +0000 (20:28 +0100)]
Handle very special __ARM_NR_-prefixed syscalls

* linux/aarch64/nr_prefix.c: New file.
* linux/arm/nr_prefix.c: Likewise.
* linux/nr_prefix.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* printsiginfo.c: Include nr_prefix.c
(print_si_info): Use nr_prefix.

6 years agoMake shuffle_scno globally available
Eugene Syromyatnikov [Thu, 1 Feb 2018 11:48:44 +0000 (12:48 +0100)]
Make shuffle_scno globally available

* syscall.c (shuffle_scno): Move the declaration...
* defs.h (shuffle_scno): ...here. Remove static qualifier.
* linux/aarch64/shuffle_scno.c (shuffle_scno): Remove static qualifier.
* linux/arm/shuffle_scno.c: Likewise.
* linux/shuffle_scno.c: Likewise.
* linux/x32/shuffle_scno.c: Likewise.
* linux/x86_64/shuffle_scno.c: Likewise.

6 years agosyscall.c: use shuffle_scno in syscall_name
Eugene Syromyatnikov [Wed, 31 Jan 2018 19:12:14 +0000 (20:12 +0100)]
syscall.c: use shuffle_scno in syscall_name

syscall_name() is used only in printsiginfo.c:print_si_info currently,
and is supplied with raw syscall number (that's why it has this ugly
__X32_SYSCALL_BIT hack). But since it handled only __X32_SYSCALL_BIT and
not shuffle_scno(), it was broken on ARM.  Let's replace it with shuffle_scno
call, as it handles both the case of shuffled ARM syscalls and the
__X32_SYSCALL_BIT.

* syscall.c (syscall_name): Call shuffle_scno instead of custom
__X32_SYSCALL_BIT handling.

6 years agoUse shuffle_scno for x32 syscall numbers
Eugene Syromyatnikov [Wed, 31 Jan 2018 19:08:29 +0000 (20:08 +0100)]
Use shuffle_scno for x32 syscall numbers

This changes behaviour of printing of unknown syscall.

* linux/x32/shuffle_scno.c: New file.
* linux/x86_64/shuffle_scno.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* linux/x86_64/get_scno.c (arch_get_scno): Do not clear
__X32_SYSCALL_BIT.
* tests/nsyscalls.c: Update expected output.

6 years agoMove shuffle_scno() invocation to get_scno
Eugene Syromyatnikov [Wed, 31 Jan 2018 19:06:31 +0000 (20:06 +0100)]
Move shuffle_scno() invocation to get_scno

* linux/aarch64/get_scno.c (arch_get_scno): Remove shuffle_scno call.
* linux/arm/get_scno.c (arch_get_scno): Remove shuffle_scno calls.
* syscall.c (get_scno): Call shuffle_scno after arch_get_scno.

6 years agoMove shuffle_scno to arch-specific file
Eugene Syromyatnikov [Wed, 31 Jan 2018 18:59:48 +0000 (19:59 +0100)]
Move shuffle_scno to arch-specific file

While we are here, let's fix AArch64 by limiting scno shuffling
to compat personality only.

* syscall.c: Include shuffle_scno.c.
(shuffle_scno): Move it to a...
* linux/arm/shuffle_scno.c: New file.
* linux/aarch64/shuffle_scno.c: New file, define arm's shuffle_scno
as arm_shuffle_scno and call it only for personality 1.
* linux/shuffle_scno.c: New file, fallback trivial shuffle_scno
definition.
* Makefile.am (EXTRA_DIST): Add them.

6 years agoPrint unknown syscall number in hexadecimal
Eugene Syromyatnikov [Tue, 6 Feb 2018 02:30:41 +0000 (03:30 +0100)]
Print unknown syscall number in hexadecimal

* syscall.c (struct sysent_buf): Update buf field size.
(get_scno): Print unknown syscall number in hexadecimal form.
* tests/nsyscalls.c: Update expected output.
* strace.1.in: Document it.
* NEWS: Mention it.

6 years agotests/accept.c: call accept syscall directly, if available
Eugene Syromyatnikov [Thu, 8 Feb 2018 10:58:30 +0000 (11:58 +0100)]
tests/accept.c: call accept syscall directly, if available

* tests/accept.c [__NR_accept && !TEST_SYSCALL_NAME]: Define a wrapper that
calls accept directly.
* tests/sockname.c [TEST_SYSCALL_STR]: Do not define TEST_SYSCALL_STR.

6 years agoprintsiginfo.c: add a comment about personality detection for SIGSYS
Eugene Syromyatnikov [Thu, 1 Feb 2018 10:46:57 +0000 (11:46 +0100)]
printsiginfo.c: add a comment about personality detection for SIGSYS

Looks like it is not necessary, after all.

6 years agolinux/x86_64/set_error.c: update eax for compat personality
Eugene Syromyatnikov [Thu, 8 Feb 2018 10:40:01 +0000 (11:40 +0100)]
linux/x86_64/set_error.c: update eax for compat personality

Since this is where get_error gets the return value from in the compat case.

linux/x86_64/set_error.c (set_error, set_success): Update i386_regs.eax
if tracee is in compat personality.

6 years agoMark various arch-specific syscalls with SYSCALL_NEVER_FAILS
Eugene Syromyatnikov [Wed, 7 Feb 2018 01:07:43 +0000 (02:07 +0100)]
Mark various arch-specific syscalls with SYSCALL_NEVER_FAILS

* linux/alpha/syscallent.h (getpagesize, getdtablesize): Add NF flag.
* linux/arc/syscallent.h (arc_gettls): Likewise.
* linux/arm/syscallent.h (get_tls): Likewise.
* linux/ia64/syscallent.h (getpagesize): Likewise.
* linux/m68k/syscallent.h (getpagesize, get_thread_area): Likewise.
* linux/sparc/syscallent.h (getpagesize): Likewise.
* linux/sparc64/syscallent.h (getpagesize): Likewise.

6 years agoAdd SYSCALL_NEVER_FAILS flag to getpgrp
Eugene Syromyatnikov [Wed, 7 Feb 2018 00:58:51 +0000 (01:58 +0100)]
Add SYSCALL_NEVER_FAILS flag to getpgrp

As glibc, at least, treats it this way.

* linux/aarch64/syscallent.h (getpgrp): Add NF flag.
* linux/alpha/syscallent.h: Likewise.
* linux/arm/syscallent.h: Likewise.
* linux/avr32/syscallent.h: Likewise.
* linux/bfin/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.

6 years agolinux/x86_64/get_error.c: do not sign-extend if no error happened
Eugene Syromyatnikov [Wed, 7 Feb 2018 01:19:06 +0000 (02:19 +0100)]
linux/x86_64/get_error.c: do not sign-extend if no error happened

6 years agotests/membarrier.c: fix expected output on nohz_full systems
Eugene Syromyatnikov [Thu, 8 Feb 2018 10:09:01 +0000 (11:09 +0100)]
tests/membarrier.c: fix expected output on nohz_full systems

If nohz_full is enabled, MEMBARRIER_CMD_GLOBAL is not available.

* tests/membarrier.c: check availability of MEMBARRIER_CMD_GLOBAL
separately.

6 years agoUpdate MEMBARRIER_CMD_* constants
Eugene Syromyatnikov [Thu, 8 Feb 2018 10:01:52 +0000 (11:01 +0100)]
Update MEMBARRIER_CMD_* constants

* xlat/membarrier_cmds.in: Add new constants, rename
MEMBARRIER_CMD_SHARED to MEMBARRIER_CMD_GLOBAL.
* NEWS: Mention this.
* tests/membarrier.c (main): Update expected output.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoperf.c: print group_fd argument of perf_event_open syscall as fd
Eugene Syromyatnikov [Wed, 7 Feb 2018 13:45:02 +0000 (14:45 +0100)]
perf.c: print group_fd argument of perf_event_open syscall as fd

* perf.c (SYS_FUNC(perf_event_open)): Print 4th argument using printfd.

6 years agosyscall.c: print higher bits of syscall return value on x32 personality
Eugene Syromyatnikov [Tue, 6 Feb 2018 23:58:30 +0000 (00:58 +0100)]
syscall.c: print higher bits of syscall return value on x32 personality

* syscall.c (syscall_exiting_trace): Check for current_klongsize instead
of current_wordsize to determine the size of tcp->u_rval.

6 years agostrace.1.in: history update
Eugene Syromyatnikov [Tue, 6 Feb 2018 01:21:28 +0000 (02:21 +0100)]
strace.1.in: history update

strace.1.in (.SH HISTORY): Some amendments based on
https://github.com/strace/strace-talks/blob/master/2012-ossdevconf-obninsk-strace_from_upstream_PoV/ossdevconf_2012-slides-strace_from_upstream_PoV.tex

6 years agostrace.1.in: minor changes
Eugene Syromyatnikov [Tue, 6 Feb 2018 01:12:59 +0000 (02:12 +0100)]
strace.1.in: minor changes

* strace.1.in (.SH DESCRIPTION): s/a passion/passion/,
s/Here the/Here, the/, s/Where traditional/Where the traditional/,
s/output has proven/output is proven/, s/In all cases/In most cases,/¸
embolden st_mode, lstat, SIGCHLD, and SIGTTOU mentions,
s/In some cases /In some cases, /
(.SS Output format) <-o>: de-italicize dot in "filename.pid", convert
the sentence's voice to passive, some other rephrasing.  Mention
incompatibility of output piping with -ff mode.
(.SS Output options) <-t>: s/time of day/wall clock time/.
(.SS Statistics) <-c>: Remove "on Linux" mention, -F option mention.

6 years agoREADME.md: add information about git repository location
Eugene Syromyatnikov [Mon, 5 Feb 2018 17:45:55 +0000 (18:45 +0100)]
README.md: add information about git repository location

* README.md: Mention URLs for SourceForge, GitHub, and GitLab
repositories.

6 years agotests: rewrite net-accept-connect.c without strncpy
Dmitry V. Levin [Wed, 7 Feb 2018 12:32:57 +0000 (12:32 +0000)]
tests: rewrite net-accept-connect.c without strncpy

gcc8 -Wall -Werror rejects our method of struct sockaddr_un.sun_path
initialization because the field lacks __nonstring__ attribute.

As we calculate the length of the string being copied anyway,
workaround this gcc+glibc bug by changing the code to use this
pre-calculated length and get rid of strncpy completely.

* tests/net-accept-connect.c (main): Use memcpy to initialize sun_path.

6 years agoUse kernel's fcntl.h header instead of libc's for open_mode_flags
Dmitry V. Levin [Fri, 2 Feb 2018 19:39:23 +0000 (19:39 +0000)]
Use kernel's fcntl.h header instead of libc's for open_mode_flags

As definitions of O_* macros provided by various libc implementations
are usually less reliable than those provided by kernel headers, switch
to use kernel's fcntl.h header.

* open.c: Include <asm/fcntl.h> instead of <fcntl.h>.  Remove
O_LARGEFILE fallback definitions assuming that the kernel headers
provide them.
* xlat/open_mode_flags.in: Add __O_SYNC after O_SYNC.  Add O_TMPFILE
and __O_TMPFILE before O_DIRECTORY.  Remove "O_TMPFILE & ~O_DIRECTORY".
* tests/open.c: Include <asm/fcntl.h> instead of <fcntl.h>.  Remove
workarounds for libc O_TMPFILE implementations.
* tests/openat.c: Include <asm/fcntl.h> instead of <fcntl.h>.
(test_mode_flag): New function.
(main): Use it to check decoding of all access modes and file flags.
* tests/gen_tests.in (openat): Add -a option.

Co-Authored-by: Eugene Syromyatnikov <evgsyr@gmail.com>
6 years agoxlat: update TCP_* constants
Dmitry V. Levin [Sun, 4 Feb 2018 00:22:01 +0000 (00:22 +0000)]
xlat: update TCP_* constants

* xlat/socktcpoptions.in: Add TCP_FASTOPEN_KEY and
TCP_FASTOPEN_NO_COOKIE introduced by linux kernel commits
v4.15-rc1~84^2~387 and v4.15-rc1~84^2~339, respectively.
* NEWS: Mention this.

6 years agoxlat: update IPV6_* constants
Dmitry V. Levin [Sat, 3 Feb 2018 00:19:17 +0000 (00:19 +0000)]
xlat: update IPV6_* constants

* xlat/sockipv6options.in: Add IPV6_FREEBIND introduced by linux kernel
commit v4.15-rc1~84^2~601.
* NEWS: Mention this.

6 years agoxlat: update MAP_* constants
Dmitry V. Levin [Fri, 2 Feb 2018 00:21:16 +0000 (00:21 +0000)]
xlat: update MAP_* constants

* xlat/mmap_flags.in: Add MAP_SHARED_VALIDATE and MAP_SYNC introduced
by linux kernel commits v4.15-rc1~71^2^2~23 and v4.15-rc1~71^2^2~12,
respectively.
* NEWS: Mention this.

6 years agotests: avoid triggering -Wstringop-truncation in ioctl_dm.c
Eugene Syromyatnikov [Tue, 6 Feb 2018 01:26:35 +0000 (02:26 +0100)]
tests: avoid triggering -Wstringop-truncation in ioctl_dm.c

* tests/ioctl_dm.c: Replace strncpy calls with memcpy as the character
arrays being copied are not C strings.

6 years agoMakefile.am: minor EXTRA_DIST formatting changes
Eugene Syromyatnikov [Wed, 31 Jan 2018 18:19:48 +0000 (19:19 +0100)]
Makefile.am: minor EXTRA_DIST formatting changes

6 years agoMove large file-related wrappers to a separate header
Eugene Syromyatnikov [Tue, 30 Jan 2018 09:09:54 +0000 (10:09 +0100)]
Move large file-related wrappers to a separate header

* strace.c [_LARGEFILE64_SOURCE]: Move the definitions under it to a...
* largefile_wrappers.h: ... new file.
* Makefile.am (strace_SOURCES): Add it.

6 years agostrace.1: fix wording about setuid installation
Dmitry V. Levin [Mon, 29 Jan 2018 17:49:24 +0000 (17:49 +0000)]
strace.1: fix wording about setuid installation

* strace.1.in (SETUID INSTALLATION): Fix wording.

Closes: https://github.com/strace/strace/issues/24
6 years agoAdd KVM_PPC_GET_CPU_CHAR ioctl definition from linux v4.15
Gleb Fotengauer-Malinovskiy [Mon, 29 Jan 2018 12:35:10 +0000 (15:35 +0300)]
Add KVM_PPC_GET_CPU_CHAR ioctl definition from linux v4.15

* linux/powerpc/ioctls_arch0.h: Update from linux v4.15
using ioctls_gen.sh.

6 years agoUpdate NEWS
Eugene Syromyatnikov [Wed, 17 Jan 2018 23:42:42 +0000 (00:42 +0100)]
Update NEWS

6 years agotests: check s390_pci_mmio_read and s390_pci_mmio_write decoders
Eugene Syromyatnikov [Sun, 14 Jan 2018 09:42:11 +0000 (10:42 +0100)]
tests: check s390_pci_mmio_read and s390_pci_mmio_write decoders

* tests/s390_pci_mmio_read_write.c: New file.
* tests/.gitignore: Add s390_pci_mmio_read_write.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (s390_pci_mmio_read_write): New test.

6 years agoIntroduce s390_pci_mmio_read, s390_pci_mmio_write system call decoders
Eugene Syromyatnikov [Sun, 14 Jan 2018 09:40:21 +0000 (10:40 +0100)]
Introduce s390_pci_mmio_read, s390_pci_mmio_write system call decoders

* linux/s390/syscallent.h ([352]): Change decoder to s390_pci_mmio_write.
([353]): Change decoder to s390_pci_mmio_read.
* linux/s390x/syscallent.h: Likewise.
* s390.c (SYS_FUNC(s390_pci_mmio_write), SYS_FUNC(s390_pci_mmio_read)):
New function.

6 years agotests: check s390_runtime_instr system call decoder
Eugene Syromyatnikov [Sun, 14 Jan 2018 08:39:05 +0000 (09:39 +0100)]
tests: check s390_runtime_instr system call decoder

* tests/s390_runtime_instr.c: New file.
* tests/.gitignore: Add s390_runtime_instr.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (s390_runtime_instr): New test.

6 years agoIntroduce s390_runtime_instr system call decoder
Eugene Syromyatnikov [Sun, 14 Jan 2018 08:37:43 +0000 (09:37 +0100)]
Introduce s390_runtime_instr system call decoder

* linux/s390/syscallent.h ([342]): Change decoder to s390_runtime_instr.
* linux/s390x/syscallent.h: Likewise.
* s390.c (SYS_FUNC(s390_runtime_instr)): New function.
* xlat/s390_runtime_instr_commands.in: New file.

6 years agotests: check s390_guarded_storage system call decoder
Eugene Syromyatnikov [Fri, 12 Jan 2018 17:31:34 +0000 (18:31 +0100)]
tests: check s390_guarded_storage system call decoder

* configure.ac (AC_CHECK_HEADERS): Add asm/guarded_storage.h.
* tests/s390_guarded_storage-v.c: New file.
* tests/s390_guarded_storage.c: Likewise.
* tests/.gitignore: Add s390_guarded_storage, s390_guarded_storage-v.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (s390_guarded_storage, s390_guarded_storage-v):
New tests.

6 years agoIntroduce s390_guarded_storage system call decoder
Eugene Syromyatnikov [Fri, 12 Jan 2018 16:25:38 +0000 (17:25 +0100)]
Introduce s390_guarded_storage system call decoder

* linux/s390/syscallent.h ([378]): Change decoder to s390_guarded_storage.
* linux/s390x/syscallent.h: Likewise.
* s390.c (struct guard_storage_control_block,
struct guard_storage_event_parameter_list): New structure type
definition.
(guard_storage_print_gsepl, guard_storage_print_gscb,
SYS_FUNC(s390_guarded_storage)): New function.
(DIV_ROUND_UP): New macro.
* xlat/s390_guarded_storage_commands.in: New file.

6 years agotests: check s390_sthyi system call decoder
Eugene Syromyatnikov [Thu, 18 Jan 2018 05:22:40 +0000 (06:22 +0100)]
tests: check s390_sthyi system call decoder

* configure.ac (AC_CHECK_FUNCS): Add iconv_open.
(AC_CHECK_HEADERS): Add iconv.h.
* tests/s390_sthyi-v.c: New file.
* tests/s390_sthyi.c: Likewise.
* tests/.gitignore: Add s390_sthyi, s390_sthyi-v.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (s390_sthyi, s390_sthyi): New tests.

6 years agoIntroduce s390_sthyi system call decoder
Eugene Syromyatnikov [Thu, 18 Jan 2018 05:21:45 +0000 (06:21 +0100)]
Introduce s390_sthyi system call decoder

* s390.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/s390/syscallent.h ([380]): Change decoder to s390_sthyi.
* linux/s390x/syscallent.h: Likewise.
* xlat/s390_sthyi_function_codes.in: New file.

6 years agoprint_fields.h: add macro to print hexadecimal array field
Eugene Syromyatnikov [Thu, 11 Jan 2018 21:47:11 +0000 (22:47 +0100)]
print_fields.h: add macro to print hexadecimal array field

* print_fields.h (PRINT_FIELD_HEX_ARRAY): New macro, prints target
array with QUOTE_FORCE_HEX.

6 years agoAdd print_quoted_string flag to generate comment
Eugene Syromyatnikov [Thu, 11 Jan 2018 21:46:23 +0000 (22:46 +0100)]
Add print_quoted_string flag to generate comment

Because there are never enough print_quoted_string flags.

* defs.h (QUOTE_EMIT_COMMENT): New quoting flag macro constant.
* util.c (string_quote): Emit " /* " in the beginning and " */" in the
end if QUOTE_EMIT_COMMENT is passed.
(print_quoted_string): Increase alloc_size by 7 if QUOTE_EMIT_COMMENT is
passed.

6 years agotests: make ioctl.test more flexible, use it for the rest of ioctl tests
Eugene Syromyatnikov [Thu, 25 Jan 2018 09:54:56 +0000 (10:54 +0100)]
tests: make ioctl.test more flexible, use it for the rest of ioctl tests

As the remaining non-generated ioctl tests differ from ioctl.test only
in strace options, and since gen_tests.sh can pass arguments to sourced
tests, replace the remaining non-generated ioctl tests with invocations
of ioctl.test with appropriate parameters.

* tests/ioctl.test: Pass script arguments to the strace invocation.
* tests/gen_tests.in (ioctl_dm): New entry, invoke ioctl.test with -s9.
(ioctl_dm-v): New entry, invoke ioctl.test with -v -s9.
(ioctl_kvm_run): New entry, invoke ioctl.test with -a36 -y.
(ioctl_loop-nv): New entry, invoke ioctl.test with -a22 -e verbose=none.
(ioctl_nsfs): New entry, invoke ioctl.test with -esignal=none.
(ioctl_sock_gifconf): New entry, invoke ioctl.test with -a28 -s1.
(ioctl_evdev-v, ioctl_loop-v, ioctl_rtc-v): Invoke ioctl.test
with -v option instead of ioctl-v.sh.
* tests/ioctl_dm-v.test: Remove.
* tests/ioctl_dm.test: Likewise.
* tests/ioctl_kvm_run.test: Likewise.
* tests/ioctl_loop-nv.test: Likewise.
* tests/ioctl_nsfs.test: Likewise.
* tests/ioctl_sock_gifconf.test: Likewise.
* tests/ioctl-v.sh: Likewise.
* tests/Makefile.am (DECODER_TESTS, EXTRA_DIST): Remove them.

6 years agotests/gen_tests.sh: enable passing arguments to sourced tests
Eugene Syromyatnikov [Thu, 25 Jan 2018 09:33:55 +0000 (10:33 +0100)]
tests/gen_tests.sh: enable passing arguments to sourced tests

* tests/gen_tests.sh: Read first argument separately, put it in $arg0,
and the rest of the arguments in $args.
(case "$arg0" in) <+*)>: Set command line to $args and source $arg0.

6 years agoxlat/gen.sh: add some rudimentary support for comments
Eugene Syromyatnikov [Wed, 13 Sep 2017 19:44:44 +0000 (21:44 +0200)]
xlat/gen.sh: add some rudimentary support for comments

* xlat/gen.sh: Trim parts of the string abbreviated in "/*" and "*/"

6 years agoconfigure.ac: sort architectures in lexicographical order
Eugene Syromyatnikov [Wed, 24 Jan 2018 13:29:55 +0000 (14:29 +0100)]
configure.ac: sort architectures in lexicographical order

* configure.ac (case "$host_cpu"): sort architectures in alphabetical
order.

6 years agoDrop non-functional CRIS architecture support
Dmitry V. Levin [Thu, 25 Jan 2018 01:55:08 +0000 (01:55 +0000)]
Drop non-functional CRIS architecture support

From the very first commit when CRIS architecture support was introduced
and up to this comment that ends the agony of this non-functional code,
this support was incomplete and could never be compiled.

* Makefile.am (EXTRA_DIST): Remove linux/crisv*.
* clone.c: Remove CRISV* checks.
* configure.ac ($host_cpu == cris*): Remove.
* linux/crisv10: Remove.
* linux/crisv32: Likewise.

Fixes: v4.5.18-77-gea0e6e8 ("CRIS support by Hinko Kocevar ...")
6 years agoUpdate futex test in accordance with kernel's v4.15-rc7-202-gfbe0e83
Eugene Syromyatnikov [Wed, 24 Jan 2018 14:55:50 +0000 (09:55 -0500)]
Update futex test in accordance with kernel's v4.15-rc7-202-gfbe0e83

* futex.c (VALP, VALP_PR, VAL2P, VAL2P_PR): New macro definitions.
(main): Allow EINVAL on *REQUEUE* checks with VAL/VAL2 with higher bit
being set, check that the existing behaviour preserved with VALP/VAL2P
where higher bit is unset.

6 years agotests/futex.c: improve error diagnostics
Eugene Syromyatnikov [Wed, 24 Jan 2018 14:54:32 +0000 (09:54 -0500)]
tests/futex.c: improve error diagnostics

* tests/futex.c (futex_error): Add func and line arguments, print them.
(CHECK_FUTEX_GENERIC): Pass __func__ and __LINE__ to futex_error.

6 years agoAdd syscall entry for ARM-specific get_tls syscall
Eugene Syromyatnikov [Tue, 23 Jan 2018 08:40:12 +0000 (09:40 +0100)]
Add syscall entry for ARM-specific get_tls syscall

* linux/arm/syscallent.h ([ARM_FIRST_SHUFFLED_SYSCALL+1+6]): New entry.
(ARM_LAST_SPECIAL_SYSCALL): Update to 6.
* NEWS: Mention it.

6 years agoFix syscall descriptions for ARM-specific system calls
Eugene Syromyatnikov [Tue, 23 Jan 2018 08:37:19 +0000 (09:37 +0100)]
Fix syscall descriptions for ARM-specific system calls

Based on an analysis of arm_syscall in arch/arm/kernel/traps.c.

* linux/arm/syscallent.h ([ARM_FIRST_SHUFFLED_SYSCALL+1+2]): Update
argument number, add TM flag.
([ARM_FIRST_SHUFFLED_SYSCALL+1+1], [ARM_FIRST_SHUFFLED_SYSCALL+1+3],
[ARM_FIRST_SHUFFLED_SYSCALL+1+4], [ARM_FIRST_SHUFFLED_SYSCALL+1+5]):
Update argument number.

6 years agotests: check riscv_flush_icache syscall decoder
Eugene Syromyatnikov [Mon, 22 Jan 2018 12:07:13 +0000 (13:07 +0100)]
tests: check riscv_flush_icache syscall decoder

* tests/riscv_flush_icache.c: New file.
* tests/.gitignore: Add riscv_flush_icache.
* tests/gen_tests.in: Likewise.
* tests/pure_executables.list: Likewise.

6 years agoImplement decoding of riscv_flush_icache syscall
Eugene Syromyatnikov [Mon, 22 Jan 2018 09:23:07 +0000 (10:23 +0100)]
Implement decoding of riscv_flush_icache syscall

* linux/riscv/syscallent.h ([259]): Add riscv_flush_icache entry.
* riscv.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/riscv_flush_icache_flags.in: New file.
* NEWS: Mention it.

6 years agoWorkaround stray PTRACE_EVENT_EXEC
Eugene Syromyatnikov [Mon, 22 Jan 2018 02:53:43 +0000 (03:53 +0100)]
Workaround stray PTRACE_EVENT_EXEC

We (apparently) had a long-standing test failure inside strace-ff.test
with the symptom that it misses exit_group call.  As it turned out, it
was PTRACE_EVENT_EXEC followed by execve syscall exiting stop.  That
behaviour indeed screwed all the syscall state tracking for the tracee.
Let's try to patch it up by calling trace_syscall when we receive
PTRACE_EVENT_EXEC outside syscall.

* defs.h (TCB_RECOVERING): New tcb flag.
* strace.c (dispatch_event) <case TE_STOP_BEFORE_EXECVE>: Invoke
trace_syscall with TCB_RECOVERING flag being set for the current_tcp
if the tracee is not on exiting syscall.
* syscall.c (get_scno): Set QUAL_RAW if we are recovering.
(tamper_with_syscall_entering): Do not perform actual tampering during
recovery as it's already too late.
* NEWS: Mention it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: robustify set_ptracer_any
Dmitry V. Levin [Wed, 24 Jan 2018 01:56:15 +0000 (01:56 +0000)]
tests: robustify set_ptracer_any

* tests/set_ptracer_any.c (main) [HAVE_PRCTL]: Provide fallback
definitions for PR_SET_PTRACER and PR_SET_PTRACER_ANY constants,
set all unused prctl arguments to 0.

6 years agoia64: do not bail out in get_syscall_args if umove fails with EPERM
Dmitry V. Levin [Wed, 24 Jan 2018 01:56:15 +0000 (01:56 +0000)]
ia64: do not bail out in get_syscall_args if umove fails with EPERM

If the kernel contains commit 84d77d3f06e7e8dea057d10e8ec77ad71f721be3,
both PTRACE_PEEKDATA and process_vm_readv become unavailable when the
process dumpable flag is cleared, on ia64 this results to all syscall
arguments being unavailable.

Recognize this situation and do not treat it as get_syscall_args error
because the latter leaves the tracee in a ptrace stop.

This condition used to be triggered by prctl-dumpable test that caused
strace to hang indefinitely.

* linux/ia64/get_syscall_args.c (get_syscall_args): Do not bail out
if umove fails.
* tests/prctl-dumpable.c [__ia64__]: Skip the test.

6 years agostrace.c: reset printing_tcp on print_event_exit
Eugene Syromyatnikov [Mon, 22 Jan 2018 00:55:05 +0000 (01:55 +0100)]
strace.c: reset printing_tcp on print_event_exit

print_event_exit should have printing_tcp setup analogous to printleader and
syscall_exit_trace before printing its part, otherwise it spuriously resets
curcol in line_ended for the stale printing_tcp if followfork == 2.

* strace.c (print_event_exit): Set printing_tcp to tcp before printing
exiting event line and calling line_ended.

6 years agotests: check path tracing of old select syscall
Dmitry V. Levin [Tue, 23 Jan 2018 01:06:09 +0000 (01:06 +0000)]
tests: check path tracing of old select syscall

* tests/xselect.c [xselect] (xselect): Turn into prototype.
* tests/oldselect-P.c: New file.
* tests/oldselect-efault-P.c: Likewise.
* tests/oldselect-efault.c: Likewise.
* tests/oldselect.c: Use xselect.c
* tests/pure_executables.list: Add oldselect-efault.
* tests/gen_tests.in (oldselect, oldselect-P, oldselect-efault,
oldselect-efault-P): New entries.
* tests/oldselect.expected: Remove.
* tests/oldselect.test: Remove.
* tests/Makefile.am (check_PROGRAMS): Add oldselect-P
and oldselect-efault-P.
(DECODER_TESTS): Remove oldselect.test.
(EXTRA_DIST): Remove oldselect.expected.
* tests/.gitignore: Add oldselect-P, oldselect-efault,
and oldselect-efault-P.

6 years agotests: check path tracing of select/_newselect syscalls
Dmitry V. Levin [Tue, 23 Jan 2018 01:06:09 +0000 (01:06 +0000)]
tests: check path tracing of select/_newselect syscalls

* tests/xselect.c (main) [PATH_TRACING_FD]: Skip if /proc/self/fd/
is not available.  Add test calls that use PATH_TRACING_FD.
(main): Conditionalize expected output for those calls
that do not use PATH_TRACING_FD with [!PATH_TRACING_FD].
* tests/_newselect-P.c: New file.
* tests/select-P.c: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add _newselect-P and select-P.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (_newselect-P, select-P): New entries.

6 years agotests: extend the check of select/_newselect syscalls decoding
Dmitry V. Levin [Tue, 23 Jan 2018 01:06:09 +0000 (01:06 +0000)]
tests: extend the check of select/_newselect syscalls decoding

* tests/xselect.c: Rewrite for better coverage.

6 years agotests: redirect stdin to /dev/null
Dmitry V. Levin [Tue, 23 Jan 2018 23:17:02 +0000 (23:17 +0000)]
tests: redirect stdin to /dev/null

Ensure that stdin descriptor is not available for output
by reopening it to input from /dev/null.

* tests/run.sh: Redirect test's stdin to /dev/null.

6 years agotests: add file:line to perror_msg_and_fail/error_msg_and_fail output
Dmitry V. Levin [Tue, 23 Jan 2018 21:17:05 +0000 (21:17 +0000)]
tests: add file:line to perror_msg_and_fail/error_msg_and_fail output

* tests/tests.h [!perror_msg_and_fail] (perror_msg_and_fail): New macro
wrapper around the homonymous function.
[!error_msg_and_fail] (error_msg_and_fail): Likewise.
* tests/error_msg.c (perror_msg_and_fail, error_msg_and_fail): New
macros defined to themselves.

6 years agoRework decoding and pathtrace of old select syscall
Dmitry V. Levin [Mon, 22 Jan 2018 00:31:07 +0000 (00:31 +0000)]
Rework decoding and pathtrace of old select syscall

* linux/arch_defs_.h [!HAVE_ARCH_OLD_SELECT] (HAVE_ARCH_OLD_SELECT): New
macro.
* linux/aarch64/arch_defs_.h (HAVE_ARCH_OLD_SELECT): Likewise.
* linux/arm/arch_defs_.h: Likewise.
* linux/bfin/arch_defs_.h: Likewise.
* linux/i386/arch_defs_.h: Likewise.
* linux/m68k/arch_defs_.h: Likewise.
* linux/microblaze/arch_defs_.h: Likewise.
* linux/powerpc64/arch_defs_.h: Likewise.
* linux/sh/arch_defs_.h: Likewise.
* linux/x32/arch_defs_.h: Likewise.
* linux/x86_64/arch_defs_.h: Likewise.
* linux/powerpc/arch_defs_.h: New file.
* Makefile.am (EXTRA_DIST): Add it.
* desc.c (SYS_FUNC(oldselect)): Rewrite using
fetch_indirect_syscall_args, move under [HAVE_ARCH_OLD_SELECT].
* pathtrace.c (match_xselect_args): New function.
(pathtrace_match_set): Use it.

6 years agoTransform fetch_old_mmap_args into fetch_indirect_syscall_args
Dmitry V. Levin [Sun, 21 Jan 2018 23:23:31 +0000 (23:23 +0000)]
Transform fetch_old_mmap_args into fetch_indirect_syscall_args

As there are more than one old style syscall that take their arguments
via array, generalize fetch_old_mmap_args into a function that could
fetch variable number of arguments.

* mem.c (fetch_old_mmap_args): Transform into ...
* fetch_indirect_syscall_args.c: ... fetch_indirect_syscall_args
in this new file.
* Makefile.am (libstrace_a_SOURCES): Add it.
* defs.h [HAVE_ARCH_OLD_MMAP] (fetch_old_mmap_args): Remove.
(fetch_indirect_syscall_args): New prototype.
* pathtrace.c (pathtrace_match_set) [HAVE_ARCH_OLD_MMAP]: Use
fetch_indirect_syscall_args instead of fetch_old_mmap_args.

6 years agosignal.c: remove excess semicolon after the end of the function
Eugene Syromyatnikov [Mon, 22 Jan 2018 12:31:25 +0000 (13:31 +0100)]
signal.c: remove excess semicolon after the end of the function

* signal.c (rt_sigtimedwait): Remove semicolon after the function body.

6 years agoUse char * for pointer arithmetics
Eugene Syromyatnikov [Mon, 22 Jan 2018 12:24:40 +0000 (13:24 +0100)]
Use char * for pointer arithmetics

* netlink_inet_diag.c (decode_inet_diag_req_compat,
decode_inet_diag_req_v2, decode_inet_diag_msg): Cast to char *
instead of void *.
* netlink_netlink_diag.c (decode_netlink_diag_req,
decode_netlink_diag_msg): Likewise.
* netlink_packet_diag.c (decode_packet_diag_req,
decode_packet_diag_msg): Likewise.
* netlink_unix_diag.c (decode_unix_diag_req, decode_unix_diag_msg):
Likewise.
* rtnl_addr.c (decode_ifaddrmsg): Likewise.
* rtnl_addrlabel.c (decode_ifaddrlblmsg): Likewise.
* rtnl_dcb.c (decode_dcbmsg): Likewise.
* rtnl_link.c (decode_ifinfomsg): Likewise.
* rtnl_mdb.c (decode_br_port_msg): Likewise.
* rtnl_neigh.c (decode_ndmsg): Likewise.
* rtnl_route.c (decode_rtmsg): Likewise.
* rtnl_rule.c (decode_fib_rule_hdr): Likewise.
* rtnl_tc.c (decode_tcmsg): Likewise.

6 years agonetlink_inet_diag.c: remove unnecessary return
Eugene Syromyatnikov [Mon, 22 Jan 2018 12:22:17 +0000 (13:22 +0100)]
netlink_inet_diag.c: remove unnecessary return

decode_inet_diag_req, as well as the functions it calls, returns void.

* netlink_inet_diag.c (decode_inet_diag_req): Do not return anything.

6 years agoMove decoder of getpagesize syscall to libstrace
Dmitry V. Levin [Sun, 21 Jan 2018 20:19:53 +0000 (20:19 +0000)]
Move decoder of getpagesize syscall to libstrace

As only five architectures have getpagesize syscall, moving the decoder
to libstrace allows to get rid of getpagesize related ifdefs and check
build of getpagesize decoder on other architectures.

* mem.c (SYS_FUNC(getpagesize)): Move ...
* getpagesize.c: ... to this new file.
* Makefile.am (libstrace_a_SOURCES): Add it.

6 years agompers: implement gawk 3 support
Eugene Syromyatnikov [Thu, 18 Jan 2018 07:49:57 +0000 (08:49 +0100)]
mpers: implement gawk 3 support

Some old systems that still make some sense to be supported have only
gawk 3, so let's support them for now.

In order to achieve that, multiple changes have been implemented:
 - Multidimensional arrays are replaced with single-dimensional ones.
   In most places it's a "][" -> ", " replacement, as awk allows some
   kind of emulation of multidimensional arrays that way, but in several
   occasions (specifically for storing name and special fields) we have
   to iterate over them later, so we store that information in
   additional arrays in order to get the keys.
 - "switch" statements are replaced with sets of "if ... else if ...
   else" statements.  This change is trivial, except we've added
   a temporary variable in what_is order to store expression value, for
   readability purposes.
 - No support for array iteration ordering.  This one is most ugly of
   them all.  Luckily, not that ugly, we've just had to process index a
   bit in order to make it lexicographically sortable and add two
   temporary arrays containing sorted indices in order to sort over them
   instead of those two arrays that we've added in order to work around
   lack of multidimensional array support.

* mpers.awk (compare_indices): Remove unused function.
(array_get, update_upper_bound, /^DW_AT_data_member_location/,
/^DW_AT_byte_size/, /^DW_AT_encoding/): Replace multidimensional array
access with comma-concatenated index.
(norm_idx): New function.
(array_seq): Replace multidimensional array access with
comma-concatenated index.  Use comma-concatenated pair of (array_idx,
"seq") in order to check presence of the item in an array.
(what_is): Add enc and i local variables.  Store the value of
array[what_idx, "encoding"] in it.  Replace "switch" statements with
sets of "if ... else if ... else" statements.  Replace multidimensional
array access with comma-concatenated index. Use for (... ; ...; ...)
iteration over aparents_keys instead of iteration over array.
(/^<[[:xdigit:]]+>/): Store idx as norm_idx(matches[2]).  Replace
multidimensional array access with comma-concatenated index.  Store an
additional flag in array_names array.
(/^DW_AT_name/): Replace multidimensional array access with
comma-concatenated index.  Add a flag to array_names for that idx.
(/^DW_AT_type/): Do not capture "0x" as a part of a group, normalise
the captured group.  Replace multidimensional array access with
comma-concatenated index.
(/^Abbrev Number:[^(]+\(DW_TAG_/): Replace multidimensional array access
with comma-concatenated index.  Store additional flags in
array_special and array_parents arrays.
(END): Remove PROCINFO["sorted_in"] setup.  Sort array_parents.  Replace
multidimensional array access with comma-concatenated index.  Iterate
over array_special to go over all the items that have "special" field.
Iterate over array_names to go over all items that have "name" field.
* NEWS: Mention it.

6 years agodm: add support for event_nr in DM_LIST_DEVICES result
Eugene Syromyatnikov [Sun, 17 Sep 2017 02:58:49 +0000 (04:58 +0200)]
dm: add support for event_nr in DM_LIST_DEVICES result

Commit v4.13-rc1~137^2~13 (and a follow-up fix v4.14-rc4~20^2~3
that changed alignment) introduced an additional hidden field
in the structure returned by DM_LIST_DEVICES ioctl command
that contains event_nr information.

Unfortunately, we can't test it for now, but looks like it kinda works:

  # ./strace -v -eioctl -y dmsetup ls
  ioctl(3</dev/mapper/control>, DM_VERSION, {version=4.0.0,
  data_size=16384, flags=DM_EXISTS_FLAG} => {version=4.37.0,
  data_size=16384, flags=DM_EXISTS_FLAG}) = 0
  ioctl(3</dev/mapper/control>, DM_LIST_DEVICES, {version=4.0.0,
  data_size=16384, data_start=312, flags=DM_EXISTS_FLAG} =>
  {version=4.37.0, data_size=408, data_start=312, flags=DM_EXISTS_FLAG,
  {dev=makedev(253, 1), name="fedoratesting--30-swap", event_nr=0},
  {dev=makedev(253, 0), name="fedoratesting--30-root"}}) = 0
  fedoratesting--30-swap (253:1)
  fedoratesting--30-root (253:0)

* dm.c (dm_decode_dm_name_list): Obtain the amount of bytes copied
during printing device name, print event number if there's a suitable
gap present and the DM version is high enough.
* NEWS: Mention it.

6 years agoMove definition of personality macros to arch_defs_.h
Eugene Syromyatnikov [Sat, 20 Jan 2018 03:51:29 +0000 (04:51 +0100)]
Move definition of personality macros to arch_defs_.h

* supported_personalities.h: Remove.
* defs.h: Do not include it.
* linux/arch_defs_.h [!DEFAULT_PERSONALITY] (DEFAULT_PERSONALITY): New
macro.
[!SUPPORTED_PERSONALITIES] (SUPPORTED_PERSONALITIES): Likewise.
* linux/aarch64/arch_defs_.h (SUPPORTED_PERSONALITIES): New macro.
* linux/riscv/arch_defs_.h: Likewise.
* linux/s390x/arch_defs_.h: Likewise.
* linux/sparc64/arch_defs_.h: Likewise.
* linux/x32/arch_defs_.h: Likewise.
* linux/x86_64/arch_defs_.h: Likewise.
* linux/powerpc64/arch_defs_.h: New file.
* linux/tile/arch_defs_.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
(strace_SOURCES): Remove supported_personalities.h.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoIntroduce HAVE_ARCH_SA_RESTORER
Eugene Syromyatnikov [Sat, 20 Jan 2018 03:25:26 +0000 (04:25 +0100)]
Introduce HAVE_ARCH_SA_RESTORER

In order to simplify HAVE_SA_RESTORER logic a bit.

* linux/ia64/arch_defs_.h (HAVE_ARCH_SA_RESTORER): New macro.
* linux/m68k/arch_defs_.h: Likewise.
* linux/sparc/arch_defs_.h: Likewise.
* linux/sparc64/arch_defs_.h: Likewise.
* linux/hppa/arch_defs_.h: New file.
* Makefile.am (EXTRA_DIST): Add it.
* signal.c [HAVE_ARCH_SA_RESTORER]: Define HAVE_SA_RESTORER to it.
[!HAVE_ARCH_SA_RESTORER && SA_RESTORER]: Define HAVE_SA_RESTORER to 1.
[!HAVE_ARCH_SA_RESTORER && !SA_RESTORER]: Define HAVE_SA_RESTORER to 0.

6 years agoReplace NEED_UID16_PARSERS with HAVE_ARCH_UID16_SYSCALLS
Dmitry V. Levin [Sat, 20 Jan 2018 00:02:57 +0000 (00:02 +0000)]
Replace NEED_UID16_PARSERS with HAVE_ARCH_UID16_SYSCALLS

* linux/arch_defs_.h [!HAVE_ARCH_UID16_SYSCALLS]
(HAVE_ARCH_UID16_SYSCALLS): New macro.
* linux/aarch64/arch_defs_.h (HAVE_ARCH_UID16_SYSCALLS): New macro.
* linux/arm/arch_defs_.h: Likewise.
* linux/i386/arch_defs_.h: Likewise.
* linux/ia64/arch_defs_.h: Likewise.
* linux/m68k/arch_defs_.h: Likewise.
* linux/s390/arch_defs_.h: Likewise.
* linux/s390x/arch_defs_.h: Likewise.
* linux/sh/arch_defs_.h: Likewise.
* linux/sparc/arch_defs_.h: Likewise.
* linux/sparc64/arch_defs_.h: Likewise.
* linux/syscall.h: Likewise.
* linux/x32/arch_defs_.h: Likewise.
* linux/x86_64/arch_defs_.h: Likewise.
* linux/bfin/arch_defs_.h: New file.
* linux/microblaze/arch_defs_.h: Likewise.
* linux/riscv/arch_defs_.h: Likewise.
* linux/sh64/arch_defs_.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* defs.h (NEED_UID16_PARSERS): Remove.
* linux/syscall.h: Check for HAVE_ARCH_UID16_SYSCALLS instead of
NEED_UID16_PARSERS.
* uid.c: Likewise.

6 years agoReplace HAVE_GETRVAL2 with HAVE_ARCH_GETRVAL2
Dmitry V. Levin [Sat, 20 Jan 2018 00:02:57 +0000 (00:02 +0000)]
Replace HAVE_GETRVAL2 with HAVE_ARCH_GETRVAL2

* linux/arch_defs_.h [!HAVE_ARCH_GETRVAL2] (HAVE_ARCH_GETRVAL2): New
macro.
* linux/alpha/arch_defs_.h: New file.
* linux/ia64/arch_defs_.h: Likewise.
* linux/mips/arch_defs_.h: Likewise.
* linux/sh/arch_defs_.h: Likewise.
* linux/sparc/arch_defs_.h: Likewise.
* linux/sparc64/arch_defs_.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* defs.h (HAVE_GETRVAL2): Remove.
(getrval2): Check for HAVE_ARCH_GETRVAL2 instead of arch checks.
* net.c (SYS_FUNC(pipe)): Check for HAVE_ARCH_GETRVAL2 instead of
HAVE_GETRVAL2.
* syscall.c: Likewise.

6 years agoUse #if idiom instead of #ifdef for HAVE_ARCH_* macros.
Dmitry V. Levin [Sun, 21 Jan 2018 01:46:04 +0000 (01:46 +0000)]
Use #if idiom instead of #ifdef for HAVE_ARCH_* macros.

* linux/arch_defs_.h [!HAVE_ARCH_OLD_MMAP] (HAVE_ARCH_OLD_MMAP): New
macro.
[!HAVE_ARCH_OLD_MMAP_PGOFF] (HAVE_ARCH_OLD_MMAP_PGOFF): Likewise.
* defs.h: Use #if instead of #ifdef to check HAVE_ARCH_OLD_MMAP.
* mem.c: Use #if instead of #ifdef to check HAVE_ARCH_OLD_MMAP
and HAVE_ARCH_OLD_MMAP_PGOFF
* pathtrace.c: Likewise.

6 years agoRename arch-specific arch_defs.h files to arch_defs_.h
Dmitry V. Levin [Sun, 21 Jan 2018 01:46:04 +0000 (01:46 +0000)]
Rename arch-specific arch_defs.h files to arch_defs_.h

Introduce a new arch_defs.h header that includes the corresponding
arch-specific arch_defs_.h file followed by generic arch_defs_.h file.

* linux/arch_defs.h: Rename to linux/arch_defs_.h.
* linux/aarch64/arch_defs.h: Rename to linux/aarch64/arch_defs_.h.
* linux/arm/arch_defs.h: Rename to linux/arm/arch_defs_.h.
* linux/i386/arch_defs.h: Rename to linux/i386/arch_defs_.h.
* linux/m68k/arch_defs.h: Rename to linux/m68k/arch_defs_.h.
* linux/s390/arch_defs.h: Rename to linux/s390/arch_defs_.h.
* linux/s390x/arch_defs.h: Rename to linux/s390x/arch_defs_.h.
* linux/x32/arch_defs.h: Rename to linux/x32/arch_defs_.h.
* linux/x86_64/arch_defs.h: Rename to linux/x86_64/arch_defs_.h.
* arch_defs.h: New file.
* Makefile.am (strace_SOURCES): Add it.
(EXTRA_DIST): Rename linux/*/arch_defs.h to linux/*/arch_defs_.h.

6 years agoFix ANY_WORDSIZE_LESS_THAN_KERNEL_LONG definition
Dmitry V. Levin [Fri, 19 Jan 2018 23:02:17 +0000 (23:02 +0000)]
Fix ANY_WORDSIZE_LESS_THAN_KERNEL_LONG definition

* defs.h (ANY_WORDSIZE_LESS_THAN_KERNEL_LONG): Rewrite without undefined
behaviour.

Fixes: f916793 ("Introduce ANY_WORDSIZE_LESS_THAN_KERNEL_LONG macro")
6 years agoutil: return string size in printstr
Eugene Syromyatnikov [Sun, 17 Sep 2017 02:58:07 +0000 (04:58 +0200)]
util: return string size in printstr

As umovestr now returns something useful, let's propagate it further.

* defs.h (printstr_ex, printpathn, printpath): Change return type from
void to int.
(printstrn, printstr): Change return type from void to int, return
printstr_ex result.
* util.c (printpathn): Return -1 on NULL addr, nul_seen (exit code of
umovestr) on success.
(printpath): Return printpathn result.
(printstr_ex): Return -1 on NULL addr, umoven/umovestr result otherwise.

6 years agoucopy: return string size in umovestr
Eugene Syromyatnikov [Sun, 17 Sep 2017 02:57:37 +0000 (04:57 +0200)]
ucopy: return string size in umovestr

We return the size that includes \0 in order to preserve existing
behaviour (return 0 when \0 haven't been seen, return positive number
when it has been seen).

* ucopy.c (umovestr_peekdata, umovestr): Return string length
including \0 instead of 1 when \0 is found.

6 years agompers.awk: avoid redefinition of mpers_ptr_t
Dmitry V. Levin [Fri, 19 Jan 2018 17:07:04 +0000 (17:07 +0000)]
mpers.awk: avoid redefinition of mpers_ptr_t

Older versions of gcc like those found in RHEL6 fail with the following
diagnostics:

  In file included from block.c:32:
  ./mpers-m32/struct_blk_user_trace_setup.h:2: error: redefinition of typedef ‘mpers_ptr_t’
  mpers_type.h:44: note: previous declaration of ‘mpers_ptr_t’ was here

* mpers.awk (END): Add #ifndef guard to mpers_ptr_t typedef.
* mpers_test.sh: Update expected output.

6 years agoAdd support for --enable-mpers=m32|mx32
Eugene Syromyatnikov [Fri, 19 Jan 2018 02:21:48 +0000 (03:21 +0100)]
Add support for --enable-mpers=m32|mx32

* configure.ac (AC_ARG_ENABLE([mpers])): Allow m32 and mx32 values
for --enable-mpers option.
* m4/mpers.m4 (st_MPERS): Check for personality support if personality
name is provided as an option.  Fail if the requested personality
support is not available.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: improve setugid error diagnostics a bit
Eugene Syromyatnikov [Fri, 19 Jan 2018 02:24:03 +0000 (03:24 +0100)]
tests: improve setugid error diagnostics a bit

* tests/setugid.c (main): Print unexpected code returned by syscall.

6 years agov4l2: do not mpersify struct v4l2_create unless it is used by other code
Dmitry V. Levin [Fri, 19 Jan 2018 17:50:09 +0000 (17:50 +0000)]
v4l2: do not mpersify struct v4l2_create unless it is used by other code

This fixes build with mpers support on older systems that lack
definition of struct v4l2_create.

* v4l2.c: Wrap references to struct v4l2_create with
[VIDIOC_CREATE_BUFS].

6 years agobtrfs: use uint32_t instead of __u32
Dmitry V. Levin [Thu, 18 Jan 2018 17:44:56 +0000 (17:44 +0000)]
btrfs: use uint32_t instead of __u32

* btrfs.c (btrfs_ioctl) [!HAVE_STRUCT_BTRFS_IOCTL_FS_INFO_ARGS_NODESIZE]:
Replace __u32 with uint32_t.  Remove useless cast.

6 years agostrace.1.in: clarify mpers flags in strace -V output
Eugene Syromyatnikov [Thu, 18 Jan 2018 12:16:35 +0000 (13:16 +0100)]
strace.1.in: clarify mpers flags in strace -V output

The previous description was a bit dated.

* strace.1.in (.SH "MULTIPLE PERSONALITY SUPPORT"): Remove "no-m32" and
"no-mx32", describe the situation when some of mpers flags are not
present in strace -V output.

6 years agoAdd compat support for s390x
Eugene Syromyatnikov [Wed, 10 Jan 2018 20:20:06 +0000 (20:20 +0000)]
Add compat support for s390x

By very popular demand.

While we are here, let's refactor the condition for old_mmap_pgoff into
an arch-specific one, as it is used more than in one place.

* NEWS: Mention this.
* strace.1.in (.SH "MULTIPLE PERSONALITY SUPPORT"): Likewise.
* configure.ac (case "$host_cpu" in) <s390x>: Set arch_m32 to s390, set
cc_flags_m32 to -m31.
(st_MPERS([m32])): Add s390x.
* defs.h [S390X]: Define NEED_UID16_PARSERS.
* linux/s390/arch_sigreturn.c [!S390_FRAME_PTR] (S390_FRAME_PTR): New
macro, define to s390_frame_ptr.
[!SIGNAL_FRAMESIZE] (SIGNAL_FRAMESIZE): New macro, define to
__SIGNAL_FRAMESIZE.
[!PTR_TYPE] (PTR_TYPE): New macro, define to unsigned long.
(arch_sigreturn): Use S390_FRAME_PTR, SIGNAL_FRAMESIZE, and PTR_TYPE
instead of s390_frame_ptr, __SIGNAL_FRAMESIZE, and pointer-sized type,
respectively.
* linux/s390/get_error.c [!ARCH_REGSET] (ARCH_REGSET): New macro, define
* to s390_regset.
(get_error): Use it instead of s390_regset.
* linux/s390/get_scno.c (arch_get_scno): Likewise.
* linux/s390/get_syscall_args.c (get_syscall_args): Likewise.
* linux/s390/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/s390/set_scno.c (arch_set_scno): Likewise.
* linux/s390x/arch_regs.c (psw_compat_t, s390_compat_regs,
s390x_regs_union, s390_frame_ptr, s390x_frame_ptr, s390x_io): New
variables.
(s390_regset, s390x_regset, ARCH_REGS_FOR_GETREGSET,
ARCH_IOVEC_FOR_GETREGSET, ARCH_PC_REG, ARCH_PERSONALITY_0_IOV_SIZE,
ARCH_PERSONALITY_1_IOV_SIZE): New macros.
* linux/s390x/arch_regs.h (s390_frame_ptr, s390x_frame_ptr): New
prototypes.
* linux/s390x/arch_rt_sigframe.c: Conditionalize on tcp->currpers.
* linux/s390x/arch_sigreturn.c: Likewise.
* linux/s390x/get_error.c: Likewise.
* linux/s390x/get_scno.c: Likewise.
* linux/s390x/get_syscall_args.c: Likewise.
* linux/s390x/set_error.c: Likewise.
* linux/s390x/set_scno.c: Likewise.
* linux/s390x/errnoent1.h: New file.
* linux/s390x/ioctls_arch1.h: Likewise.
* linux/s390x/ioctls_inc1.h: Likewise.
* linux/s390x/signalent1.h: Likewise.
* linux/s390x/syscallent1.h: Likewise.
* Makefile.am (EXTRA_DIST): Add new files added to linux/s390x.
* supported_personalities.h [S390X] (SUPPORTED_PERSONALITIES): Define
to 2.
* tests/strace-V.test: Add s390 to the list of architectures that have
m32 personality.
* linux/s390/arch_defs.h (HAVE_ARCH_OLD_MMAP_PGOFF): New macro.
* linux/s390x/arch_defs.h: Likewise.
* mem.c: Replace #ifdef S390 with #ifdef HAVE_ARCH_OLD_MMAP_PGOFF.
* pathtrace.c: Likewise.

6 years agoUpdate NEWS
Eugene Syromyatnikov [Thu, 18 Jan 2018 00:09:22 +0000 (01:09 +0100)]
Update NEWS

6 years agotests: check path tracing of ppoll syscall
Dmitry V. Levin [Wed, 17 Jan 2018 21:31:07 +0000 (21:31 +0000)]
tests: check path tracing of ppoll syscall

* tests/ppoll.c (main) [PATH_TRACING_FD]: Skip if /proc/self/fd/
is not available.  Add a test call that use PATH_TRACING_FD.
(main): Conditionalize expected output for those calls
that do not use PATH_TRACING_FD with [!PATH_TRACING_FD].
* tests/ppoll-P.c: New file.
* tests/pure_executables.list: Add ppoll-P.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (ppoll-P): New entry.

6 years agotests: check path tracing of poll syscall
Dmitry V. Levin [Wed, 17 Jan 2018 21:31:07 +0000 (21:31 +0000)]
tests: check path tracing of poll syscall

* tests/poll.c (main) [PATH_TRACING_FD]: Skip if /proc/self/fd/
is not available.  Add tests calls that use PATH_TRACING_FD.
(main): Conditionalize expected output for those calls
that do not use PATH_TRACING_FD with [!PATH_TRACING_FD].
* tests/poll-P.c: New file.
* tests/pure_executables.list: Add poll-P.
* tests/.gitignore: Likewise.
* tests/poll-P.test: New test.
* tests/Makefile.am (DECODER_TESTS): Add poll-P.test.

6 years agotests: enable old_mmap-P.test on s390x
Eugene Syromyatnikov [Wed, 17 Jan 2018 03:53:36 +0000 (04:53 +0100)]
tests: enable old_mmap-P.test on s390x

As s390x is the only 64-bit architecture that has old_mmap,
the test needs some adjustments there.

* tests/old_mmap.c: Update condition.
(main): Change int types to long, extend numerals to 64 bit, change
printing format qualifiers to corresponding long types.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: check path tracing of old mmap syscall
Eugene Syromyatnikov [Wed, 17 Jan 2018 01:39:21 +0000 (02:39 +0100)]
tests: check path tracing of old mmap syscall

* tests/old_mmap.c [!TEST_FD]: Define TEST_FD.
(main) <args1_c>: Replace 5th argument with TEST_FD.
(main): Wrap the output for the calls that do not use TEST_FD
with #ifndef PATH_TRACING.
* tests/old_mmap-P.c: New file.
* tests/pure_executables.list: Add old_mmap-P.
* tests/.gitignore: Likewise.
* tests/gen_tests.in: Add old_mmap-P test.

6 years agoFix pathtrace for old_mmap/old_mmap_pgoff
Eugene Syromyatnikov [Wed, 17 Jan 2018 01:38:55 +0000 (02:38 +0100)]
Fix pathtrace for old_mmap/old_mmap_pgoff

As these system calls have only one argument that points to the
location in memory containing actual arguments, current path tracing
implementation is incorrect.  In order to fix this, let's use recently
introduced fetch_old_mmap_args in order to get actual arguments suitable
for path matching.

* pathtrace.c [HAVE_ARCH_OLD_MMAP] <case SEN_old_mmap,
case SEN_old_mmap_pgoff>: Retrieve actual old_mmap arguments with
fetch_old_mmap_args, pass the value from the retrieved args if it's
available.

6 years agoTest non-verbose old_mmap output
Eugene Syromyatnikov [Wed, 17 Jan 2018 01:19:36 +0000 (02:19 +0100)]
Test non-verbose old_mmap output

* tests/old_mmap-v-none.c: New file.  Include old_mmap.c.
* tests/pure_executables.list: Add old_mmap-v-none.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (old_mmap-v-none): New entry.

6 years agomem.c: use runtime check in fetch_old_mmap_args
Eugene Syromyatnikov [Wed, 17 Jan 2018 02:29:17 +0000 (03:29 +0100)]
mem.c: use runtime check in fetch_old_mmap_args

This makes code a bit cleaner and makes it compatible with the upcoming
s390x compat support.

* mem.c [HAVE_ARCH_OLD_MMAP] (fetch_old_mmap_args): Replace
ANY_WORDSIZE_LESS_THAN_KERNEL_LONG check with current_wordsize == 4
check.

6 years agomem.c: introduce fetch_old_mmap_args
Eugene Syromyatnikov [Wed, 17 Jan 2018 01:18:45 +0000 (02:18 +0100)]
mem.c: introduce fetch_old_mmap_args

Move common old_mmap/old_mmap_pgoff argument fetching code into a
separate function.

As it is, it also fixes the case of non-verbose printing of old_mmap
arguments (see the new test in the next commit).  Also, it is a
preparation for the fix of path tracing for these syscalls.

* defs.h [HAVE_ARCH_OLD_MMAP] (fetch_old_mmap_args): New prototype.
* mem.c [HAVE_ARCH_OLD_MMAP] (fetch_old_mmap_args): New function.
[HAVE_ARCH_OLD_MMAP] (old_mmap, old_mmap_pgoff): Use it.

Fixes: 3db07f11 "Fix old_mmap output when mmap arguments are unfetchable"
Suggested-by: Dmitry V. Levin <ldv@altlinux.org>