]> granicus.if.org Git - strace/log
strace
5 years agosyslog: do not print bufp and len for commands that ignore them
Eugene Syromyatnikov [Wed, 26 Sep 2018 22:42:27 +0000 (00:42 +0200)]
syslog: do not print bufp and len for commands that ignore them

* syslog.c (SYS_FUNC(syslog)): Defer printing of comma after the first
argument to the specific command handlers, return RVAL_DECODED without
additional printing for SYSLOG_ACTION_CLOSE, SYSLOG_ACTION_OPEN,
SYSLOG_ACTION_CLEAR, SYSLOG_ACTION_CONSOLE_OFF,
SYSLOG_ACTION_CONSOLE_ON, SYSLOG_ACTION_SIZE_UNREAD,
SYSLOG_ACTION_SIZE_BUFFER.
* tests/syslog.c: Add checks.

5 years agosyslog: fix switch statement indentation
Eugene Syromyatnikov [Wed, 26 Sep 2018 22:27:21 +0000 (00:27 +0200)]
syslog: fix switch statement indentation

* syslog.c (SYS_FUNC(syslog)): Decrease indentation level of case
clauses in the switch statement.

5 years agosyslog: print syslog command with verbose style, as it is not in UAPI
Eugene Syromyatnikov [Wed, 26 Sep 2018 16:56:15 +0000 (18:56 +0200)]
syslog: print syslog command with verbose style, as it is not in UAPI

* syslog.c (SYS_FUNC(syslog)): Print syslog_action_type using
XLAT_STYLE_VERBOSE.
* tests/syslog.c: Update expected output.

5 years agotests: update hppa workaround in remap_file_pages test
Dmitry V. Levin [Mon, 5 Aug 2019 19:01:36 +0000 (19:01 +0000)]
tests: update hppa workaround in remap_file_pages test

... to cater for the change of MAP_TYPE on hppa introduced
by Linux kernel commit v4.17-rc1~146^2~9.

* tests/remap_file_pages.c (main) [__hppa__ && MAP_TYPE != 0x03]
(MAP_TYPE_str): Define to "0x2b /* MAP_??? */".

5 years agoRemove AUDIT_ARCH_* fallback definitions from arch_get_personality.c files
Dmitry V. Levin [Mon, 5 Aug 2019 10:58:30 +0000 (10:58 +0000)]
Remove AUDIT_ARCH_* fallback definitions from arch_get_personality.c files

Since xlat/audit_arch.h provides definitions for all AUDIT_ARCH_*
constants, remove their fallback definitions from other files.

* get_personality.c [SUPPORTED_PERSONALITIES > 1]: Include
"xlat/elf_em.h" and "xlat/audit_arch.h" under XLAT_MACROS_ONLY.
* linux/aarch64/arch_get_personality.c (AUDIT_ARCH_ARM): Remove.
* linux/powerpc64/arch_get_personality.c (AUDIT_ARCH_PPC): Remove.
* linux/riscv/arch_get_personality.c (AUDIT_ARCH_RISCV32): Remove.
* linux/s390x/arch_get_personality.c (AUDIT_ARCH_S390): Remove.
* linux/sparc64/arch_get_personality.c (AUDIT_ARCH_SPARC): Remove.
* linux/tile/arch_get_personality.c (AUDIT_ARCH_TILEGX32,
AUDIT_ARCH_TILEPRO): Remove.
* linux/x86_64/arch_get_personality.c (AUDIT_ARCH_I386): Remove.

5 years agoxlat: update audit_arch.in
Eugene Syromyatnikov [Sun, 25 Nov 2018 15:51:14 +0000 (16:51 +0100)]
xlat: update audit_arch.in

* xlat/audit_arch.in: Add fallback definitions.
(__AUDIT_ARCH_CONVENTION_MIPS64_N32, __AUDIT_ARCH_64BIT,
__AUDIT_ARCH_LE): New macros.
(AUDIT_ARCH_V850): New constant.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: add elf_em.in
Eugene Syromyatnikov [Thu, 22 Nov 2018 09:45:02 +0000 (10:45 +0100)]
xlat: add elf_em.in

For now, it's a source of fallback values for AUDIT_ARCH_* constants.

* xlat/elf_em.in: New file.
* xlat/audit_arch.in (AUDIT_ARCH_ARM, AUDIT_ARCH_ARMEB, AUDIT_ARCH_FRV,
AUDIT_ARCH_MICROBLAZE, AUDIT_ARCH_OPENRISC): Define unconditionally.
* printsiginfo.c: Include "xlat/elf_em.h".
* tests/ptrace_syscall_info.c: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agostrace.c: sync up strace -h message with the man page
Eugene Syromyatnikov [Wed, 24 Jul 2019 08:44:31 +0000 (10:44 +0200)]
strace.c: sync up strace -h message with the man page

Especially synopsis.

* strace.c (usage): copy synopsis over from the man page; add "-A"
and "-qq" options description.

5 years agostrace.1.in: add missing options to synopsis
Eugene Syromyatnikov [Wed, 24 Jul 2019 08:41:32 +0000 (10:41 +0200)]
strace.1.in: add missing options to synopsis

* strace.1.in (.SH SYNOPSIS): add second "-q", "-w", second "-y", "-z",
and "-Z" to normal call variant; add "-w", "-z" and "-Z" to syscall
statistics call variant.

5 years agostrace.c: split lines in strace -h output to fit into 80 columns
Eugene Syromyatnikov [Wed, 24 Jul 2019 08:26:21 +0000 (10:26 +0200)]
strace.c: split lines in strace -h output to fit into 80 columns

* strace.c (usage): split "-yy", "-c", "-e" options descriptions to fit
into 80 columns width.

5 years agostrace.c: move -v to Output format section in strace -h message
Eugene Syromyatnikov [Wed, 24 Jul 2019 08:20:52 +0000 (10:20 +0200)]
strace.c: move -v to Output format section in strace -h message

And also reword it into a more general and concise form in order to fit
into 80-columnt width.

* strace.c (usage): Move "-v" option to the "Output format" option of
the help message, reword its description.

5 years agostrace.c: add "-k" to strace -h list of options
Eugene Syromyatnikov [Wed, 24 Jul 2019 07:52:05 +0000 (09:52 +0200)]
strace.c: add "-k" to strace -h list of options

It is mentioned in the "Output format" section below, but not in the
usage section.

* strace.c (usage): Define K_OPT macro with a value that depends
on ENABLE_STACKTRACE macro presence, use it in the help output, undefine
it.

5 years agostrace.1.in: rewrite supported -e status options in a more compact form
Eugene Syromyatnikov [Wed, 24 Jul 2019 00:13:11 +0000 (02:13 +0200)]
strace.1.in: rewrite supported -e status options in a more compact form

* strace.1.in (.SS Filtering): Rewrite -e status value options in a
sublist.

5 years agostrace.1.in: reformat mpers support matrix table
Eugene Syromyatnikov [Tue, 23 Jul 2019 23:51:03 +0000 (01:51 +0200)]
strace.1.in: reformat mpers support matrix table

In order to make it much less wider.

* strace.1.in (.SH MULTIPLE PERSONALITY SUPPORT): Move additional text
in x86_64 line to notes under the table, clarify PowerPC specifics.

5 years agostrace.1.in: compact small named lists
Eugene Syromyatnikov [Tue, 23 Jul 2019 23:46:33 +0000 (01:46 +0200)]
strace.1.in: compact small named lists

And also rewrite nested .RS/.RE abomination.

* strace.1.in (.SS Output format): compact -X option values variants
using ".TQ".
(.SS Tampering): Rewrite -e inject=:when= expression variants using
".TP"/".TQ".
(.SH MULTIPLE PERSONALITY SUPPORT): compact optional features list using
".TQ".

5 years agostrace.1.in: rewrite conditional parts
Eugene Syromyatnikov [Tue, 23 Jul 2019 23:43:25 +0000 (01:43 +0200)]
strace.1.in: rewrite conditional parts

The current implementation doesn't work as intended since in case the
condition is false, .ig has no effect and it results in "warning: macro
'end_unwind_opt' not defined".  Rewrite it into something more dumb and
verbose, but hopefully correct.

* strace.1.in (.SH SYNOPSYS, .SS Output format): Prepend each
conditional line with respective ".if" instead of trying to wrap
it in ".ig".

5 years agostrace.1.in: add AUTHORS section
Eugene Syromyatnikov [Tue, 23 Jul 2019 18:57:25 +0000 (20:57 +0200)]
strace.1.in: add AUTHORS section

* strace.1.in: Add .SH AUTHORS, refer to the CREDITS file.

5 years agostrace.1.in: add a link to the current project's home page
Eugene Syromyatnikov [Tue, 23 Jul 2019 18:50:18 +0000 (20:50 +0200)]
strace.1.in: add a link to the current project's home page

* strace.1.in (.SH SEE ALSO): Add a link to strace's home page.

5 years agostrace.1.in: reorder options
Eugene Syromyatnikov [Tue, 23 Jul 2019 18:37:24 +0000 (20:37 +0200)]
strace.1.in: reorder options

In an attempt to make the order more sensible.

* strace.1.in (.SH OPTIONS): Insert ".SS General" at the beginning of
the section; move ".SS Startup" after ".SS General"; move ".SS Tracing"
after ".SS Startup"; move ".SS Filtering" after ".SS Startup"; insert
".SS Tampering" after ".SS Statistics"; move "-e expr" from ".SS
Filtering" to ".SS General"; move "-e abbrev", "-e verbose", "-e raw",
"-e read", "-e write", "-e kvm=vcpu" and "-v" from ".SS Filtering"
to ".SS Output format"; move "-e inject" and "-e fault" from
".SS Filtering" to ".SS Tampering".

5 years agoTreat PowerPC 64 LE as a separate architecture
Eugene Syromyatnikov [Wed, 24 Jul 2019 14:57:34 +0000 (16:57 +0200)]
Treat PowerPC 64 LE as a separate architecture

That seems to be the easiest way to properly handle the fact that
PPC64LE does not have a meaningful m32 personality.

* configure.ac: Move AC_C_BIGENDIAN before arch detection; determine
powerpc64/powerpc64le arch based on $ac_cv_c_bigendian value.
* linux/dummy.h [POWERPC64LE] (sys_oldselect): Redirect to printargs.
* linux/powerpc64le/arch_defs_.h: New file.
* linux/powerpc64le/arch_regs.c: Likewise.
* linux/powerpc64le/arch_rt_sigframe.c: Likewise.
* linux/powerpc64le/errnoent.h: Likewise.
* linux/powerpc64le/get_error.c: Likewise.
* linux/powerpc64le/get_scno.c: Likewise.
* linux/powerpc64le/get_syscall_args.c: Likewise.
* linux/powerpc64le/ioctls_arch0.h: Likewise.
* linux/powerpc64le/ioctls_inc0.h: Likewise.
* linux/powerpc64le/raw_syscall.h: Likewise.
* linux/powerpc64le/rt_sigframe.h: Likewise.
* linux/powerpc64le/set_error.c: Likewise.
* linux/powerpc64le/set_scno.c: Likewise.
* linux/powerpc64le/syscallent.h: Likewise.
* linux/powerpc64le/userent.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* tests/ipc_msg.c: Check for POWERPC64LE definition in addition to
POWERPC64.
* util.c (getllval): Add check for POWERPC64LE definition in addition to
POWERPC64.
* strace.1.in (.SH MULTIPLE PERSONALITY SUPPORT): Mention that only big
endian PowerPC 64 has mpers support.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoFix invalid free in trace_close_memstream
Pierre Marsais [Sun, 4 Aug 2019 15:39:29 +0000 (16:39 +0100)]
Fix invalid free in trace_close_memstream

