Commit Graph

4399 Commits

Author SHA1 Message Date
b9bc216fdd Set exit status to 1 if strace has not traced any processes
* strace.c (main): Initialize exit_code with 1 when no processes
has been attached.
* strace.1: Document it.
* NEWS: Mention this change.
2016-07-29 22:47:46 +00:00
2ddb73ddd3 Attach to the target process before attempting to attach to its siblings
* strace.c (attach_tcb): Attach to tcp->pid first.
2016-07-29 17:14:28 +00:00
c9251518b0 Report the name of ptrace command when ptrace_attach_or_seize fails.
* strace.c (ptrace_attach_cmd): New variable.
(ptrace_attach_or_seize): Save last ptrace command's name
to ptrace_attach_cmd.
(attach_tcb, startup_child): Use it in error diagnostics.
2016-07-29 17:13:53 +00:00
795795ae99 strace.c: refactor startup_attach
* strace.c (startup_attach): Move the inner part of the big loop
over tcbtab elements ...
(attach_tcb): ... to this new function.
2016-07-29 17:13:47 +00:00
bbfeea269e startup_attach: do not use atoi
* strace.c (startup_attach): Replace atoi with string_to_uint.
2016-07-29 17:10:50 +00:00
6d3162acf1 Do not enable mpers runtime checks if mpers is not enabled
* m4/mpers.m4 (HAVE_RUNTIME): Enable iff both mpers and runtime
work properly.
2016-07-28 18:32:29 +00:00
8ff8ada6ee linux/dummy_check.sh: remove obsolete script
Starting with commit v4.10-62-ga0bd374, function prototypes
of syscall parsers are generated at build time.

