Commit Graph

274 Commits

Author SHA1 Message Date
Eugene Syromyatnikov
b46d5b8caf sparc, sparc64: implement kern_features decoder
* sparc.c: New file.
* Makefile.am (EXTRA_DIST): Add it.
* linux/sparc/syscallent.h ([340]): Remove NF flag, set kern_features
decoder.
* linux/sparc64/syscallent.h ([340]): Likewise.
* xlat/sparc_kern_features.in: New file.
* NEWS: Mention this enhancement.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-27 22:22:23 +00:00
Elvira Khabirova
ba8e768a80 Implement delay injection
Add -e inject=SET:delay_enter= and -e inject=SET:delay_exit= options.

* configure.ac (AC_SEARCH_LIBS): Check for timer_create -lrt.
* delay.c: New file.
* Makefile.am (strace_SOURCES): Add it.
(strace_LDADD): Add $(timer_LIBS).
* defs.h (INJECT_F_DELAY_ENTER, INJECT_F_DELAY_EXIT,
TCB_INJECT_DELAY_EXIT, TCB_DELAYED, inject_delay_exit, syscall_delayed):
New macros.
(alloc_delay_data, fill_delay_data, is_delay_timer_created,
arm_delay_timer, delay_tcb): New prototypes.
(struct inject_data): Replace reserved field with delay_idx.
(struct tcb): Add delay_expiration_time field.
* filter_qualify.c (parse_delay_token): New function.
(parse_inject_token): Use it.
(qualify_inject_common): Initialize struct inject_opts.data.delay_idx.
* strace.c: Include <setjmp.h>
(timer_jmp_buf, timer_set): New static variables.
(timer_sighandler, restart_delayed_tcb, restart_delayed_tcbs): New
functions.
(init): Block SIGALRM, set SIGALRM handler.
(dispatch_event): Do not restart delayed syscalls.
(next_event): Unblock SIGALRM during wait4 invocation.
* syscall.c (tamper_with_syscall_entering): Arm delay timer if
INJECT_F_DELAY_ENTER injection flag is set, set TCB_INJECT_DELAY_EXIT
flag if INJECT_F_DELAY_EXIT injection flag is set.
tamper_with_syscall_exiting): Arm delay timer if inject_delay_exit.
(syscall_exiting_trace): Call tamper_with_syscall_exiting in case of
inject_delay_exit.
(syscall_exiting_finish): Clear TCB_INJECT_DELAY_EXIT flag.
* strace.1.in: Document delay injection.
* NEWS: Mention this improvement.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-22 06:23:25 +00:00
dfccb60a75 Fix -O option handling
Fast syscalls usually take less than a microsecond of system cpu time
nowadays, making -O option almost useless.

* count.c (call_summary_pers): Avoid negative time counts.
* tests/count.test: Check it.
* NEWS: Mention it.
2018-03-20 02:30:24 +00:00
Eugene Syromyatnikov
1ed1866ebd btrfs.c: print __u64 fields with pointer semantics using printaddr64
* btrfs.c (btrfs_ioctl) <case BTRFS_IOC_INO_PATHS>: Print fspath field
with printaddr64.
(btrfs_ioctl) <case BTRFS_IOC_LOGICAL_INO>: Print inodes field with
printaddr64.
* tests/btrfs.c: Add checks for NULL in fspath and inodes fields.
* NEWS: Mention it.
2018-03-06 23:52:08 +00:00
Eugene Syromyatnikov
beafdd36e1 prctl: add decoding of PR_SVE_SET_VL and PR_SVE_GET_VL commands
These commands were introduced in Linux commit v4.15-rc1~110^2~9.