In maybe_switch_tcbs we exchange the pointers to the memstream's buffers
between 2 tcb, however the libc doesn't know and keeps updating the
tcb->memfptr as if the exchange didn't happen.  This leads to
unsynchronized tcb->memfptr and tcb->outf and invalid frees.
Adding a new indirection fixes the problem.

* stage_output.c (struct staged_output_data): New struct.
(strace_open_memstream, strace_close_memstream): Use it.
* defs.h (struct tcb): Replace real_outf, memfptr, and memfloc
with a pointer to struct staged_output_data.
* strace.c (maybe_switch_tcbs): Use it.
* syscall.c (print_syscall_resume): Ditto.

Signed-off-by: Pierre Marsais <pierre.marsais@lse.epita.fr>
5 years agotests: fix expected output for some ipc tests
Dmitry V. Levin [Sun, 4 Aug 2019 08:47:00 +0000 (08:47 +0000)]
tests: fix expected output for some ipc tests

* tests/gen_tests.in (ipc_msgbuf-Xraw, ipc_shm, ipc_shm-Xabbrev,
ipc_shm-Xverbose): Adjust -a argument.

5 years agotests: check the latest MSG_TRUNC decoding fix
Dmitry V. Levin [Fri, 2 Aug 2019 16:53:02 +0000 (16:53 +0000)]
tests: check the latest MSG_TRUNC decoding fix

* tests/recv-MSG_TRUNC.c: New file.
* tests/recvfrom-MSG_TRUNC.c: Likewise.
* tests/gen_tests.in (recv-MSG_TRUNC, recvfrom-MSG_TRUNC): New entries.
* tests/pure_executables.list: Add recv-MSG_TRUNC and
recvfrom-MSG_TRUNC.
* tests/.gitignore: Likewise.

5 years agonet: Fix access beyond tracee buffer for MSG_TRUNC receives
Jeremy Kerr [Fri, 2 Aug 2019 03:01:29 +0000 (11:01 +0800)]
net: Fix access beyond tracee buffer for MSG_TRUNC receives

The recv(), recvfrom() and recvmsg() calls allow a MSG_TRUNC flag, which
indicates that the kernel should return the available size of an
incoming message, rather than the received size.

When strace-ing a truncated recv(), strace will try to access a
return-value size area of the tracee's buffer, which may be larger than
the actual buffer:

  $ obj/strace -e trace=recvfrom ~/tmp/recv-test
  recvfrom(3, "\1\2\3\4\0\0\0\0", 4, MSG_TRUNC, NULL, NULL) = 8

If I add a non-readable guard page after the tracee's recv buffer, we
see strace failing to read the vm area:

  $ obj/strace -e trace=recvfrom ~/tmp/recv-test+guard
  recvfrom(3, obj/strace: umoven: short read (4 < 8) @0x7f0b0d7ddffc
  0x7f0b0d7ddffc, 4, MSG_TRUNC, NULL, NULL) = 8

This change restricts the maximum read size to the size of the tracee's
actual buffer.

The recvmsg() handler will do the right thing by using the .iov_len
data, so no change is required there.

* net.c (sys_recv, sys_recvfrom): Clamp maximum sockbuf size.

5 years agoAdd xlat description structure
Eugene Syromyatnikov [Sun, 19 Aug 2018 17:53:06 +0000 (19:53 +0200)]
Add xlat description structure

Rename struct xlat to struct xlat_data and make struct xlat an xlat
descriptor that contains various information about xlat.
So far it's the type and the number of items.