* linux/dummy_check.sh: Remove.
2016-07-28 18:32:29 +00:00
a290710b1b generate_xlat_in.sh: remove obsolete script
This script has been created by commit v4.8-180-g0ed617b
for the one-shot job of automatic convertion of xlat structures
from *.c files to xlat/*.in files.

* generate_xlat_in.sh: Remove.
2016-07-28 18:32:28 +00:00
f915f220c0 tests: use terse notation in designated initializers where appropriate
* tests/btrfs.c (btrfs_test_dev_replace_ioctl): Initialize
struct btrfs_ioctl_dev_replace_args using terse notation.
* tests/clock_nanosleep.c (main): Initialize struct timespec
using terse notation.
* tests/nanosleep.c (main): Likewise.
2016-07-28 18:32:28 +00:00
469fd109cd Consistently use extended regular expressions where appropriate
When grep or sed is used with basic regular expressions containing
'(', ')', '{', '}', '|', '?', and '+' special characters, convert them
to extended regular expressions for better portability and readability.

* generate_mpers_am.sh: Convert grep and sed BREs to EREs.
* Makefile.am (ioctl_redefs%.h, m%_type_defs.h, m%_funcs.h,
mpers_printer_decl_pattern, printers.h, %_printer_decls.h,
%_printer_defs.h): Convert sed BREs to EREs.
* generate_sen.sh: Likewise.
* linux/mips/genstub.sh: Likewise.
* make-dsc: Likewise.
* mpers.sh: Likewise.
* xlat/gen.sh: Likewise.
* tests/Makefile.am (ksysent.h): Likewise.
* tests/ksysent.sed: Likewise.
* tests/pc.test: Likewise.
* tests/strace-S.test: Likewise.
* tests/strace-V.test: Likewise.
* tests/strace-k.test: Likewise.
2016-07-28 18:32:18 +00:00
1b2500c6bf tests: fix extended regexps
* tests/adjtimex.c (main): Consistently quote curly braces
in expected output.
* tests/uio.expected: Likewise.
2016-07-28 00:06:46 +00:00
1514448dad Post-release administrivia
* NEWS: Add header line for the next release.
* debian/changelog.in: Add a changelog entry for 4.13-1.
* strace.spec.in: Likewise.
2016-07-27 09:19:37 +00:00
02fb1755da Prepare for 4.13 release
* NEWS: Update for 4.13 release.
2016-07-26 16:17:18 +00:00
de5b0092a6 Fix one more code pattern that might break gcc strict aliasing rules
* btrfs.c (btrfs_ioctl): Add one more expicit cast to "void *",
to avoid breaking strict-aliasing rules reported by some gcc compilers.
* syscall.c (decode_socket_subcall): Likewise.
* util.c (next_set_bit): Likewise.
* tests/btrfs.c (btrfs_test_send_ioctl): Likewise.
2016-07-26 16:14:50 +00:00
82ffa78acd Fix casts of ptrace's third argument
* strace.c (maybe_allocate_tcb): Replace "(char *) 0" with NULL
as ptrace's third argument.
* linux/sparc64/get_scno.c (arch_get_scno): Cast third argument
of ptrace to "void *'.
* syscall.c (get_regs): Likewise.
* upeek.c (upeek): Likewise.
* util.c (umoven): Likewise.
2016-07-26 16:14:50 +00:00
e43bb8dffc tests/btrfs.c: do not include the same header file twice
* tests/btrfs.c: Do not include <sys/fcntl.h>, <fcntl.h> is enough.
2016-07-26 15:51:55 +00:00
9d168f3cdf tests: fix accept4.test on systems that lack SOCK_CLOEXEC definition
* tests/accept4.c: Check that O_CLOEXEC is defined.  Use O_CLOEXEC
instead of SOCK_CLOEXEC.
2016-07-26 15:33:22 +00:00
cb44289ee3 tests: fix vhangup.test
* tests/vhangup.c (main): Fix expected output for the case when
the calling process has CAP_SYS_TTY_CONFIG capability.

Reported-by: Yun-Chih Chen <b03902074@ntu.edu.tw>
2016-07-26 12:16:58 +00:00
58d0ee2ea5 tests: fix chown.test
* tests/chown.test: Fix the value specified for strace -a parameter.

Reported-by: Yun-Chih Chen <b03902074@ntu.edu.tw>
2016-07-26 09:58:37 +00:00
197829aa45 x32: fix syscall entries for x86_64 variants of io_setup and io_submit
* linux/x32/syscallent.h (64:io_setup, 64:io_submit): Change handler
to printargs.
2016-07-25 09:30:02 +00:00
76ebcf1476 tests/ipc.c: fix typo 2016-07-25 09:20:09 +00:00
f922fcc2ef NEWS: Prepare for 4.13 release 2016-07-24 23:40:14 +00:00
fcca2c474c debian: add gcc-multilib to Build-Depends for relevant architectures
* debian/control (Build-Depends) [amd64, ppc64, sparc64, x32]:
Add gcc-multilib to enable multiple personalities support.
2016-07-23 23:22:40 +00:00
1a7c38dc52 tests: check decoding of ipc syscall
* tests/ipc.c: New file.
* tests/ipc.test: New test.
* tests/.gitignore: Add ipc.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add ipc.test.
2016-07-22 19:30:30 +00:00
b412d75f74 Fix corner cases of ipc syscall decoding
* xlat/ipccalls.in: New file.
* ipc.c: New file.
* Makefile.am (libstrace_a_SOURCES): Add it.
* linux/dummy.h (sys_ipc): Remove stub alias.
* syscall.c (decode_ipc_subcall): Treat 1st argument of ipc syscall
as "unsigned int".
[S390 || S390X]: Skip ipc cubcalls that have non-zero version.
[SPARC64]: Likewise, for the native personality.
Save ipc cubcall version for later use by specific ipc parsers.
* ipc_msg.c (SYS_FUNC(msgrcv)): Handle non-zero ipc subcall version.
[SPARC64]: Handle non-ipc_kludge case for the native personality.
* linux/subcall.h (msgrcv): Change nargs from 4 to 5.
* linux/s390/syscallent.h (ipc): Change nargs from 6 to 5.
* linux/s390x/syscallent.h (ipc): Likewise.
2016-07-22 19:28:06 +00:00
9c652ccf90 tests: skip netlink_protocol.test on old systems
* tests/netlink_protocol.c: Check that HAVE_SYS_XATTR_H is defined.
Include <stdlib.h> and <sys/xattr.h>.
(main): Check that system.sockprotoname attribute is supported.
2016-07-21 20:57:55 +00:00
b7844f8b4a Do not print too many arguments of socketcall syscall
* socketcall.c (SYS_FUNC(socketcall)): Print just "call" and "args"
syscall arguments.
* tests/socketcall.c (test_socketcall): Update expected output.
* tests/socketcall.test: Likewise.
2016-07-21 12:32:14 +00:00
3b6bc9b40d tests/nsyscalls.c: change the type of syscall arguments to kernel_ulong_t
As most syscalls on x32 and mips n32 are actually 64-bit,
check that 64-bit syscall arguments are decoded properly.

This also workarounds x32 gcc sign extension bug
reported by Eugene Syromyatnikov at
https://sourceforge.net/p/strace/mailman/message/35150860/

* tests/nsyscalls.c: Include "kernel_types.h".
(main): Change the type of syscall arguments to kernel_ulong_t.
2016-07-20 11:16:37 +00:00
9bd2382f21 x32, mips n32: make printargs print full 64-bit syscall arguments
As most of x32 syscalls are regular x86_64 syscalls, they should be
printed by default as 64-bit syscalls, and syscall parsers at their
discretion might print syscalls differently.  This is already
implemented in 64-bit strace tracing x32 personality processes,
and now x32 strace will also behave this way.

Similar reasoning applies to mips n32.

* util.c (printargs) [HAVE_STRUCT_TCB_EXT_ARG]: Print syscall arguments
from ext_arg array using %llx format.
2016-07-20 11:16:37 +00:00
b49c65cece tests: check decoding of socketcall syscall
* tests/socketcall.c: New file.
* tests/socketcall.test: New test.
* tests/.gitignore: Add socketcall.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add socketcall.test.
2016-07-20 11:16:37 +00:00
e0a0d89bc5 Fix corner cases of socketcall syscall
* xlat/socketcalls.in: New file.
* socketcall.c: New file.
* Makefile.am (libstrace_a_SOURCES): Add it.
* linux/dummy.h (sys_socketcall): Remove stub alias.
* syscall.c (decode_socket_subcall): Treat 1st argument of socketcall
as "int".  Do not substitute syscall until all socketcall arguments
have been fetched successfully.
2016-07-20 11:16:14 +00:00
374dc48dbd tests: check decoding and dumping of send and recv syscalls
* tests/unix-pair-send-recv.c: New file.
* tests/unix-pair-send-recv.expected: Likewise.
* tests/unix-pair-send-recv.test: New test.
* tests/.gitignore: Add unix-pair-send-recv.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add unix-pair-send-recv.test.
(EXTRA_DIST): Add unix-pair-send-recv.expected.
2016-07-19 17:46:33 +00:00
1991ee94bc tests: rename unix-pair-send-recv to unix-pair-sendto-recvfrom
* dumpio.expected: Rename to unix-pair-sendto-recvfrom.expected.
* dumpio.test: Rename to unix-pair-sendto-recvfrom.test.
* unix-pair-send-recv.c: Rename to unix-pair-sendto-recvfrom.c
* .gitignore: Rename unix-pair-send-recv to unix-pair-sendto-recvfrom.
* Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add unix-pair-sendto-recvfrom.test.
(MISC_TESTS): Remove dumpio.test.
(EXTRA_DIST): Rename dumpio.expected
to unix-pair-sendto-recvfrom.expected.
2016-07-19 17:46:33 +00:00
d95eaefb45 tests: check decoding of shutdown syscall
* tests/shutdown.c: New file.
* tests/shutdown.test: New test.
* tests/.gitignore: Add shutdown.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add shutdown.test.
2016-07-19 17:46:33 +00:00
838306234f xlat/shutdown_modes.in: convert to modern syntax
* xlat/shutdown_modes.in: Replace open-coded xlat table with a list
of constants.
2016-07-19 17:46:33 +00:00
349750e1bc tests: check silent decoding of sendmmsg and recvmmsg syscalls
* tests/mmsg-silent.c: New file.
* tests/mmsg-silent.test: New test.
* tests/.gitignore: Add mmsg-silent.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add mmsg-silent.test.
2016-07-19 17:46:33 +00:00
0d88d99da2 Print unsent messages of failed sendmmsg syscall
* mmsghdr.c (decode_mmsgvec): Clear syserror for the time of printing
struct mmsghdr array in !use_msg_len case.
(SYS_FUNC(sendmmsg)): As failed sendmmsg syscall does not
set msg_len fields, tell this to decode_mmsgvec.
* tests/mmsg_name.c (test_mmsg_name): Check it.
2016-07-19 17:46:33 +00:00
3a161d1902 Print unsent messages of sendmmsg syscall
* defs.h (decode_mmsgvec): Add int argument.
* mmsghdr.c (print_struct_mmsghdr_config): Add msg_len_vlen field.
(print_struct_mmsghdr): Print struct mmsghdr.msg_len only for
msg_len_vlen first elements of struct mmsghdr array.
(decode_mmsgvec): Add msg_len_vlen argument.
(SYS_FUNC(sendmmsg), SYS_FUNC(recvmmsg)): Pass to decode_mmsgvec
the number of elements of struct mmsghdr array that contain meaningful
struct mmsghdr.msg_len.
* tests/mmsg_name.c (test_mmsg_name): Check it.
2016-07-19 17:46:33 +00:00
850523683d tests: check verbose decoding of msg_name* fields of struct mmsghdr array
* tests/mmsg_name-v.c: New file.
* tests/mmsg_name-v.test: New test.
* tests/.gitignore: Add mmsg_name-v.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add mmsg_name-v.test.
2016-07-19 17:46:33 +00:00
80bd8e11fa tests: check decoding of msg_name* fields of struct mmsghdr array
* tests/mmsg_name.c: New file.
* tests/mmsg_name.test: New test.
* tests/.gitignore: Add mmsg_name.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add mmsg_name.test.
2016-07-19 17:46:33 +00:00
b42f6b3903 Fix decoding of msg_name* fields of recvmmsg syscall's msghdr array argument
As msg_namelen fields of recvmmsg syscall's struct msghdr array have
the same read-write semantics as struct msghdr argument of recvmsg
syscall, parser of recvmmsg syscall needs a similar fix.

* mmsghdr.c (print_struct_mmsghdr): Increment p_user_msg_namelen field.
(mmsgvec_data): New structure.
(free_mmsgvec_data, save_mmsgvec_namelen): New functions.
(decode_mmsgvec): Take into account the data saved
by save_mmsgvec_namelen function.
(SYS_FUNC(recvmmsg)): Use save_mmsgvec_namelen.
2016-07-19 17:46:33 +00:00
0485ab5e23 mmsghdr.c: rewrite decode_mmsgvec using print_array
* fetch_struct_mmsghdr.c (sizeof_struct_mmsghdr): New mpers printer.
* mmsghdr.c: Include <limits.h>.
(print_struct_mmsghdr_config): New structure.
(fetch_struct_mmsghdr_or_printaddr, print_struct_mmsghdr): New functions.
(decode_mmsgvec): Rewrite using them and print_array.
2016-07-19 17:46:32 +00:00
1c444a75d1 tests: check decoding of timeout argument of recvmmsg syscall
* tests/recvmmsg-timeout.c: New file.
* tests/recvmmsg-timeout.test: New test.
* tests/.gitignore: Add recvmmsg-timeout.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add recvmmsg-timeout.test.
2016-07-19 17:46:30 +00:00
3e3b7f6403 Fix printing of remaining timeout of recvmmsg syscall
* mmsghdr.c (SYS_FUNC(recvmmsg)): Do not print remaining timeout
when the 5th syscall argument is NULL.
* tests/mmsg.c (main): Update expected output.
2016-07-19 17:45:06 +00:00
70495eb3ef Remove configure checks for recvmmsg and sendmmsg
* configure.ac (AC_CHECK_FUNCS): Remove recvmmsg and sendmmsg.
2016-07-19 17:45:06 +00:00
aaf526ce32 tests: add recv_mmsg and send_mmsg functions to libtests
* tests/tests.h (recv_mmsg, send_mmsg): New prototype.
* tests/libmmsg.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
* tests/mmsg.c Do not check for __NR_sendmmsg, __NR_recvmmsg,
HAVE_SENDMMSG, and HAVE_RECVMMSG.  Do not include unused headers.
(recv_mmsg, send_mmsg): Remove.
2016-07-19 17:45:02 +00:00
736d8e4d3f tests: add socketcall function to libtests
* tests/tests.h (socketcall): New prototype.
* tests/libsocketcall.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
2016-07-19 15:15:17 +00:00
8da9668b1b Use IOV_MAX instead of UIO_MAXIOV
IOV_MAX appears to be more portable than UIO_MAXIOV.

* msghdr.c: Include <limits.h>. Remove fallback defintion of UIO_MAXIOV.
(get_optmem_max): Replace UIO_MAXIOV with IOV_MAX.
* tests/msg_control.c: Likewise.
2016-07-18 22:12:45 +00:00
b759d276d5 Unabuse struct tcb.auxstr
As we've got a proper mechanism that parsers can use for storing private
data between entering and exiting stages, all cases of struct tcb.auxstr
abuse should go.

* btrfs.c (btrfs_ioctl): Use set_tcb_priv_ulong and get_tcb_priv_ulong
instead of abusing tcp->auxstr.
* file_handle.c (SYS_FUNC(name_to_handle_at)): Likewise.
* msghdr.c (SYS_FUNC(recvmsg)): Likewise.
* net.c (decode_sockname, SYS_FUNC(recvfrom)): Likewise.
* v4l2.c (print_v4l2_queryctrl): Likewise.
2016-07-18 22:12:45 +00:00
7f8ece11c8 Fix race condition in decoding timeout argument of recvmmsg syscall
As the value returned by sprint_timespec points to a static area and may
be overwritten by subsequent calls to sprint_timespec, it is not safe to
save this value on entering syscall and use it later on exiting.

* mmsghdr.c (SYS_FUNC(recvmmsg)): On entering syscall, copy the value
returned by sprint_timespec to a dynamically allocated memory, and save
the pointer using set_tcb_priv_data.  On exiting, restore it using
get_tcb_priv_data.
2016-07-18 22:12:45 +00:00