* xlat/pr_sve_vl_flags.in: New file.
* xlat/prctl_options.in: Likewise.
* prctl.c: Include "xstring.h" and "xlat/pr_sve_vl_flags.h".
[!PR_SVE_VL_LEN_MASK] (PR_SVE_VL_LEN_MASK): New macro constant.
(sprint_sve_val): New function.
(SYS_FUNC(prctl)): Add decoding for PR_SVE_GET_VL and PR_SVE_SET_VL
commands.
* NEWS: Mention it.
2018-03-06 23:52:08 +00:00
Eugene Syromyatnikov
fd02ce4ff8 Implement PTRACE_SECCOMP_GET_METADATA ptrace request decoding
* defs.h (seccomp_filter_flags): New declaration.
* process.c (SYS_FUNC(ptrace)): Implement PTRACE_SECCOMP_GET_METADATA
request decoding.
* ptrace.h [!PTRACE_SECCOMP_GET_METADATA] (PTRACE_SECCOMP_GET_METADATA):
New macro constant.
* xlat/ptrace_cmds.in (PTRACE_SECCOMP_GET_METADATA): New constant.
* tests/ptrace.c (main): Add some checks for PTRACE_SECCOMP_GET_METADATA
request decoding.
* NEWS: Mention it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-06 23:52:08 +00:00
Eugene Syromyatnikov
2f0842fe61 xlat: add eBPF-based device controller constants
Add new BPF_PROG_TYPE_CGROUP_DEVICE eBPF program type and new
BPF_CGROUP_DEVICE eBPF program attach type, added in Linux commit
v4.15-rc1~84^2~120^2~2.

* xlat/bpf_attach_type.in (BPF_CGROUP_DEVICE): New constant.
* xlat/bpf_prog_types.in (BPF_PROG_TYPE_CGROUP_DEVICE): Likewise.
* NEWS: Mention it.
2018-03-05 15:03:37 +00:00
Eugene Syromyatnikov
e0f59c42d5 xlat: update the list of input event constants
Remove some duplicating definitions and add the new ones.

* xlat/evdev_keycode.in (KEY_HANGUEL): Remove, an alternative name for
KEY_HANGEUL.
(KEY_DIRECTION): Remove, an alternative name for KEY_ROTATE_DISPLAY.
(KEY_BRIGHTNESS_ZERO): Remove, an alternative name for
KEY_BRIGHTNESS_AUTO.
(KEY_WIMAX): Remove, an alternative name for KEY_WWAN.
(BTN_A): Remove, an alternative name for BTN_SOUTH.
(BTN_B): Remove, an alternative name for BTN_EAST.
(BTN_X): Remove, an alternative name for BTN_NORTH.
(BTN_Y): Remove, an alternative name for BTN_WEST.
(BTN_STYLUS3): New constant, added in Linux commit v4.15-rc1~114^2^2~1.
(KEY_BRIGHTNESS_TOGGLE): Remove, an alternative name for
KEY_DISPLAYTOGGLE.
(KEY_ROTATE_LOCK_TOGGLE): New constant, added in Linux commit
v4.16-rc1~54^2~67.
(KEY_DATA): New constant, added in Linux commit v4.9-rc8~12^2.
(KEY_ONSCREEN_KEYBOARD): New constant, added in Linux commit
v4.12-rc1~126^2~2^12~5.
* NEWS: Mention it.
2018-03-02 21:53:08 +00:00
Eugene Syromyatnikov
67ec8128bf xlat: update the list of SCTP socket option constants
* xlat/socksctpoptions.in (SCTP_DELAYED_ACK): Rename to...
(SCTP_DELAYED_SACK): ...this, per Linux commit v2.6.38-rc2~33^2.
(SCTP_SOCKOPT_PEELOFF_FLAGS): New constant, introduced in Linux commit
v4.13-rc1~157^2~39.
(SCTP_STREAM_SCHEDULER): New constant, introduced in Linux commit
v4.15-rc1~84^2~567^2~3.
(SCTP_STREAM_SCHEDULER_VALUE): New constant, introduced in Linux commit
v4.15-rc1~84^2~567^2~2.
(SCTP_INTERLEAVING_SUPPORTED): New constant, introduced in Linux commit
 v4.16-rc1~123^2~384^2~11.
