Commit Graph

6337 Commits

Author SHA1 Message Date
Eugene Syromyatnikov
54038a6898 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
2018-02-07 22:03:48 +00:00
Eugene Syromyatnikov
1dd94856d3 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.
2018-02-07 22:03:48 +00:00
Eugene Syromyatnikov
cf7924dc5e README.md: add information about git repository location
* README.md: Mention URLs for SourceForge, GitHub, and GitLab
repositories.
2018-02-07 22:02:53 +00:00
85bd0dcea1 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.
2018-02-07 12:32:57 +00:00
11d1c182ba 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>
2018-02-06 23:46:18 +00:00
0ec9716124 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.
2018-02-06 08:45:32 +00:00
6c76cbe645 xlat: update IPV6_* constants
* xlat/sockipv6options.in: Add IPV6_FREEBIND introduced by linux kernel
commit v4.15-rc1~84^2~601.
* NEWS: Mention this.
2018-02-06 08:45:32 +00:00
444a93d0f0 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.
2018-02-06 08:45:32 +00:00
Eugene Syromyatnikov
71124c49ee 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.
2018-02-06 08:45:32 +00:00
Eugene Syromyatnikov
1f77138867 Makefile.am: minor EXTRA_DIST formatting changes 2018-02-06 02:56:14 +01:00
Eugene Syromyatnikov
eae4643b0f 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.
2018-02-06 02:56:14 +01:00
69ae3ae39c strace.1: fix wording about setuid installation
* strace.1.in (SETUID INSTALLATION): Fix wording.

Closes: https://github.com/strace/strace/issues/24
2018-01-29 22:47:48 +00:00
Gleb Fotengauer-Malinovskiy
b62b2dca1d 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.
2018-01-29 13:17:45 +00:00
Eugene Syromyatnikov
a7457d88e2 Update NEWS 2018-01-29 14:12:50 +01:00
Eugene Syromyatnikov
e470a92d38 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.
2018-01-29 14:12:50 +01:00
Eugene Syromyatnikov
f7649ed985 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.
2018-01-29 14:10:10 +01:00
Eugene Syromyatnikov
9d35c59421 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.
2018-01-29 14:10:10 +01:00
Eugene Syromyatnikov
a0094a0ebd 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.
2018-01-29 14:10:10 +01:00
Eugene Syromyatnikov
52970d343b 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.
2018-01-29 14:10:10 +01:00
Eugene Syromyatnikov
180a913d84 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.
2018-01-29 14:10:10 +01:00
Eugene Syromyatnikov
9437d47366 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.
2018-01-29 14:10:10 +01:00
Eugene Syromyatnikov
876e77a785 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.
2018-01-29 14:10:10 +01:00
Eugene Syromyatnikov
4ba4e62a51 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.
2018-01-29 14:10:10 +01:00
Eugene Syromyatnikov
501611115f 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.
2018-01-29 14:10:10 +01:00
Eugene Syromyatnikov
baec073f01 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.
2018-01-25 07:18:38 +00:00
Eugene Syromyatnikov
f55ad2bbfc 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.
2018-01-25 07:18:38 +00:00
Eugene Syromyatnikov
96ac341ae7 xlat/gen.sh: add some rudimentary support for comments
* xlat/gen.sh: Trim parts of the string abbreviated in "/*" and "*/"
2018-01-25 07:18:38 +00:00
Eugene Syromyatnikov
865d93c2ec configure.ac: sort architectures in lexicographical order
* configure.ac (case "$host_cpu"): sort architectures in alphabetical
order.
2018-01-25 07:18:38 +00:00
832e2ac13e 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 ...")
2018-01-25 01:55:08 +00:00
Eugene Syromyatnikov
79d10dfc20 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.
2018-01-25 01:55:08 +00:00
Eugene Syromyatnikov
5e39002c23 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.
2018-01-25 01:55:08 +00:00
Eugene Syromyatnikov
fdcfe80983 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.
2018-01-25 01:55:08 +00:00
Eugene Syromyatnikov
8b1ce9ef45 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.
2018-01-25 01:55:08 +00:00
Eugene Syromyatnikov
13f0c7a955 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.
2018-01-25 01:55:08 +00:00
Eugene Syromyatnikov
5b5e9a7620 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.
2018-01-25 01:55:08 +00:00
Eugene Syromyatnikov
1b849e23bf 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>
2018-01-25 01:55:08 +00:00
ceceb4dffb 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.
2018-01-24 01:56:15 +00:00
c7e8fc0e63 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.
2018-01-24 01:56:15 +00:00
Eugene Syromyatnikov
5fcdae5359 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.
2018-01-24 01:56:15 +00:00
5ac1e8e11b 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.
2018-01-23 23:17:02 +00:00
959e82d13d 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.
2018-01-23 23:17:02 +00:00
8c5c14c196 tests: extend the check of select/_newselect syscalls decoding
* tests/xselect.c: Rewrite for better coverage.
2018-01-23 23:17:02 +00:00
c2265040b8 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.
2018-01-23 23:17:02 +00:00
030fae537f 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.
2018-01-23 23:17:02 +00:00
7494f63faa 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.
2018-01-23 23:17:02 +00:00
f03d67cfd9 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.
2018-01-23 23:17:02 +00:00
Eugene Syromyatnikov
c179cc5184 signal.c: remove excess semicolon after the end of the function
* signal.c (rt_sigtimedwait): Remove semicolon after the function body.
2018-01-23 23:17:02 +00:00
Eugene Syromyatnikov
0327446ae5 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.
2018-01-23 23:17:02 +00:00
Eugene Syromyatnikov
2b97629df1 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.
2018-01-23 23:17:02 +00:00
af955678b9 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.
2018-01-21 20:19:53 +00:00