As a result, xlookup/printxval now have enough information for handling
xlat depending on its type, so *index/*_search API is not needed any
longer.

* xlat.h (struct xlat_data): Rename from struct xlat.
(struct xlat): New type definition.
* xlat.c (xlat_search, printxval_sized, printxval_searchn_ex, xlat_idx,
printxval_indexn_ex, printxval_dispatch_ex): Remove.
(xlookup): Handle xlat_data based on xlat type.
(xlat_search_eq_or_less, xlookup_le): New functions.
(sprintflags_ex, printflags_ex): Update.
* xlat/gen.sh (gen_header): Add handling for #sorted, generate new
struct xlat descriptor.
* defs.h (arp_hardware_types_size, ethernet_protocols_size,
inet_protocols_size, evdev_abs_size, xlat_search, xlat_idx,
printxval_searchn_ex, printxval_searchn, printxval_search,
printxval_search_ex, printxval_indexn_ex, printxval_indexn,
printxval_index, printxval_index_ex, printxval_dispatch_ex,
printxval_dispatch): Remove.
(enum xlat_style_private_flag_bits): Remove PAF_INDEX_XLAT_SORTED_BIT
and PAF_INDEX_XLAT_VALUE_INDEXED_BIT.
(enum xlat_style_private_flag): Remove PAF_INDEX_XLAT_SORTED and
PAF_INDEX_XLAT_VALUE_INDEXED.
(print_array_ex): Remove index_xlat_size argument.
(xlookup_le): New declaration.
(printxval_ex): New macro.
* dyxlat.c (struct dyxlat): Remove used field (use xlat.size instead),
embed struct xlat, add pointer to struct xlat_data.
(MARK_END): Remove.
(dyxlat_alloc, dyxlat_free, dyxlat_get, dyxlat_add_pair): Update in
accordance with the structure changes.
* evdev.c (evdev_abs_size): Remove.
(keycode_ioctl): Use printxval instead of printxval_index.
(decode_bitset): Remove.
(decode_bitset_): Rename to decode_bitset, remove decode_nr_size and xt
arguments, call printxval instead of printxval_dispatch.
(bit_ioctl, evdev_read_ioctl): Do not pass xlat type to decode_bitset.
* fsconfig.c (SYS_FUNC(fsconfig)): Use printxval instead of
printxval_index.
* print_fields.h (PRINT_FIELD_XVAL_SORTED_SIZED,
PRINT_FIELD_XVAL_INDEX): Remove.
* nlattr.h (struct decode_nla_xlat_opts): Remove xlat_size and xt
fields.
* nlattr.c (decode_nla_meminfo): Do not pass
PAF_INDEX_XLAT_VALUE_INDEXED flag and netlink_sk_meminfo_indices size
in a print_array_ex call.
(decode_nla_xval): Call printxval_ex instead of printxval_dispatch_ex.
(decode_nla_ether_proto, decode_nla_ip_proto): Do not pass xlat_size and
xt fields in opts.
(decode_nla_flags): Remove XT_INDEXED unsupported warning.
* process.c (struct_user_offsets_data): Rename from struct_user_offsets,
change type to struct xlat_data[].
(struct_user_offsets): New xlat description.
(print_user_offset_addr): Rewrite using xlookup_le.
* util.c (print_array_ex): Remove index_xlat_size argument, simply call
printxval_ex for index printing.
* aio.c (tprint_lio_opcode): Use printxval_ex instead of
printxval_indexn_ex.
* bpf.c: Use printxval instead of printxval_index; use PRINT_FIELD_XVAL
instead of PRINT_FIELD_XVAL_INDEX.
* bpf_filter.c (print_bpf_filter_code): Use printxval instead of
printxval_index.
* ioctl.c (evdev_decode_number): Use printxval instead of
printxval_indexn.
* kvm.c (kvm_ioctl_decode_check_extension): Use printxval64 instead of
printxval_index.
(kvm_ioctl_run_attach_auxstr): Use xlookup instead of xlat_idx.
* net.c: Use printxval instead of printxval_search/printxval_index, use
printxval_ex instead of printxval_searchn_ex.
* netlink.c (get_fd_nl_family): Rewrite using xlat descriptor structure.
* netlink_packet_diag.c (decode_packet_diag_msg): Use PRINT_FIELD_XVAL
instead of PRINT_FIELD_XVAL_SORTED_SIZED.
* netlink_smc_diag.c (decode_smc_diag_shutdown): Remove ARRSZ_PAIR
wrapper.
(decode_smc_diag_fallback): Use printxval_ex instead of
printxval_search_ex.
(decode_smc_diag_msg): Use PRINT_FIELD_XVAL instead of
PRINT_FIELD_XVAL_INDEX.
* print_statfs.c (print_statfs_type): Use printxval instead of
printxval_search.
* ptrace_syscall_info.c (print_ptrace_syscall_info): Use
PRINT_FIELD_XVAL instead of PRINT_FIELD_XVAL_INDEX.
* rtnl_link.c (decode_ifla_inet6_flags, decode_ifla_inet6_agm):
Likewise.
(decode_nla_tun_type, decode_ifla_xdp_attached): Remove xlat_size,
xt fields.
(decode_ifla_inet_conf, decode_ifla_inet6_conf, decode_ifla_inet6_stats,
decode_ifla_inet6_icmp6_stats): Remove PAF_INDEX_XLAT_VALUE_INDEXED flag
and ARRSZ_PAIR wrapper in print_array_ex calls.
(decode_ifinfomsg): Use PRINT_FIELD_XVAL instead of
PRINT_FIELD_XVAL_SORTED_SIZED.
* rtnl_route.c (decode_nla_rt_proto): Use printxval instead of
printxval_search.
* sock.c (print_ifreq): Use PRINT_FIELD_XVAL instead of
PRINT_FIELD_XVAL_SORTED_SIZED.
* sockaddr.c (print_sockaddr_data_ll, print_sockaddr_data_bt,
print_sockaddr): Use printxval instead of printxval_search and
printxval_index.
* time.c (getitimer, osf_getitimer, setitimer, osf_setitimer,
printclockname): Use printxval instead of printxval_index.
(do_adjtimex): Use xlookup instead of xlat_idx.
* tests/btrfs.c: Update xlat handling, use struct xlat_data instead of
struct xlat for XLAT() arrays.
* tests/ioctl_block.c: Likewise.
* tests/ioctl_rtc.c: Likewise.
* tests/printflags.c: Likewise.
* tests/printxval.c: Likewise.
* tests/prlimit64.c: Likewise.
* tests/setrlimit.c: Likewise.
* tests/socketcall.c: Likewise.
* tests/xgetrlimit.c: Likewise.
* tests/xstatfsx.c: Likewise.
* xlat/af_packet_versions.in: Add #value_indexed.
* xlat/arp_hardware_types.in: Add #sorted.
* xlat/ax25_protocols.in: Likewise.
* xlat/bluetooth_l2_cid.in: Likewise.
* xlat/bluetooth_l2_psm.in: Likewise.
* xlat/ethernet_protocols.in: Likewise.
* xlat/evdev_ff_types.in: Likewise.
* xlat/fsmagic.in: Likewise.
* xlat/hw_breakpoint_type.in: Likewise.
* xlat/iffflags.in: Likewise.
* xlat/inet6_if_flags.in: Likewise.
* xlat/inet_protocols.in: Likewise.
* xlat/msgctl_flags.in: Likewise.
* xlat/perf_hw_cache_id.in: Likewise.
* xlat/perf_hw_cache_op_id.in: Likewise.
* xlat/perf_hw_cache_op_result_id.in: Likewise.
* xlat/perf_hw_id.in: Likewise.
* xlat/perf_sw_ids.in: Likewise.
* xlat/perf_type_id.in: Likewise.
* xlat/routing_protocols.in: Likewise.
* xlat/semctl_flags.in: Likewise.
* xlat/shmctl_flags.in: Likewise.
* xlat/smc_decl_codes.in: Likewise.
* xlat/sock_ax25_options.in: Likewise.
* xlat/sock_bluetooth_options.in: Likewise.
* xlat/sock_dccp_options.in: Likewise.
* xlat/sock_tipc_options.in: Likewise.
* xlat/socketlayers.in: Likewise.
* xlat/v4l2_control_classes.in: Likewise.
* xlat/v4l2_pix_fmts.in: Likewise.
* xlat/v4l2_sdr_fmts.in: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoNEWS: retroactively mention that -z/-Z fix addresses Debian bug #176376
Eugene Syromyatnikov [Tue, 23 Jul 2019 23:05:57 +0000 (01:05 +0200)]
NEWS: retroactively mention that -z/-Z fix addresses Debian bug #176376

5 years agoxlat/v4l2_pix_fmts.in: work around V4L2_PIX_FMT_BGRA444 value change
Eugene Syromyatnikov [Tue, 23 Jul 2019 22:32:53 +0000 (00:32 +0200)]
xlat/v4l2_pix_fmts.in: work around V4L2_PIX_FMT_BGRA444 value change

* xlat/v4l2_pix_fmts.in: Undefine V4L2_PIX_FMT_BGRA444 as it has changed
its value in Linux commit v5.2-rc5-403-g22be8233b34f.

5 years agoREADME-configure: recommend 'make -k check' instead of 'make check'
Anatoly Pugachev [Thu, 18 Jul 2019 15:02:56 +0000 (18:02 +0300)]
README-configure: recommend 'make -k check' instead of 'make check'

* maint/install.texi: Replace 'make check' with 'make -k check'.
* README-configure: Regenerate.

5 years agoGeneralise hardware address printing
Eugene Syromyatnikov [Fri, 31 Aug 2018 04:00:29 +0000 (06:00 +0200)]
Generalise hardware address printing

* defs.h [!MAX_ADDR_LEN] (MAX_ADDR_LEN): New macro.
(sprint_hwaddr): New declaration.
(print_hwaddr): New inline function, a wrapper for sprint_hwaddr.
* print_fields.h (PRINT_FIELD_HWADDR_SZ): New macro.
* print_mac.c: Include "xlat/arp_hardware_types.h" under
XLAT_MACROS_ONLY.
[!MAX_ADDR_LEN] (MAX_ADDR_LEN): Remove.
(sprint_hwaddr): New function.
* sock.c (print_ifreq) <SIOCSIFHWADDR, SIOCGIFHWADDR>: Print hardware
address using PRINT_FIELD_HWADDR_SZ.

5 years agoopen: implement sprint_open_modes using sprintflags_ex
Eugene Syromyatnikov [Fri, 31 Aug 2018 04:21:21 +0000 (06:21 +0200)]
open: implement sprint_open_modes using sprintflags_ex

* defs.h (sprintflags_ex): Add "sep" argument.
(sprintflags): Pass '\0' in "sep" argument.
* open.c (sprint_open_modes): Use sprintflags_ex for printing
open_mode_flags.
* xlat.c (sprintflags_ex): Add "sep" argument, use it as initial
separator (if not nul).

5 years agoConsistently define __NR_* constants
Dmitry V. Levin [Tue, 16 Jul 2019 17:46:47 +0000 (17:46 +0000)]
Consistently define __NR_* constants

Include <asm/unistd.h> from "scno.h", include "scno.h" instead of
<asm/unistd.h>, do not include <asm/unistd.h> where "scno.h" is already
included.

* scno.head: Include <asm/unistd.h>.
* clone.c: Include "scno.h" instead of <asm/unistd.h>.
* syscall.c: Likewise.
* tests/_newselect.c: Likewise.
* tests/accept.c: Likewise.
* tests/accept_compat.h: Likewise.
* tests/access.c: Likewise.
* tests/acct.c: Likewise.
* tests/aio.c: Likewise.
* tests/alarm.c: Likewise.
* tests/answer.c: Likewise.
* tests/attach-f-p.c: Likewise.
* tests/brk.c: Likewise.
* tests/chmod.c: Likewise.
* tests/chown.c: Likewise.
* tests/chown32.c: Likewise.
* tests/chroot.c: Likewise.
* tests/clock_adjtime.c: Likewise.
* tests/clock_nanosleep.c: Likewise.
* tests/clock_xettime.c: Likewise.
* tests/creat.c: Likewise.
* tests/delay.c: Likewise.
* tests/delete_module.c: Likewise.
* tests/dev-yy.c: Likewise.
* tests/dup2.c: Likewise.
* tests/dup3.c: Likewise.
* tests/epoll_create.c: Likewise.
* tests/epoll_create1.c: Likewise.
* tests/epoll_ctl.c: Likewise.
* tests/epoll_pwait.c: Likewise.
* tests/epoll_wait.c: Likewise.
* tests/eventfd.c: Likewise.
* tests/faccessat.c: Likewise.
* tests/fadvise64.c: Likewise.
* tests/fadvise64_64.c: Likewise.
* tests/fallocate.c: Likewise.
* tests/fanotify_init.c: Likewise.
* tests/fanotify_mark.c: Likewise.
* tests/fchdir.c: Likewise.
* tests/fchmod.c: Likewise.
* tests/fchmodat.c: Likewise.
* tests/fchown.c: Likewise.
* tests/fchown32.c: Likewise.
* tests/fchownat.c: Likewise.
* tests/fcntl.c: Likewise.
* tests/fcntl64.c: Likewise.
* tests/fdatasync.c: Likewise.
* tests/file_handle.c: Likewise.
* tests/flock.c: Likewise.
* tests/fstat.c: Likewise.
* tests/fstat64.c: Likewise.
* tests/fstatat64.c: Likewise.
* tests/fstatfs.c: Likewise.
* tests/fstatfs64.c: Likewise.
* tests/fsync.c: Likewise.
* tests/ftruncate.c: Likewise.
* tests/ftruncate64.c: Likewise.
* tests/futex.c: Likewise.
* tests/futimesat.c: Likewise.
* tests/get_mempolicy.c: Likewise.
* tests/get_sigset_size.c: Likewise.
* tests/getcpu.c: Likewise.
* tests/getcwd.c: Likewise.
* tests/getdents.c: Likewise.
* tests/getdents64.c: Likewise.
* tests/getegid32.c: Likewise.
* tests/geteuid32.c: Likewise.
* tests/getgid.c: Likewise.
* tests/getgid32.c: Likewise.
* tests/getgroups.c: Likewise.
* tests/getgroups32.c: Likewise.
* tests/getpgrp.c: Likewise.
* tests/getpid.c: Likewise.
* tests/getrandom.c: Likewise.
* tests/getresgid.c: Likewise.
* tests/getresgid32.c: Likewise.
* tests/getresuid.c: Likewise.
* tests/getresuid32.c: Likewise.
* tests/getrlimit.c: Likewise.
* tests/getrusage.c: Likewise.
* tests/gettid.c: Likewise.
* tests/getuid.c: Likewise.
* tests/getuid32.c: Likewise.
* tests/getxxid.c: Likewise.
* tests/init_module.c: Likewise.
* tests/inject-nf.c: Likewise.
* tests/inotify.c: Likewise.
* tests/inotify_init1.c: Likewise.
* tests/ioctl_inotify.c: Likewise.
* tests/ioctl_loop.c: Likewise.
* tests/ioctl_perf.c: Likewise.
* tests/ioctl_uffdio.c: Likewise.
* tests/ioperm.c: Likewise.
* tests/iopl.c: Likewise.
* tests/ioprio.c: Likewise.
* tests/ipc.c: Likewise.
* tests/ipc_msgbuf.c: Likewise.
* tests/kexec_load.c: Likewise.
* tests/keyctl.c: Likewise.
* tests/kill.c: Likewise.
* tests/ksysent.c: Likewise.
* tests/lchown.c: Likewise.
* tests/lchown32.c: Likewise.
* tests/libmmsg.c: Likewise.
* tests/libsocketcall.c: Likewise.
* tests/link.c: Likewise.
* tests/linkat.c: Likewise.
* tests/llseek.c: Likewise.
* tests/localtime.c: Likewise.
* tests/lookup_dcookie.c: Likewise.
* tests/lseek.c: Likewise.
* tests/lstat.c: Likewise.
* tests/lstat64.c: Likewise.
* tests/madvise.c: Likewise.
* tests/migrate_pages.c: Likewise.
* tests/mkdir.c: Likewise.
* tests/mkdirat.c: Likewise.
* tests/mknod.c: Likewise.
* tests/mknodat.c: Likewise.
* tests/mlock.c: Likewise.
* tests/modify_ldt.c: Likewise.
* tests/move_pages.c: Likewise.
* tests/mq_sendrecv.c: Likewise.
* tests/newfstatat.c: Likewise.
* tests/nsyscalls.c: Likewise.
* tests/old_mmap.c: Likewise.
* tests/oldfstat.c: Likewise.
* tests/oldlstat.c: Likewise.
* tests/oldselect-efault.c: Likewise.
* tests/oldselect.c: Likewise.
* tests/oldstat.c: Likewise.
* tests/open.c: Likewise.
* tests/openat.c: Likewise.
* tests/osf_utimes.c: Likewise.
* tests/pause.c: Likewise.
* tests/perf_event_open.c: Likewise.
* tests/perf_event_open_nonverbose.c: Likewise.
* tests/pipe.c: Likewise.
* tests/pipe2.c: Likewise.
* tests/poll.c: Likewise.
* tests/ppoll.c: Likewise.
* tests/prctl-arg2-intptr.c: Likewise.
* tests/prctl-dumpable.c: Likewise.
* tests/prctl-no-args.c: Likewise.
* tests/prctl-pdeathsig.c: Likewise.
* tests/prctl-seccomp-filter-v.c: Likewise.
* tests/prctl-seccomp-strict.c: Likewise.
* tests/prctl-securebits.c: Likewise.
* tests/prctl-spec-inject.c: Likewise.
* tests/prctl-tid_address.c: Likewise.
* tests/prctl-tsc.c: Likewise.
* tests/prlimit64.c: Likewise.
* tests/process_vm_readv.c: Likewise.
* tests/process_vm_writev.c: Likewise.
* tests/pselect6.c: Likewise.
* tests/ptrace.c: Likewise.
* tests/qual_inject-error-signal.c: Likewise.
* tests/qual_inject-retval.c: Likewise.
* tests/qual_inject-signal.c: Likewise.
* tests/quotactl-xfs.c: Likewise.
* tests/quotactl.c: Likewise.
* tests/read-write.c: Likewise.
* tests/readahead.c: Likewise.
* tests/readdir.c: Likewise.
* tests/readlink.c: Likewise.
* tests/readlinkat.c: Likewise.
* tests/reboot.c: Likewise.
* tests/rename.c: Likewise.
* tests/renameat.c: Likewise.
* tests/request_key.c: Likewise.
* tests/rmdir.c: Likewise.
* tests/rt_sigpending.c: Likewise.
* tests/rt_sigprocmask.c: Likewise.
* tests/rt_sigsuspend.c: Likewise.
* tests/rt_sigtimedwait.c: Likewise.
* tests/rt_tgsigqueueinfo.c: Likewise.
* tests/s390_guarded_storage.c: Likewise.
* tests/s390_pci_mmio_read_write.c: Likewise.
* tests/s390_runtime_instr.c: Likewise.
* tests/s390_sthyi.c: Likewise.
* tests/sched_get_priority_mxx.c: Likewise.
* tests/sched_rr_get_interval.c: Likewise.
* tests/sched_xetaffinity.c: Likewise.
* tests/sched_xetattr.c: Likewise.
* tests/sched_xetparam.c: Likewise.
* tests/sched_xetscheduler.c: Likewise.
* tests/sched_yield.c: Likewise.
* tests/seccomp-filter-v.c: Likewise.
* tests/seccomp-filter.c: Likewise.
* tests/seccomp-strict.c: Likewise.
* tests/seccomp_get_action_avail.c: Likewise.
* tests/select.c: Likewise.
* tests/sendfile.c: Likewise.
* tests/sendfile64.c: Likewise.
* tests/setdomainname.c: Likewise.
* tests/setfsgid.c: Likewise.
* tests/setfsgid32.c: Likewise.
* tests/setfsuid.c: Likewise.
* tests/setfsuid32.c: Likewise.
* tests/setgid.c: Likewise.
* tests/setgid32.c: Likewise.
* tests/setgroups.c: Likewise.
* tests/setgroups32.c: Likewise.
* tests/sethostname.c: Likewise.
* tests/setns.c: Likewise.
* tests/setregid.c: Likewise.
* tests/setregid32.c: Likewise.
* tests/setresgid.c: Likewise.
* tests/setresgid32.c: Likewise.
* tests/setresuid.c: Likewise.
* tests/setresuid32.c: Likewise.
* tests/setreuid.c: Likewise.
* tests/setreuid32.c: Likewise.
* tests/setrlimit.c: Likewise.
* tests/setuid.c: Likewise.
* tests/setuid32.c: Likewise.
* tests/sigaction.c: Likewise.
* tests/signal.c: Likewise.
* tests/signalfd4.c: Likewise.
* tests/sigpending.c: Likewise.
* tests/sigprocmask.c: Likewise.
* tests/sigreturn.c: Likewise.
* tests/sigsuspend.c: Likewise.
* tests/socketcall.c: Likewise.
* tests/splice.c: Likewise.
* tests/stack-fcall-3.c: Likewise.
* tests/stat.c: Likewise.
* tests/stat64.c: Likewise.
* tests/statfs.c: Likewise.
* tests/statfs64.c: Likewise.
* tests/status-none-threads.c: Likewise.
* tests/status-unfinished-threads.c: Likewise.
* tests/statx.c: Likewise.
* tests/swap.c: Likewise.
* tests/sxetmask.c: Likewise.
* tests/symlink.c: Likewise.
* tests/symlinkat.c: Likewise.
* tests/sync.c: Likewise.
* tests/sync_file_range.c: Likewise.
* tests/sync_file_range2.c: Likewise.
* tests/syslog.c: Likewise.
* tests/tee.c: Likewise.
* tests/threads-execve.c: Likewise.
* tests/time.c: Likewise.
* tests/timer_create.c: Likewise.
* tests/timer_xettime.c: Likewise.
* tests/timerfd_xettime.c: Likewise.
* tests/times-fail.c: Likewise.
* tests/times.c: Likewise.
* tests/truncate.c: Likewise.
* tests/truncate64.c: Likewise.
* tests/ugetrlimit.c: Likewise.
* tests/umount.c: Likewise.
* tests/umount2.c: Likewise.
* tests/umoven-illptr.c: Likewise.
* tests/umovestr-illptr.c: Likewise.
* tests/uname.c: Likewise.
* tests/unix-pair-send-recv.c: Likewise.
* tests/unlink.c: Likewise.
* tests/unlinkat.c: Likewise.
* tests/unshare.c: Likewise.
* tests/ustat.c: Likewise.
* tests/utime.c: Likewise.
* tests/utimensat.c: Likewise.
* tests/utimes.c: Likewise.
* tests/vhangup.c: Likewise.
* tests/vmsplice.c: Likewise.
* tests/waitid.c: Likewise.
* tests/waitpid.c: Likewise.
* tests/xet_robust_list.c: Likewise.
* tests/xet_thread_area_x86.c: Likewise.
* tests/xetitimer.c: Likewise.
* tests/xetpgid.c: Likewise.
* tests/xetpriority.c: Likewise.
* tests/xettimeofday.c: Likewise.
* strace.c: Do not include <asm/unistd.h>.
* ucopy.c: Likewise.
* tests/add_key.c: Likewise.
* tests/aio_pgetevents.c: Likewise.
* tests/bpf-obj_get_info_by_fd.c: Likewise.
* tests/bpf.c: Likewise.
* tests/copy_file_range.c: Likewise.
* tests/execveat.c: Likewise.
* tests/finit_module.c: Likewise.
* tests/fsconfig.c: Likewise.
* tests/fsmount.c: Likewise.
* tests/fsopen.c: Likewise.
* tests/fspick.c: Likewise.
* tests/getegid.c: Likewise.
* tests/geteuid.c: Likewise.
* tests/getppid.c: Likewise.
* tests/inotify_init.c: Likewise.
* tests/io_uring_enter.c: Likewise.
* tests/io_uring_register.c: Likewise.
* tests/io_uring_setup.c: Likewise.
* tests/kcmp.c: Likewise.
* tests/kern_features.c: Likewise.
* tests/kernel_version.c: Likewise.
* tests/kexec_file_load.c: Likewise.
* tests/maybe_switch_current_tcp.c: Likewise.
* tests/mbind.c: Likewise.
* tests/membarrier.c: Likewise.
* tests/memfd_create.c: Likewise.
* tests/mlock2.c: Likewise.
* tests/move_mount.c: Likewise.
* tests/open_tree.c: Likewise.
* tests/pidfd_send_signal.c: Likewise.
* tests/pkey_alloc.c: Likewise.
* tests/pkey_free.c: Likewise.
* tests/pkey_mprotect.c: Likewise.
* tests/preadv2-pwritev2.c: Likewise.
* tests/ptrace_syscall_info.c: Likewise.
* tests/remap_file_pages.c: Likewise.
* tests/renameat2.c: Likewise.
* tests/riscv_flush_icache.c: Likewise.
* tests/set_mempolicy.c: Likewise.
* tests/test_printstrn.c: Likewise.
* tests/test_ucopy.c: Likewise.
* tests/userfaultfd.c: Likewise.

5 years agoaarch64: remove syscall numbers range [1024...1079] from syscallent.h
Dmitry V. Levin [Tue, 16 Jul 2019 17:46:47 +0000 (17:46 +0000)]
aarch64: remove syscall numbers range [1024...1079] from syscallent.h

Remove support for decoding syscalls in range [1024...1079] on aarch64
as this range has never been implemented in mainline kernel releases.

* linux/aarch64/syscallent.h [1024...1079]: Remove.
* NEWS: Mention this change.

5 years agotests: skip socketcall test on arm eabi
Dmitry V. Levin [Tue, 16 Jul 2019 17:46:47 +0000 (17:46 +0000)]
tests: skip socketcall test on arm eabi

arm eabi has no socketcall even if __NR_socketcall is defined.

* tests/socketcall.c: Conditionalize on !__ARM_EABI__ along with
__NR_socketcall.

5 years agotests: robustify statx test
Dmitry V. Levin [Tue, 16 Jul 2019 17:46:47 +0000 (17:46 +0000)]
tests: robustify statx test

Do not assume that <linux/stat.h> defines struct statx.

* configure.ac (AC_CHECK_TYPES): Check for struct statx in
<linux/stat.h>.
* tests/statx.c: Conditionalize on HAVE_STRUCT_STATX along with
__NR_statx.

5 years agotests: robustify old_mmap test
Dmitry V. Levin [Tue, 16 Jul 2019 17:46:47 +0000 (17:46 +0000)]
tests: robustify old_mmap test

Do not assume that old mmap syscall is implemented in the kernel
when __NR_mmap is defined.

* tests/alarm.c (main): Print mmap return code using sprintrc,
do not invoke mprotect if mmap is not implemented.

5 years agotests: robustify alarm test
Dmitry V. Levin [Tue, 16 Jul 2019 17:46:47 +0000 (17:46 +0000)]
tests: robustify alarm test

Do not assume that alarm syscall always succeeds.

* tests/alarm.c (main): Use sprintrc.

5 years agodefs.h: add ability to pass style to printxval_index_ex macro
Eugene Syromyatnikov [Fri, 1 Mar 2019 18:31:41 +0000 (19:31 +0100)]
defs.h: add ability to pass style to printxval_index_ex macro

So it matches its name.

* defs.h (printxval_index_ex): Add style__ macro, pass it as the 5th
argument to the printxval_indexn_ex call.

5 years agotests: extend coverage of syslog tests
Bharath Vedartham [Thu, 28 Feb 2019 12:51:13 +0000 (18:21 +0530)]
tests: extend coverage of syslog tests

The current syslog test covers only those cases where the type parameter
is one of SYSLOG_ACTION_READ, SYSLOG_ACTION_READ_ALL,
SYSLOG_ACTION_READ_CLEAR as per codecov.

Add test case to cover the default case.

* tests/syslog.c (SYSLOG_ACTION_SIZE_BUFFER): New macro.
(main): Check SYSLOG_ACTION_SIZE_BUFFER decoding.

Co-Authored-by: Eugene Syromyatnikov <evgsyr@gmail.com>
5 years agoaio: assorted iocb decoder updates
Eugene Syromyatnikov [Mon, 27 Aug 2018 20:17:17 +0000 (22:17 +0200)]
aio: assorted iocb decoder updates

* xlat/aio_iocb_flags.in: New file.
* defs.h (pollflags, rwf_flags): New declarations.
* configure.ac (AC_CHECK_MEMBERS): Check for aio_flags and aio_rw_flags
fields of struct iocb.
* aio.c [HAVE_STRUCT_IOCB_AIO_FLAGS]: Include "xlat/aio_iocb_flags.h".
(AIO_RW_FLAGS_FIELD): New macro definition, defined based on the
presence of HAVE_STRUCT_IOCB_AIO_RW_FLAGS macro.
(iocb_sub): Add SUB_POLL.
(tprint_lio_opcode): Change IOCB_CMD_POLL subtype to SUB_POLL.
(print_common_flags): Conditionalize on HAVE_STRUCT_IOCB_AIO_FLAGS
instead of IOCB_FLAG_RESFD.  Print aio_flags using aio_iocb_flags xlat.
(print_iocb_header): Always print aio_data.  Print aio_rw_flags if it
is non-zero.  Print aio_reqprio based on the presence of
IOCB_FLAG_IOPRIO flag in aio_flags (use print_ioprio if it set and print
as a signed integer otherwise).
(print_iocb): Decode SUB_POLL subtype.
* tests/aio.c: Update expected output.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoioprio: add print_ioprio function
Eugene Syromyatnikov [Mon, 27 Aug 2018 20:16:17 +0000 (22:16 +0200)]
ioprio: add print_ioprio function

That respects xlat style settings.

* ioprio.c (print_ioprio): New function.
* defs.h (print_ioprio): New declaration.

5 years agotests: serialize bpf-obj_get_info_by_fd based executables
Dmitry V. Levin [Mon, 15 Jul 2019 15:54:51 +0000 (15:54 +0000)]
tests: serialize bpf-obj_get_info_by_fd based executables

Concurrent execution of many bpf-obj_get_info_by_fd based tests may
lead to a temporary resource shortage that causes them to fail with
the following error diagnostics:

BPF_MAP_CREATE failed: Operation not permitted

Avoid this issue by serializing execution of all relevant tests.

* tests/lock_file.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add lock_file.c
* tests/tests.h (lock_file_by_dirname): New prototype.
* tests/bpf-obj_get_info_by_fd.c (main): Call lock_file_by_dirname
to obtain an exclusive lock on bpf-obj_get_info_by_fd executable.

References: https://github.com/strace/strace/issues/74
References: https://github.com/strace/strace/issues/105

5 years agotests: fix build and run on alpha with fresh kernel headers
Dmitry V. Levin [Mon, 15 Jul 2019 17:11:27 +0000 (17:11 +0000)]
tests: fix build and run on alpha with fresh kernel headers

Fix tests on alpha with Linux kernel headers containing commits
v5.1-rc1~160^2~3^2~12 and v5.1-rc1~160^2~3^2~1.

* tests/getegid.c: Include "scno.h".
(main): Use sprintrc.
* tests/geteuid.c: Likewise.
* tests/getppid.c: Likewise.
* tests/getgid.c [__NR_getgid == __NR_getxgid]: Skip.
* tests/getuid.c [__NR_getuid == __NR_getxuid]: Skip.
* tests/getpid.c [__NR_getpid == __NR_getxpid]: Skip.
* tests/umount2.c (__NR_umount2): Remove.
(TEST_SYSCALL_NR): New macro.
(main): Use it instead of __NR_umount2.
* tests/ksysent.sed: Remove new __NR_get[gup]id aliases to traditional
__NR_getx[gup]id names (on alpha).
Prioritize __NR_umount over __NR_umount2, __NR_osf_shmat over __NR_shmat.
* NEWS: Mention these fixes.

5 years agocopyright-year-gen, file-date-gen: enhance error diagnostics
Dmitry V. Levin [Mon, 15 Jul 2019 12:04:48 +0000 (12:04 +0000)]
copyright-year-gen, file-date-gen: enhance error diagnostics

* copyright-year-gen: Prefix error message with the script name.
* file-date-gen: Likewise.  Bail out in case of invalid date.

5 years agoconfigure.ac: honor exit status of commands run by m4_esyscmd
Dmitry V. Levin [Mon, 15 Jul 2019 12:04:48 +0000 (12:04 +0000)]
configure.ac: honor exit status of commands run by m4_esyscmd

If the command run by m4_esyscmd exits with non-zero exit status,
autom4te shall terminate.

* m4/st_esyscmd_s.m4: New file.
* configure.ac: Replace m4_esyscmd with st_esyscmd_s.

References: https://github.com/strace/strace/issues/105

5 years agotests: test evdev bitset decoding more thoroughly
Eugene Syromyatnikov [Fri, 12 Jul 2019 12:31:44 +0000 (14:31 +0200)]
tests: test evdev bitset decoding more thoroughly

* tests/ioctl_evdev-success-v.test: Inject various values.
* tests/ioctl_evdev-success.test: Likewise.
* tests/ioctl_evdev-success.c (NUM_WORDS): New macro.
(struct evdev_check): Constify arg_ptr and print_arg args.
(invoke_test_syscall, test_evdev, print_input_absinfo, print_input_id,
print_mtslots): Add const qualifiers.
(print_getbit): Add const qualifiers, rewrite to expect trailing NULL
in the string array instead of leading string count.
(main): Set size for ev_more, ev_less, ev_zero arrays; replace leading
count element in ev_more_str, ev_less_str, ev_zero_str with trailing
NULL; replace ev_more_str and ev_less_str with ev_more_str_2/ev_less_str_2
and ev_more_str_3/ev_less_str_3 that differ by presence of flags that reside
beyond first two bytes; add static and const qualifiers where possible;
add key/key_sts_8/key_str_16 values; update a to provide either ev_more_str_2
or ev_more_str_3 and either key_str_8 or key_str_16 depending on inject_retval
value.

5 years agoevdev: fix array size calculation in decode_bitset_
Eugene Syromyatnikov [Fri, 12 Jul 2019 12:57:28 +0000 (14:57 +0200)]
evdev: fix array size calculation in decode_bitset_

max_nr is in bits (as it is a number of flags), result is in bytes, and
the array allocation has to be in personality words.

There's still an open question, however, what to do on big-endian
architectures when a non-divisible-by-4 value is returned.

* evdev.c (decode_bitset_): Declare size_bits, initialise it and use it
later instead of size; round up size by personality's word boundary.

5 years agoevdev: avoid bit vector decoding on non-successful and 0 return codes
Eugene Syromyatnikov [Fri, 12 Jul 2019 12:38:33 +0000 (14:38 +0200)]
evdev: avoid bit vector decoding on non-successful and 0 return codes

Reported by Clang.

    strace/evdev.c:157:3: note: The value 0 is assigned to 'size'
    #                size = tcp->u_rval * 8;
    #                ^~~~~~~~~~~~~~~~~~~~~~
    strace/evdev.c:158:2: warning: Declared variable-length array (VLA)
    has zero size
    #        char decoded_arg[size];
    #        ^

* evdev.c (decode_bitset_): Bail out before decoded_arg VLA definition.

5 years agofilter_qualify: export trace_set set
Chen Jingpiao [Thu, 3 May 2018 12:59:20 +0000 (20:59 +0800)]
filter_qualify: export trace_set set

In preparation for seccomp-assisted syscall filtering, export
trace_set set, which will be used to derive the BPF program.

* filter_qualify.c (trace_set): Remove static qualifier.
* number_set.h (trace_set): New declaration.

5 years agoPost-release administrivia
Dmitry V. Levin [Sat, 13 Jul 2019 11:48:01 +0000 (11:48 +0000)]
Post-release administrivia

* NEWS: Add a header line for the next release.
* debian/changelog.in: Add a changelog entry for 5.2-1.
* strace.spec.in: Likewise.

5 years agoPrepare for 5.2 release v5.2
Dmitry V. Levin [Fri, 12 Jul 2019 12:13:14 +0000 (12:13 +0000)]
Prepare for 5.2 release

* NEWS: Update for 5.2 release.

5 years agoUpdate .mailmap
Dmitry V. Levin [Fri, 12 Jul 2019 12:13:14 +0000 (12:13 +0000)]
Update .mailmap

* .mailmap: Add both email addresses of Zhibin Li to avoid duplication
in CREDITS file.

5 years agoUpdate copyright headers
Dmitry V. Levin [Thu, 11 Jul 2019 17:51:22 +0000 (17:51 +0000)]
Update copyright headers

Headers updated automatically using maint/update_copyright_years.sh
script.

5 years agomaint/update_copyright_years.sh: take all commits into account
Dmitry V. Levin [Thu, 11 Jul 2019 17:51:22 +0000 (17:51 +0000)]
maint/update_copyright_years.sh: take all commits into account

This helps to avoid accidental shrinking of copyright years range.

* maint/update_copyright_years.sh: Take all commits into account
to find copyright years of the earliest and the latest commit.

5 years agoFix preprocessor indentation
Dmitry V. Levin [Thu, 11 Jul 2019 17:51:22 +0000 (17:51 +0000)]
Fix preprocessor indentation

Indent the C preprocessor directives to reflect their nesting
using the following script:

$ cppi -l $(git grep -El '^[[:space:]]*#[[:space:]]*(if|ifdef|ifndef|elif|else|endif|define|pragma)[[:space:]]' |grep -v '\.sh$') |while read f; do
cppi < "$f" > "$f".cppi; mv "$f".cppi "$f"
done

5 years agotests: check status qualifier
Paul Chaignon [Mon, 1 Apr 2019 20:50:45 +0000 (22:50 +0200)]
tests: check status qualifier

This change adds 8 test cases for -e status with unfinished, failed,
none, successful, detached, and the whole set.  The test cases for
failed, successful, and the whole set use chdir(2).  Threaded test cases
for unfinished and none rely on a child thread execve'ing the lead
thread.  There are additional single-threaded tests for status=none and
status=unfinished.  The test case for detached interrupts strace while
attached to a sleeping process.

* tests/status.c: New file.
* tests/status-all.c: Likewise.
* tests/status-failed.c: Likewise.
* tests/status-detached.expected: Likewise.
* tests/status-none.c: Likewise.
* tests/status-none-threads.c: Likewise.
* tests/status-successful.c: Likewise.
* tests/status-unfinished-threads.c: Likewise.
* tests/status-unfinished.c: Likewise.
* tests/status-detached.test: New test.
* tests/status-none-threads.test: Likewise.
* tests/status-unfinished-threads.test: Likewise.
* tests/tests.h (test_status_chdir): New prototype.
* tests/.gitignore: Add status-all, status-failed, status-none,
status-none-threads, status-successful, status-unfinished,
and status-unfinished-threads.
* tests/gen_tests.in: Add status-all, status-failed, status-successful,
status-none, and status-unfinished.
* tests/pure_executables.list: Likewise.
* tests/Makefile.am (libtests_a_SOURCES): Add status.c.
(check_PROGRAMS): Add status-none-threads and status-unfinished-threads.
(status_none_threads_LDADD, status_unfinished_threads_LDADD): New
variables.
(MISC_TESTS): Add status-detached.test, status-none-threads.test, and
status-unfinished-threads.test.
(EXTRA_DIST): Add status-detached.expected.

Co-Authored-by: Burkhard Kohl <burkhard.kohl@intel.com>
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoImplement -e status=set option
Paul Chaignon [Sat, 15 Jun 2019 05:32:03 +0000 (07:32 +0200)]
Implement -e status=set option

The status qualifier enables filtering based on the return status of
syscalls.  -z and -Z become aliases for -e status=successful and -e
status=failed.  Staged output is only enabled when at least one status
is filtered, that is, when the set is incomplete.

* signal.c (popcount32): Move ...
* defs.h (popcount32): ... here.
(not_failing_only, failing_only): Remove.
* filter_qualify.c (status_set): New number_set variable.
(statuses): New variable for names of statuses.
(statusstr_to_uint, qualify_status): New functions.
(qual_options): Handle status qualifier.
* number_set.c (get_number_setbit, is_complete_set): New functions.
* number_set.h (is_complete_set): New prototype.
(status_t): New enumeration for statuses.
(status_set): New prototype.
* strace.1.in: Document new status qualifier.
* strace.c (not_failing_only, failing_only): Remove.
(droptcb): Handle status=detached option.
(init): Handle new status qualifier, set status_set variable on -z and -Z
options, warn on -zZ and -Zz, use is_complete_set.
(maybe_switch_tcbs): Reopen memstream after tcb switch.
(print_event_exit): Handle status=unfinished option.
* syscall.c (syscall_entering_trace): Use is_complete_set.
(syscall_exiting_trace): Use is_complete_set, handle status=unavailable
option.
* NEWS: Mention this change.

Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
5 years agoStage output for -z and -Z options
Paul Chaignon [Sat, 15 Jun 2019 05:21:44 +0000 (07:21 +0200)]
Stage output for -z and -Z options

-z and -Z options print only successful and failing syscalls respectively.
However, failure of syscall is only known after syscall return.  Thus, we
end up with something like this on, e.g., ENOENT:

  open("does_not_exist", O_RDONLY <unfinished ...>

whereas the intended result is that the open(...) line is not shown at all.

This change fixes this issue using open_memstream.  When either the -z or
the -Z option is used, the output is staged in memory (using
open_memstream) until we know the syscall return status.  If the
open_memstream function is not available, these new options error out.

Document -z and -Z options as new features since they have never worked
properly before and were undocumented since commit v4.4.95~21.

* stage_output.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* configure.ac (AC_CHECK_FUNCS): Add open_memstream.
* defs.h (struct tcb): Add real_outf, memfptr, and memfloc fields for
memstream.
(strace_open_memstream, strace_close_memstream): New prototypes.
* strace.1.in: Document -z and -Z options.
* strace.c (usage): Mention -z and -Z options.
(init): Error on -z and -Z options if open_memstream if unavailable.
(maybe_switch_tcbs): Handle switch of memstream between tcbs.
(printleader): Avoid marking staged syscalls as unfinished.
* syscall.c (syscall_entering_trace): Open memstream.
(syscall_exiting_trace): Filter failed syscalls if failing_only is set,
handle raw(tcp) case.
(print_syscall_resume): Avoid marking staged syscalls as resumed.
* NEWS: Mention this change.

Resolves: https://github.com/strace/strace/issues/49
Resolves: https://github.com/strace/strace/issues/50
Co-Authored-by: Burkhard Kohl <burkhard.kohl@intel.com>
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
5 years agoAdd -Z option to print only failing syscalls
Paul Chaignon [Mon, 1 Apr 2019 20:26:00 +0000 (22:26 +0200)]
Add -Z option to print only failing syscalls

Existing -z option prints only successful syscalls.
This change adds a -Z option to print only failing syscalls.

Both options will start to behave properly with the subsequent commit.

* strace.c (init): Handle new -Z option.
* defs.h (failing_only): New prototype.
* syscall.c (failing_only): New variable.
(syscall_exiting_trace): Ignore failed syscalls if failing_only is set.

References: https://github.com/strace/strace/issues/50
Co-Authored-by: Burkhard Kohl <burkhard.kohl@intel.com>
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
5 years agosyscall.c: rename ptrace_get_syscall_info to strace_get_syscall_info
Dmitry V. Levin [Wed, 10 Jul 2019 16:12:44 +0000 (16:12 +0000)]
syscall.c: rename ptrace_get_syscall_info to strace_get_syscall_info

... to avoid potential conflict with future glibc versions.

* syscall.c (ptrace_get_syscall_info): Rename to
strace_get_syscall_info.  All callers updated.

5 years agotests: fix build with cutting-edge glibc
Dmitry V. Levin [Wed, 10 Jul 2019 16:12:44 +0000 (16:12 +0000)]
tests: fix build with cutting-edge glibc

Fix the following compilation error:

In file included from statx.c:44:
xstatx.c:47:16: error: â€˜struct libc_statx’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]

* tests/xstatx.c (struct statx): New forward declaration.

5 years agoFix misleading stray PTRACE_EVENT_EXEC diagnostics
Dmitry V. Levin [Wed, 10 Jul 2019 16:12:44 +0000 (16:12 +0000)]
Fix misleading stray PTRACE_EVENT_EXEC diagnostics

If current_tcp is to be switched, entering(current_tcp) is irrelevant.

* strace.c (maybe_switch_tcbs): Update comment.
(dispatch_event) <case TE_STOP_BEFORE_EXECVE>: Invoke
maybe_switch_current_tcp early, skip the check for a stray
PTRACE_EVENT_EXEC if current_tcp was switched.
* tests/maybe_switch_current_tcp.c: New file.
* tests/pure_executables.list: Add maybe_switch_current_tcp.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (maybe_switch_current_tcp): New entry.
* tests/Makefile.am (maybe_switch_current_tcp_LDADD): New variable.

5 years agoRefactor maybe_switch_tcbs
Dmitry V. Levin [Wed, 10 Jul 2019 16:12:44 +0000 (16:12 +0000)]
Refactor maybe_switch_tcbs

Change maybe_switch_tcbs to return NULL when no switching is necessary.
Introduce maybe_switch_current_tcp as a thing wrapper around
maybe_switch_tcbs.

* strace.c (maybe_switch_current_tcp): New function.
(dispatch_event): Use it instead of maybe_switch_tcbs, move comments
and the os_release check before maybe_switch_tcbs invocation ...
(maybe_switch_tcbs): ... here.  Change return value to NULL
if no switching was performed.

5 years agotests: robustify strace -k tests against link-time optimizer
Dmitry V. Levin [Tue, 9 Jul 2019 19:27:58 +0000 (19:27 +0000)]
tests: robustify strace -k tests against link-time optimizer

Some distributions enable by default a link-time optimizer that
mangles stack_fcall sample executables in a way that renders them
unusable for test purposes.

Robustify tests to defeat link-time optimizer.

* tests/stack-fcall.h (f0, f1, f2, f3): Add second parameter.
* tests/stack-fcall.c (main): Pass main as the second parameter to f0.
* tests/stack-fcall-0.c (f0): Add second parameter f, pass the xor of it
and f0 to f1.
* tests/stack-fcall-1.c (f1): Add second parameter f, pass the xor of it
and f1 to f2.
* tests/stack-fcall-2.c (f2): Add second parameter f, pass the xor of it
and f2 to f3.
* tests/stack-fcall-3.c: Include <asm/unistd.h>.
(f3): Add second parameter f, invoke __NR_gettid syscall with the xor
of f and f3 as its argument.

5 years agoia64: optimize syscallent table
Eugene Syromyatnikov [Mon, 17 Sep 2018 00:59:15 +0000 (02:59 +0200)]
ia64: optimize syscallent table

Use shuffle_scno since all valid syscall numbers start from 1024.

* linux/syscallent_base_nr.h: New file.
* linux/ia64/syscallent_base_nr.h: Likewise.
* linux/ia64/shuffle_scno.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* linux/ia64/syscallent.h [SYSCALLENT_BASE_NR] (BASE_NR): Define to 0.
* syscall.c: Include "syscallent_base_nr.h".
* clone.c [IA64] (ARG_STACKSIZE, ARG_PTID, ARG_CTID, ARG_TLS): Use
shuffle_scno.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoinotify: decode file descriptor returned by inotify_init
Eugene Syromyatnikov [Mon, 24 Sep 2018 06:02:38 +0000 (08:02 +0200)]
inotify: decode file descriptor returned by inotify_init

* inotify.c (SYS_FUNC(inotify_init)): New function.
* linux/dummy.h (sys_inotify_init): Remove macro definition.
* tests/inotify_init.c: New file.
* tests/inotify_init-y.c: Likewise.
* tests/inotify_init1-y.c: Likewise.
* tests/inotify_init1.c [PRINT_PATHS]: Print inotify fd path.
* tests/inotify_init-y.test: New test.
* tests/.gitignore: Add inotify_init, inotify_init-y, inotify_init1-y.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (inotify_init, inotify_init1-y): New tests.
* tests/Makefile.am (DECODER_TESTS): Add inotify_init-y.test.

5 years agortnl_addr: decode IFA_RT_PRIORITY and IFA_TARGET_NETNSID
Eugene Syromyatnikov [Fri, 14 Dec 2018 18:53:25 +0000 (19:53 +0100)]
rtnl_addr: decode IFA_RT_PRIORITY and IFA_TARGET_NETNSID

* rtnl_addr.c (ifaddrmsg_nla_decoders): Decode IFA_RT_PRIORITY as u32,
decode IFA_TARGET_NETNSID as s32.

5 years agomips o32: print an error message when fetching of syscall arguments fails
Eugene Syromyatnikov [Fri, 26 Oct 2018 00:01:43 +0000 (02:01 +0200)]
mips o32: print an error message when fetching of syscall arguments fails

... instead of failing silently.

* linux/mips/get_syscall_args.c (get_syscall_args): Print an error message
when umoven fails.

5 years agolinux/smc_diag.h: update struct smc_diag_req definition
Eugene Syromyatnikov [Sat, 20 Oct 2018 04:34:10 +0000 (06:34 +0200)]
linux/smc_diag.h: update struct smc_diag_req definition

In accordance with Linux commit v4.19-rc8~22^2~17^2.

* linux/smc_diag.h (struct smc_diag_req): Use an anonymous union
for diag_fallback/diag_mode fields.

5 years agokvm: avoid bogus vcpu_info assignment in vcpu_register
Eugene Syromyatnikov [Tue, 18 Dec 2018 04:37:30 +0000 (05:37 +0100)]
kvm: avoid bogus vcpu_info assignment in vcpu_register

Also reformat code a bit to make nesting a bit clearer.

Reported by Clang.

* kvm.c (vcpu_register): Do not assign vcpu_alloc result to vcpu_info
as this value is not used afterwards in the function.

5 years agosync_file_range2: remove unneeded argn assignment
Eugene Syromyatnikov [Sat, 20 Oct 2018 04:42:20 +0000 (06:42 +0200)]
sync_file_range2: remove unneeded argn assignment

clang complains about it:

         argn = printllval(tcp, "%lld", argn);
         ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sync_file_range2.c:43:2: note: Value stored to 'argn' is never read

* sync_file_range2.c (SYS_FUNC(sync_file_range2)): Do not assign
printllval result to argn for the second time.

5 years agosyscall.c: avoid infinite loop in subcalls parsing
Eugene Syromyatnikov [Tue, 4 Sep 2018 12:48:13 +0000 (14:48 +0200)]
syscall.c: avoid infinite loop in subcalls parsing

clang complains about it, so it might be a good reason to refactor it
into something more linear.

* syscall.c (syscall_entering_decode): Put syscall subcall decoding
before ipc/socket subcall decoding, remove the loop.

5 years agotests: check decoding of mode argument of mbind and set_mempolicy syscalls
Dmitry V. Levin [Fri, 5 Jul 2019 11:09:37 +0000 (11:09 +0000)]
tests: check decoding of mode argument of mbind and set_mempolicy syscalls

* tests/mbind.c: Include "scno.h".
(errstr): New variable.
(k_mbind): New function.
(out_str): New macro.
(mpol_modes): New array.
(main): Use it and k_mbind.
* tests/set_mempolicy.c: Include "scno.h", do not include <errno.h>,
"xlat.h" and "xlat/mpol_modes.h".
(errstr): New variable.
(k_set_mempolicy): New function.
(out_str): New macro.
(mpol_modes): New array.
(print_nodes): Use it and k_set_mempolicy.
(main): Likewise.
* tests/mbind-Xabbrev.c: New file.
* tests/mbind-Xraw.c: Likewise.
* tests/mbind-Xverbose.c: Likewise.
* tests/set_mempolicy-Xabbrev.c: Likewise.
* tests/set_mempolicy-Xraw.c: Likewise.
* tests/set_mempolicy-Xverbose.c: Likewise.
* tests/gen_tests.in (mbind-Xabbrev, mbind-Xraw, mbind-Xverbose,
set_mempolicy-Xabbrev, set_mempolicy-Xraw, set_mempolicy-Xverbose):
New entries.
* tests/pure_executables.list: Add mbind-Xabbrev, mbind-Xraw,
mbind-Xverbose, set_mempolicy-Xabbrev, set_mempolicy-Xraw,
and set_mempolicy-Xverbose.
* tests/.gitignore: Likewise.

5 years agonuma: enhance decoding of mode argument of mbind and set_mempolicy syscalls
Dmitry V. Levin [Fri, 5 Jul 2019 11:09:37 +0000 (11:09 +0000)]
numa: enhance decoding of mode argument of mbind and set_mempolicy syscalls

Implement decoding of memory policy mode flags introduced by Linux
kernel commits v2.6.26-rc1~990 and v2.6.26-rc1~988.

* xlat/mpol_mode_flags.in: New file.
* numa.c: Include "xlat/mpol_mode_flags.h".
(print_mode): Print MPOL_MODE_FLAGS part of mode argument as flags.
* NEWS: Mention this.

5 years agonuma: factor out printing of mode argument of mbind and set_mempolicy syscalls
Dmitry V. Levin [Fri, 5 Jul 2019 11:09:37 +0000 (11:09 +0000)]
numa: factor out printing of mode argument of mbind and set_mempolicy syscalls

This printing is going to be extended by subsequent changes.

* numa.c (print_mode): New function.
(SYS_FUNC(mbind), SYS_FUNC(set_mempolicy)): Use it.

5 years agoUpdate ioctl entries from linux v5.2
Gleb Fotengauer-Malinovskiy [Thu, 4 Jul 2019 18:17:29 +0000 (21:17 +0300)]
Update ioctl entries from linux v5.2

* linux/32/ioctls_inc_align16.h: Update from linux v5.2-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.
* linux/aarch64/ioctls_arch0.h: Likewise.
* linux/arm/ioctls_arch0.h: Likewise.
* linux/mips/ioctls_arch0.h: Likewise.
* NEWS: Mention this.

5 years agosparc, sparc64: refactor arch_set_error and arch_set_success
Dmitry V. Levin [Thu, 4 Jul 2019 18:25:49 +0000 (18:25 +0000)]
sparc, sparc64: refactor arch_set_error and arch_set_success

* linux/sparc/set_error.c (sparc_set_o0_psr): New function.
(arch_set_error, arch_set_success): Use it.
* linux/sparc64/set_error.c (sparc64_set_o0_tstate): New function.
(arch_set_error, arch_set_success): Use it.

5 years agosparc, sparc64: fix syscall tampering when PTRACE_GET_SYSCALL_INFO is in use
Dmitry V. Levin [Thu, 4 Jul 2019 18:25:49 +0000 (18:25 +0000)]
sparc, sparc64: fix syscall tampering when PTRACE_GET_SYSCALL_INFO is in use

When PTRACE_GET_SYSCALL_INFO is in use on sparc, psr is not loaded,
so it has to be loaded explicitly before tampering.
Likewise, when PTRACE_GET_SYSCALL_INFO is in use on sparc64, tstate
is not loaded, so it has to be loaded explicitly before tampering.

* linux/sparc/set_error.c (arch_set_error, arch_set_success): Explicitly
call get_regs before changing psr when PTRACE_GET_SYSCALL_INFO is in use.
* linux/sparc64/set_error.c (arch_set_error, arch_set_success):
Explicitly call get_regs before changing tstate when
PTRACE_GET_SYSCALL_INFO is in use.
* NEWS: Mention this fix.

5 years agopowerpc: skip poking CCR if it is unchanged
Dmitry V. Levin [Thu, 4 Jul 2019 18:25:49 +0000 (18:25 +0000)]
powerpc: skip poking CCR if it is unchanged

* linux/powerpc/set_error.c (arch_set_r3_ccr): New function.
(arch_set_error, arch_set_success): Use it.

5 years agopowerpc: fix syscall tampering when PTRACE_GET_SYSCALL_INFO is in use
Dmitry V. Levin [Thu, 4 Jul 2019 18:25:49 +0000 (18:25 +0000)]
powerpc: fix syscall tampering when PTRACE_GET_SYSCALL_INFO is in use

When PTRACE_GET_SYSCALL_INFO is in use, CCR is not loaded, so it has
to be loaded explicitly before tampering.

* linux/powerpc/set_error.c (arch_set_error, arch_set_success):
Explicitly load CCR before changing it when PTRACE_GET_SYSCALL_INFO
is in use.
* NEWS: Mention this fix.

5 years agoxlat: rename mbindflags to mbind_flags
Dmitry V. Levin [Wed, 3 Jul 2019 18:56:13 +0000 (18:56 +0000)]
xlat: rename mbindflags to mbind_flags

The former name was not consistent with others.

* xlat/mbindflags.in: Rename to xlat/mbind_flags.in; all users updated.

5 years agoxlat: update MPOL_F_* get_mempolicy flags
Dmitry V. Levin [Wed, 3 Jul 2019 18:56:13 +0000 (18:56 +0000)]
xlat: update MPOL_F_* get_mempolicy flags

* xlat/get_mempolicy_flags.in (MPOL_F_MEMS_ALLOWED): New constant
introduced by Linux kernel v2.6.24-rc1~1212.
* NEWS: Mention this.
* tests/get_mempolicy.c (main): Update expected output.

5 years agoxlat: rename mempolicyflags to get_mempolicy_flags
Dmitry V. Levin [Wed, 3 Jul 2019 18:56:13 +0000 (18:56 +0000)]
xlat: rename mempolicyflags to get_mempolicy_flags

The former name was ambiguous.

* xlat/mempolicyflags.in: Rename to xlat/get_mempolicy_flags.in;
all users updated.

5 years agoxlat: rename policies to mpol_modes
Dmitry V. Levin [Wed, 3 Jul 2019 18:56:13 +0000 (18:56 +0000)]
xlat: rename policies to mpol_modes

The former name was too vague.

* xlat/policies.in: Rename to xlat/mpol_modes.in; all users updated.

5 years agoxlat: add MPOL_LOCAL constant
Michal Sekletar [Mon, 10 Jun 2019 21:33:56 +0000 (23:33 +0200)]
xlat: add MPOL_LOCAL constant

* xlat/policies.in (MPOL_LOCAL): New constant introduced by Linux kernel
commit v3.8-rc1~92^2~33.

Resolves: https://github.com/strace/strace/pull/102

5 years agoioctl: remove redundant _IOC_NR
Zhibin Li [Sun, 30 Jun 2019 06:03:10 +0000 (14:03 +0800)]
ioctl: remove redundant _IOC_NR

* ioctl.c (evdev_decode_number): Replace _IOC_NR(nr) with nr
as the latter is defined to _IOC_NR(code).

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agobpf: add support for new fields in BPF_PROG_TEST_RUN
Dmitry V. Levin [Tue, 2 Jul 2019 11:49:15 +0000 (11:49 +0000)]
bpf: add support for new fields in BPF_PROG_TEST_RUN

* bpf_attr.h (struct BPF_PROG_TEST_RUN_struct): Add ctx_size_in,
ctx_size_out, ctx_in, and ctx_out fields.
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_PROG_TEST_RUN)): Decode these fields
introduced by Linux kernel commit v5.2-rc1~133^2~193^2~6.
* tests/bpf.c (BPF_PROG_TEST_RUN_checks): Check it.

5 years agobpf: implement decoding of BPF_MAP_FREEZE command
Dmitry V. Levin [Tue, 2 Jul 2019 11:49:15 +0000 (11:49 +0000)]
bpf: implement decoding of BPF_MAP_FREEZE command

BPF_MAP_FREEZE command was introduced by Linux commit
v5.2-rc1~133^2~193^2~12^2~12.

* bpf_attr.h (struct BPF_MAP_FREEZE_struct): New type.
(BPF_MAP_FREEZE_struct_size, expected_BPF_MAP_FREEZE_struct_size): New
macros.
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_FREEZE)): New bpf command
decoder.
(SYS_FUNC(bpf)) <bpf_cmd_decoders[]>: Add BPF_CMD_ENTRY(BPF_MAP_FREEZE).
* NEWS: Mention this.
* tests/bpf.c (union bpf_attr_data): Add
BPF_ATTR_DATA_FIELD(BPF_MAP_FREEZE).
(BPF_MAP_FREEZE_checks): New checks array.
(main) <checks>: Add CHK(BPF_MAP_FREEZE).

5 years agoxlat: update BPF_* constants
Dmitry V. Levin [Mon, 1 Jul 2019 10:41:54 +0000 (10:41 +0000)]
xlat: update BPF_* constants

* xlat/bpf_attach_type.in (BPF_CGROUP_SYSCTL): New constant introduced
by Linux kernel commit v5.2-rc1~133^2~132^2~39^2~19.
(BPF_CGROUP_UDP4_RECVMSG, BPF_CGROUP_UDP6_RECVMSG): New constants
introduced by Linux kernel commit v5.2-rc6~33^2~44^2^2~5.
* xlat/bpf_commands.in (BPF_MAP_FREEZE): New constant introduced
by Linux kernel commit v5.2-rc1~133^2~193^2~12^2~12.
* xlat/bpf_map_flags.in (BPF_F_RDONLY_PROG, BPF_F_WRONLY_PROG): New
constants introduced by Linux kernel commit
v5.2-rc1~133^2~193^2~12^2~13.
* xlat/bpf_map_types.in (BPF_MAP_TYPE_SK_STORAGE): New constant
introduced by Linux kernel commit v5.2-rc1~133^2~80^2^2~6.
* xlat/bpf_prog_types.in (BPF_PROG_TYPE_CGROUP_SYSCTL): New constant
introduced by Linux kernel commit v5.2-rc1~133^2~132^2~39^2~19.
(BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE): New constant introduced
by Linux kernel commit v5.2-rc1~133^2~80^2~1^2~4.
* NEWS: Mention this.
* tests/bpf.c (BPF_MAP_CREATE_checks, BPF_PROG_LOAD_checks,
BPF_PROG_QUERY_checks): Update.
* tests/kernel_version.c (print_bpf_attr): Update.

5 years agoImplement decoding of fspick syscall
Dmitry V. Levin [Sat, 29 Jun 2019 17:38:25 +0000 (17:38 +0000)]
Implement decoding of fspick syscall

... introduced by Linux kernel commits v5.2-rc1~141^2~1,
v5.2-rc1~20^2~1, and v5.2-rc1~20^2.

* fspick.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* pathtrace.c (pathtrace_match_set): Add SEN_fspick.
* xlat/fspick_flags.in: New file.
* linux/syscallent-common.h [BASE_NR + 433]: Wire up fspick.
* NEWS: Mention this change.
* tests/fspick.c: New file.
* tests/fspick-P.c: Likewise.
* tests/gen_tests.in (fspick, fspick-P): New entries.
* tests/pure_executables.list: Add fspick and fspick-P.
* tests/.gitignore: Likewise.

5 years agoImplement decoding of fsmount syscall
Dmitry V. Levin [Fri, 28 Jun 2019 09:30:54 +0000 (09:30 +0000)]
Implement decoding of fsmount syscall

... introduced by Linux kernel commits v5.2-rc1~141^2~2,
v5.2-rc1~20^2~1, and v5.2-rc1~20^2.

* fsmount.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* pathtrace.c (pathtrace_match_set): Add SEN_fsmount.
* xlat/fsmount_cmds.in: New file.
* xlat/mount_attr_atime.in: Likewise.
* xlat/mount_attr_flags.in: Likewise.
* linux/syscallent-common.h [BASE_NR + 432]: Wire up fsmount.
* NEWS: Mention this change.
* tests/fsmount.c: New file.
* tests/gen_tests.in (fsmount): New entry.
* tests/pure_executables.list: Add fsmount.
* tests/.gitignore: Likewise.

5 years agoImplement decoding of fsconfig syscall
Dmitry V. Levin [Thu, 27 Jun 2019 16:51:33 +0000 (16:51 +0000)]
Implement decoding of fsconfig syscall

... introduced by Linux kernel commits v5.2-rc1~141^2~3,
v5.2-rc1~20^2~1, and v5.2-rc1~20^2.

* fsconfig.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* pathtrace.c (pathtrace_match_set): Add SEN_fsconfig.
* xlat/fsconfig_cmds.in: New file.
* linux/syscallent-common.h [BASE_NR + 431]: Wire up fsconfig.
* NEWS: Mention this change.
* tests/fsconfig.c: New file.
* tests/fsconfig-P.c: Likewise.
* tests/gen_tests.in (fsconfig, fsconfig-P): New entries.
* tests/pure_executables.list: Add fsconfig and fsconfig-P.
* tests/.gitignore: Likewise.

5 years agoprint_dirfd: do not print trailing comma
Dmitry V. Levin [Thu, 27 Jun 2019 16:51:33 +0000 (16:51 +0000)]
print_dirfd: do not print trailing comma

It was fine to print trailing comma in print_dirfd until introduction
of a syscall with the last argument being a dirfd.
Now it's time to change print_dirfd.

* open.c (print_dirfd): Do not print comma.
(SYS_FUNC(open)): Print comma after print_dirfd() invocation.
* access.c (SYS_FUNC(faccessat)): Likewise.
* chmod.c (SYS_FUNC(fchmodat)): Likewise.
* execve.c (SYS_FUNC(execveat)): Likewise.
* fanotify.c (SYS_FUNC(fanotify_mark)): Likewise.
* fchownat.c (SYS_FUNC(fchownat)): Likewise.
* file_handle.c (SYS_FUNC(name_to_handle_at)): Likewise.
* link.c (SYS_FUNC(linkat), SYS_FUNC(unlinkat), SYS_FUNC(symlinkat)):
Likewise.
* mknod.c (SYS_FUNC(mknodat)): Likewise.
* move_mount.c (SYS_FUNC(move_mount)): Likewise.
* open_tree.c (SYS_FUNC(open_tree)): Likewise.
* readlink.c (SYS_FUNC(readlinkat)): Likewise.
* renameat.c (decode_renameat): Likewise.
* stat.c (SYS_FUNC(newfstatat)): Likewise.
* stat64.c (SYS_FUNC(fstatat64)): Likewise.
* statx.c (SYS_FUNC(statx)): Likewise.
* utimes.c (SYS_FUNC(futimesat), do_utimensat): Likewise.

5 years agoImplement decoding of fsopen syscall
Dmitry V. Levin [Wed, 26 Jun 2019 08:00:39 +0000 (08:00 +0000)]
Implement decoding of fsopen syscall

... introduced by Linux kernel commits v5.2-rc1~141^2~5,
v5.2-rc1~20^2~1, and v5.2-rc1~20^2.

* fsopen.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* pathtrace.c (pathtrace_match_set): Add SEN_fsopen.
* xlat/fsopen_flags.in: New file.
* linux/syscallent-common.h [BASE_NR + 430]: Wire up fsopen.
* NEWS: Mention this change.
* tests/fsopen.c: New file.
* tests/gen_tests.in (fsopen): New entry.
* tests/pure_executables.list: Add fsopen.
* tests/.gitignore: Likewise.

5 years agoImplement decoding of move_mount syscall
Dmitry V. Levin [Tue, 25 Jun 2019 11:32:26 +0000 (11:32 +0000)]
Implement decoding of move_mount syscall

... introduced by Linux kernel commits v5.2-rc1~141^2~8,
v5.2-rc1~20^2~1, and v5.2-rc1~20^2.

* move_mount.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* pathtrace.c (pathtrace_match_set): Add SEN_move_mount.
* xlat/move_mount_flags.in: New file.
* linux/syscallent-common.h [BASE_NR + 429]: Wire up move_mount.
* NEWS: Mention this change.
* tests/move_mount.c: New file.
* tests/move_mount-P.c: Likewise.
* tests/gen_tests.in (move_mount, move_mount-P): New entries.
* tests/pure_executables.list: Add move_mount and move_mount-P.
* tests/.gitignore: Likewise.

5 years agoImplement decoding of open_tree syscall
Dmitry V. Levin [Mon, 24 Jun 2019 16:57:01 +0000 (16:57 +0000)]
Implement decoding of open_tree syscall

... introduced by Linux kernel commits v5.2-rc1~141^2~9,
v5.2-rc1~20^2~1, and v5.2-rc1~20^2.

* configure.ac (AC_CHECK_HEADERS): Add linux/mount.h.
* open_tree.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* pathtrace.c (pathtrace_match_set): Add SEN_open_tree.
* xlat/open_tree_flags.in: New file.
* linux/syscallent-common.h [BASE_NR + 428]: Wire up open_tree.
* NEWS: Mention this change.
* tests/open_tree.c: New file.
* tests/open_tree-P.c: Likewise.
* tests/gen_tests.in (open_tree, open_tree-P): New entries.
* tests/pure_executables.list: Add open_tree and open_tree-P.
* tests/.gitignore: Likewise.

5 years agoIntroduce linux/syscallent-common.h and linux/syscallent-common-32.h
Dmitry V. Levin [Wed, 26 Jun 2019 08:00:39 +0000 (08:00 +0000)]
Introduce linux/syscallent-common.h and linux/syscallent-common-32.h

These files are going to be used to define syscall entries for common
syscalls added in Linux kernel 5.1+.

* linux/syscallent-common.h: New file.
* linux/syscallent-common-32.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
(syscallent_names): Add syscallent-common.h and syscallent-common-32.h.
* linux/mips/.gitignore: Add syscallent-common-32-stub.h
and syscallent-common-stub.h.
* linux/mips/genstub.sh: Parametrize source directory.  Change syscall
name prefix to SYSCALL_NAME_PREFIX.
* configure.ac [MIPS]: Generate stubs for linux/syscallent-common.h
and linux/syscallent-common-32.h files.
* linux/mips/syscallent-n32.h [LINUX_MIPSN32]
[BASE_NR + 403..BASE_NR + 427]: Remove, include "syscallent-common-32.h"
and "syscallent-common.h" instead.
[!LINUX_MIPSN32] (SYSCALL_NAME_PREFIX): Define.
[!LINUX_MIPSN32]: Include "syscallent-common-32-sub.h"
and "syscallent-common-stub.h".
* linux/mips/syscallent-o32.h [LINUX_MIPSO32]
[BASE_NR + 403..BASE_NR + 427]: Remove, include "syscallent-common-32.h"
and "syscallent-common.h" instead.
[!LINUX_MIPSO32] (SYSCALL_NAME_PREFIX): Define.
[!LINUX_MIPSO32]: Include "syscallent-common-32-sub.h"
* linux/32/syscallent.h [403..427]: Remove, include
"syscallent-common-32.h" and "syscallent-common.h" instead.
* linux/arm/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/xtensa/syscallent.h: Likewise.
* linux/alpha/syscallent.h (BASE_NR): Define.
[534..537]: Remove, include "syscallent-common.h" instead.
* linux/ia64/syscallent.h [BASE_NR + 424..BASE_NR + 427]: Remove,
include "syscallent-common.h" instead.
* linux/mips/syscallent-n64.h [LINUX_MIPSN64]: Likewise.
[!LINUX_MIPSN64] (SYSCALL_NAME_PREFIX): Define.
[!LINUX_MIPSN64]: Include "syscallent-common-stub.h".
* linux/64/syscallent.h [424..427]: Remove, include
"syscallent-common.h" instead.
* linux/powerpc64/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.

5 years agoia64: introduce BASE_NR to syscallent initializers
Dmitry V. Levin [Wed, 26 Jun 2019 08:00:39 +0000 (08:00 +0000)]
ia64: introduce BASE_NR to syscallent initializers

* linux/ia64/syscallent.h (BASE_NR): New macro.  Use it instead of 1024.

5 years agomips: refactor syscallent initializers
Dmitry V. Levin [Wed, 26 Jun 2019 08:00:39 +0000 (08:00 +0000)]
mips: refactor syscallent initializers

Change format of designated initializers to BASE_NR + offset.

* linux/mips/syscallent-n32.h (BASE_NR): New macro.  Use it in designated
initializers.
* linux/mips/syscallent-n64.h: Likewise.
* linux/mips/syscallent-o32.h: Likewise.

5 years agoxlat: update AT_* constants
Dmitry V. Levin [Mon, 24 Jun 2019 16:57:01 +0000 (16:57 +0000)]
xlat: update AT_* constants

* xlat/at_flags.in (AT_RECURSIVE): New constant introduced
by Linux kernel commit v5.2-rc1~141^2~9.
* NEWS: Mention this.
* tests/linkat.c: Update expected output.
* tests/unlinkat.c: Update expected output.
* tests/utimensat.c: Update expected output.
* tests/xstatx.c: Update expected output.

5 years agotravis: Move fastest test configuration first
Paul Chaignon [Fri, 28 Jun 2019 15:51:42 +0000 (17:51 +0200)]
travis: Move fastest test configuration first

I use Travis CI to check each patch before sending my patchsets.  Most
failures are simple and make all test configurations fail.  However, since
Travis CI runs test configurations in order and given that the first three
configurations are the slowest ones, it takes about twenty minutes to see
the failure.  Moving the fastest test configuration first would allow to
fail earlier.  It would become about 3x faster to fail in case of simple
mistakes.

* .travis.yml (CC=gcc, STACKTRACE=no): Move to first position.

Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>