* NEWS: Mention it.
2018-03-02 21:53:08 +00:00
Eugene Syromyatnikov
183233aff1 xlat: update the list of Ethernet protocol constants
* xlat/ethernet_protocols.in (ETH_P_ERSPAN2): New constant, introduced
in Linux commit v4.16-rc1~123^2~355^2~2.
(ETH_P_IBOE): New constant, introduced in commit v4.11-rc1~73^2~74.
* NEWS: Mention it.
2018-03-02 21:53:08 +00:00
Eugene Syromyatnikov
cfa55479c2 v4l2: print known pixel/SDR formats
* xlat/v4l2_pix_fmts.in: New file.
* xlat/v4l2_sdr_fmts.in: Likewise.
* v4l2.c [!v4l2_fourcc_be] (v4l2_fourcc_be): New macro.
(print_pixelformat): Add xlat parameter, print constant name
as a comment if it has been found in xlat.
(print_v4l2_fmtdesc, print_v4l2_frmivalenum): Pass v4l2_pix_fmts
to print_pixelformat.
(print_v4l2_format_fmt) <case V4L2_BUF_TYPE_VIDEO_CAPTURE, case
V4L2_BUF_TYPE_VIDEO_OUTPUT, case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, case V4L2_BUF_TYPE_VBI_CAPTURE,
case V4L2_BUF_TYPE_VBI_OUTPUT>: Pass v4l2_pix_fmts to print_pixelformat.
(print_v4l2_format_fmt) <case V4L2_BUF_TYPE_SDR_OUTPUT, case
V4L2_BUF_TYPE_SDR_CAPTURE>: Pass v4l2_sdr_fmts to print_pixelformat.
* tests/v4l2.c: Test it, update expected output.
* NEWS: Mention it.
2018-03-02 16:02:20 +00:00
Eugene Syromyatnikov
b82706f412 v4l2: v4l2_fourcc is endianness-agnostic
v4l2_fourcc(a, b, c, d) is defined as (a | (b << 8) | (c << 16) | (d << 24)
regardless of endianness (no mnemonic on big-endian architectures),
so we don't need special handling for WORDS_BIGENDIAN both in decoder
and in the test.

* v4l2.c (print_pixelformat): Change initialisation to a simple
assignment of character array.
* tests/ioctl_v4l2.c [WORDS_BIGENDIAN]: Remove.
* NEWS: Mention this fix.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Fixes: v4.10~371 "Implement Video4Linux video-input ioctls decoder"
2018-03-02 16:02:20 +00:00
Eugene Syromyatnikov
48feeb3723 printfd: print character/block device number in -yy mode
* util.c: Include <sys/stat.h>, <sys/sysmacros.h>,
and "largefile_wrappers.h".
(printsocket, printdev): New functions.
(printfd): Move socket matching/printing logic to printsocket.  Check
also for printdev.  Escape opening angle bracket in addition to closing angle
bracket as it can show up as a separator in printdev.
* tests/fsync-y.c: Update expected output.
* strace.1.in: Mention this.
* NEWS: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-01 01:00:24 +00:00
Eugene Syromyatnikov
6d36a70868 util.c: escape closing angle bracket in printfd
* util.c (printfd): Use print_quoted_string_ex instead of
print_quoted_string, specify ">" as escape_chars argument.
* tests/fsync-y.c (main): Update expected output.
* NEWS: Mention it.
2018-03-01 01:00:24 +00:00
Eugene Syromyatnikov
413c085e59 Update the list of INET_DIAG_BC_* operators
* linux/inet_diag.h (INET_DIAG_BC_S_EQ, INET_DIAG_BC_D_EQ): New
enumeration items introduced by linux kernel commit v4.16-rc1~123^2~259.
* xlat/inet_diag_bytecodes.in (INET_DIAG_BC_S_EQ, INET_DIAG_BC_D_EQ): New
constants.
* NEWS: Mention it.
2018-02-27 13:14:38 +00:00
Eugene Syromyatnikov
0d592163cd xlat: update the list of SCHED_FLAG_* constants
* xlat/sched_flags.in (SCHED_FLAG_RECLAIM, SCHED_FLAG_DL_OVERRUN): New
constants introduced by linux kernel commits v4.13-rc1~205^2~27 and
v4.16-rc1~164^2~8, respectively.
(SCHED_FLAG_RESET_ON_FORK): Add constant value.
* tests/sched_xetattr.c: Update expected output.
* NEWS: Mention it.
2018-02-27 13:14:38 +00:00
Eugene Syromyatnikov
176c894c91 xlat: update the list of poll event flags
POLL_BUSY_LOOP was introduced by linux kernel commit v3.11-rc1~64^2~129
as POLL_LL and then renamed in v3.11-rc1~64^2~9.  POLLRDHUP was
introduced by linux kernel commit v2.6.17-rc1~796.  POLLMSG and
POLLREMOVE predate git repository.  POLLFREE was introduced by linux
kernel commit v3.3-rc5~8 for internal use only.

* xlat/pollflags.in (POLLMSG, POLLREMOVE, POLLRDHUP, POLL_BUSY_LOOP):
New constants.
* NEWS: Mention it.
2018-02-27 13:14:38 +00:00
Eugene Syromyatnikov
a3b09b9c3b xlat: add arch-specific si_codes constants
Based on Linux commits v4.16-rc1~159^2~17, v4.16-rc1~159^2~16,
v4.16-rc1~159^2~15, and v4.16-rc1~159^2~14.

* xlat/sigbus_codes.in (BUS_OPFETCH): New constant.
* xlat/sigfpe_codes.in (FPE_MDAOVF, __FPE_DECOVF, __FPE_DECDIV,
__FPE_DECERR, __FPE_INVASC, __FPE_INVDEC): New constants.
* xlat/sigill_codes.in (ILL_ILLPARAOP, ILL_ILLEXCPT, ILL_CPLB_VI,
ILL_CPLB_MISS, ILL_CPLB_MULHIT, ILL_DBLFLT, ILL_HARDWALL, ILL_BADIADDR,
__ILL_BREAK, __ILL_BNDMOD): Likewise.
* xlat/sigsegv_codes.in (SEGV_STACKFLOW, __SEGV_PSTKOVF): Likewise.
* xlat/sigtrap_codes.in (TRAP_STEP, TRAP_TRACEFLOW, TRAP_WATCHPT,
TRAP_ILLTRAP): Likewise.
* NEWS: Mention it.
2018-02-27 13:14:38 +00:00
Eugene Syromyatnikov
53ebefe984 rtnl_link: implement IFLA_EVENT_* decoding
* rtnl_link.c (decode_ifla_event): New function.
(ifinfomsg_nla_decoders) <[IFLA_EVENT]>: Use it.
* xlat/rtnl_ifla_events.in: New file.
* NEWS: Mention it.
2018-02-27 13:14:38 +00:00
Eugene Syromyatnikov
2e5510da5f xlat: update the list of RWF_* constants
* xlat/rwf_flags.in (RWF_APPEND): New constant introduced by linux
kernel commit v4.16-rc1~145^2~7.
* NEWS: Mention it.
2018-02-27 13:14:38 +00:00
Eugene Syromyatnikov
85e2e24e19 Print IPv6 addresses in brackets
Follow a common practice for printing address:port pair to distinguish
address parts delimiter from address/port delimiter.

* socketutils.c (inet_parse_response) <ob, cb>: New variables,
initialise them to open/closing brackets or empty strings based
on address family.
(inet_parse_response): Print ob and cb around src_buf and dst_buf.
* NEWS: Mention this improvement.
2018-02-27 00:17:47 +00:00
003c02745f Wipe out references to defunct sourceforge
The old location of strace-devel mailing list is defunct, it used to
lose email messages and sometimes did not deliver any mails for days.

The mailing list has been moved to strace-devel@lists.strace.io.

* CREDITS.in: Update the mailing list address.
(Zhang Le): Update email address.
* README: Update the mailing list address.
* README.md: Likewise.
* configure.ac (AC_INIT): Likewise.
* strace.1.in (.SH REPORTING BUGS): Likewise.
* strace-log-merge.1.in (.SH REPORTING BUGS): Likewise.
* sched.c (SYS_FUNC(sched_getattr)): Update the mailing list reference.
* tests/scno_tampering.sh: Likewise.
* qemu_multiarch_testing/README: Update git repository address.
* NEWS: Mention the change of the mailing list address.

Closes: https://github.com/strace/strace/issues/38
2018-02-23 23:18:56 +00:00
6ebf6c4f9e m68k: fix build
When <sys/reg.h> is included after <linux/ptrace.h>, the build fails
on m68k with the following diagnostics:

  In file included from /usr/include/linux/ptrace.h:101:0,
                   from ptrace.h:51,
                   from sigreturn.c:2:
  /usr/include/m68k-linux-gnu/sys/reg.h:26:3: error: expected identifier
  before numeric constant
     PT_D1 = 0,
     ^

Apparently, the only architecture where strace needs definitions
provided by <sys/reg.h> is x86_64, other three (m68k, tile, and x86)
are fine with definitions already provided by <linux/ptrace.h>.

Fix the issue by getting rid of <sys/reg.h> and defining necessary
macros in linux/x86_64/arch_regs.h file.

* configure.ac (AC_CHECK_HEADERS): Remove sys/reg.h.
* regs.h: Do not include <sys/reg.h>.
* linux/x86_64/arch_regs.h (R15, R14, R13, R12, RBP, RBX, R11, R10,
R9, R8, RAX, RCX, RDX, RSI, RDI, ORIG_RAX, RIP, CS, EFLAGS, RSP, SS,
FS_BASE, GS_BASE, DS, ES, FS, GS): New macros.
* NEWS: Mention this fix.

Fixes: v4.21~21 ("Include <sys/ptrace.h> early")
2018-02-21 23:03:27 +00:00
70e76c39cd Post-release administrivia
* NEWS: Add a header line for the next release.
* debian/changelog.in: Add a changelog entry for 4.21-1.
* strace.spec.in: Likewise.
2018-02-14 03:00:00 +00:00
51630c2002 Prepare for 4.21 release
* NEWS: Update for 4.21 release.
2018-02-13 23:00:00 +00:00
Eugene Syromyatnikov
31e1025264 Update the list of PKEY_* constants
* xlat/pkey_access.in (PKEY_DISABLE_EXECUTE): New constant introduced
by linux kernel commit v4.16-rc1~93^2~85.
* tests/pkey_alloc.c: Update expected output.
* NEWS: Mention it.
2018-02-12 18:28:16 +00:00
Eugene Syromyatnikov
850bb4124f powerpc, powerpc64: wire up pkey_* syscalls
* linux/powerpc/syscallent.h [384..386]: Add pkey_alloc,
pkey_free, and pkey_mprotect syscalls introduced by linux kernel
commits v4.16-rc1~93^2~70 and v4.16-rc1~93^2~69, respectively.
* linux/powerpc64/syscallent.h: Likewise.
* NEWS: Mention it.
2018-02-12 18:28:16 +00:00
Eugene Syromyatnikov
2a368bd36f Update NEWS 2018-02-12 18:08:07 +00:00
Eugene Syromyatnikov
e26e9dacda linux/ia64: remove IA-32 mode support
There is no compat support in strace and there are no systems
within reach that would allow to test it.

* linux/ia64/arch_regs.c (IA64_PSR_IS, ia64_ia32mode): Remove.
* linux/ia64/get_error.c (get_error): Remove ia64_ia32mode branch.
* linux/ia64/get_scno.c (arch_get_scno): Likewise.
* linux/ia64/get_syscall_args.c (get_syscall_args): Likewise.
* linux/ia64/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/ia64/set_scno.c (arch_set_scno): Likewise.
2018-02-12 11:42:04 +00:00
Eugene Syromyatnikov
eb45473d7f 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.
2018-02-10 01:33:49 +00:00
Eugene Syromyatnikov
dbaa7a5b06 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.
2018-02-09 22:11:50 +00:00
Eugene Syromyatnikov
e87c073ecc 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>
2018-02-09 01:16:13 +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
a7457d88e2 Update NEWS 2018-01-29 14:12:50 +01: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
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
Eugene Syromyatnikov
1b75ffef40 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.
2018-01-21 01:46:04 +00:00
Eugene Syromyatnikov
6f36919172 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.
2018-01-21 01:46:04 +00:00
Eugene Syromyatnikov
d9f6166f0c 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.
2018-01-19 02:04:37 +01:00
Eugene Syromyatnikov
6850ddbc42 Update NEWS 2018-01-18 02:17:12 +01:00
376cf85efe configure: try to set the C compiler mode to accept ISO Standard C
* configure.ac: Use AC_PROG_CC_STDC.
* NEWS: Mention this.
2018-01-16 01:09:14 +00:00
8672a7189d Enhance decoding of mq_* syscalls
* mq.c (SYS_FUNC(mq_open)): Add RVAL_FD to return value.
(SYS_FUNC(mq_timedsend), SYS_FUNC(mq_timedreceive), SYS_FUNC(mq_notify),
SYS_FUNC(mq_getsetattr)): Print the first argument using printfd.
* NEWS: Mention this change.
* pathtrace.c (pathtrace_match_set) <SEN_mq_getsetattr, SEN_mq_notify,
SEN_mq_open, SEN_mq_timedreceive, SEN_mq_timedsend>: Skip matching.
* linux/32/syscallent.h (mq_getsetattr, mq_notify, mq_open,
mq_timedreceive, mq_timedsend): Add TD flag.
* linux/64/syscallent.h: Likewise.
* linux/alpha/syscallent.h: Likewise.
* linux/arm/syscallent.h: Likewise.
* linux/avr32/syscallent.h: Likewise.
* linux/bfin/syscallent.h: Likewise.
* linux/crisv10/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/mips/syscallent-n32.h: Likewise.
* linux/mips/syscallent-n64.h: Likewise.
* linux/mips/syscallent-o32.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.
2018-01-15 22:47:38 +00:00
Eugene Syromyatnikov
4e5033c8d2 xlat: update NT_* constants
Update NT_* descriptor types with the values borrowed from
kernel's include/uapi/linux/elf.h and glibc's elf.h.

* xlat/nt_descriptor_types.in (NT_PRSTATUS, NT_FPREGSET, NT_PRPSINFO,
NT_PRXREG, NT_TASKSTRUCT, NT_PLATFORM, NT_AUXV, NT_GWINDOWS, NT_ASRS,
NT_PSTATUS, NT_PSINFO, NT_PRCRED, NT_UTSNAME, NT_LWPSTATUS,
NT_LWPSINFO, NT_PRFPXREG, NT_PRXFPREG, NT_PPC_VMX, NT_PPC_SPE,
NT_PPC_VSX, NT_386_TLS, NT_386_IOPERM, NT_X86_XSTATE): Add fallback
definitions.
(NT_SIGINFO, NT_FILE, NT_PPC_*, NT_S390_*, NT_ARM_*, NT_METAG_*,
NT_ARC_V2): New constants.
* NEWS: Mention this.
2018-01-14 23:08:10 +00:00
Gleb Fotengauer-Malinovskiy
649dd83545 Update ioctl entries from linux v4.15-rc7
* linux/32/ioctls_inc_align16.h: Update from linux v4.15-rc7 using ioctls_gen.sh.
* linux/32/ioctls_inc_align32.h: Likewise.
* linux/32/ioctls_inc_align64.h: Likewise.
* linux/64/ioctls_inc.h: Likewise.
* linux/x32/ioctls_inc0.h: Likewise.
* NEWS: Mention this.
2018-01-11 19:24:15 +00:00
Eugene Syromyatnikov
60bbdda7c2 Add strace-log-merge man page
* strace-log-merge.1.in: New file.
* NEWS: Mention this.
* .gitignore: Add strace-log-merge.1.
* Makefile.am (man_MANS): Likewise.
* configure.ac (AC_CONFIG_FILES): Likewise.
* debian/strace.manpages: Likewise.
2017-11-30 02:35:50 +01:00
acffeae467 mpers: fix cross-compiling
In cross builds, a target version of readelf has to be used
instead of a native one.

* configure.ac (AC_CHECK_TOOL): Add readelf.
* Makefile.am (READELF): New variable.
(mpers-m%.stamp): Pass it to $(srcdir)/mpers.sh.
* m4/mpers.m4 (st_MPERS): Pass READELF environment variable
to $srcdir/mpers_test.sh.
* mpers.sh (READELF): New variable.
Use it instead of readelf.
* maint/ioctls_sym.sh: Likewise.
* NEWS: Mention this fix.

Reported-by: Rolf Eike Beer <eb@emlix.com>
2017-11-25 01:55:44 +00:00
5c51173830 Implement decoding of BPF_OBJ_GET_INFO_BY_FD command of bpf syscall
* configure.ac (AC_CHECK_MEMBERS): Add union bpf_attr.info.info.
* bpf.c (decode_BPF_OBJ_GET_INFO_BY_FD): New function.
(SYS_FUNC(bpf)) <bpf_cmd_decoders>: Use it.
* NEWS: Mention this.
* tests/bpf.c: Add macro guard for BPF_OBJ_GET_INFO_BY_FD decoder test.
[HAVE_UNION_BPF_ATTR_INFO_INFO] (sample_BPF_OBJ_GET_INFO_BY_FD_attr):
New variable.
[HAVE_UNION_BPF_ATTR_INFO_INFO] (init_BPF_OBJ_GET_INFO_BY_FD_first,
print_BPF_OBJ_GET_INFO_BY_FD_first, init_BPF_OBJ_GET_INFO_BY_FD_attr,
print_BPF_OBJ_GET_INFO_BY_FD_attr): New functions.
(main) [HAVE_UNION_BPF_ATTR_INFO_INFO]: Use them.
2017-11-21 23:12:04 +00:00