]> granicus.if.org Git - strace/log
strace
6 years agotests: check decoding of successful PERF_EVENT_IOC_{ID,QUERY_BPF} ioctls
Eugene Syromyatnikov [Mon, 28 May 2018 17:34:50 +0000 (19:34 +0200)]
tests: check decoding of successful PERF_EVENT_IOC_{ID,QUERY_BPF} ioctls

As these have some argument output on the exit path.

* tests/ioctl_perf-success.c: New file.
* tests/ioctl_perf-success.test: New test.
* tests/Makefile.am (DECODER_TESTS): Add it.
(check_PROGRAMS): Add ioctl_perf-success.
* tests/.gitignore: Likewise.
* tests/ioctl_perf.c: Remove TODO.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoImplement PERF_EVENT_IOC_* decoding
Eugene Syromyatnikov [Tue, 15 May 2018 16:45:28 +0000 (18:45 +0200)]
Implement PERF_EVENT_IOC_* decoding

* perf.c (fetch_perf_event_attr, print_perf_event_attr): Remove "static"
qualifier.
* defs.h (fetch_perf_event_attr, print_perf_event_attr): New
declarations.
* perf_event_struct.h (struct perf_event_query_bpf): New type
definition.
* perf_ioctl.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/perf_ioctl_cmds.in: New file.
* xlat/perf_ioctl_flags.in: Likewise.
* ioctl.c (ioctl_decode) <case '$'>: Call perf_ioctl.
* tests/gen_tests.in (ioctl_perf): New test.
* tests/ioctl_perf.c: New file.
* tests/pure_executables.list: ioctl_perf.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: fix ipc_msgbuf.test
Dmitry V. Levin [Mon, 28 May 2018 17:34:50 +0000 (17:34 +0000)]
tests: fix ipc_msgbuf.test

* tests/ipc_msgbuf.test: Fix -a argument.

6 years agoxlat: update IPPROTO_* constants
Eugene Syromyatnikov [Wed, 23 May 2018 14:16:34 +0000 (16:16 +0200)]
xlat: update IPPROTO_* constants

* xlat/inet_protocols.in (IPPROTO_GGP, IPPROTO_HELLO, IPPROTO_ND):
Remove, not defined in Linux.
(IPPROTO_BEETPH): New constant, introduced by Linux commit
v2.6.19-rc1~33^2.
(IPPROTO_L2TP): New constant, introduced by Linux commit
v2.6.35-rc1~473^2~594.
(IPPROTO_MH): New constant, introduced by Linux commit
v2.6.19-rc1~1272^2~157.
Add default values to constants, sort the file.

6 years agoxlat: add fallback definitions to RTPROT_* constants
Eugene Syromyatnikov [Wed, 23 May 2018 13:39:25 +0000 (15:39 +0200)]
xlat: add fallback definitions to RTPROT_* constants

* xlat/routing_protocols.in: Add default values to constants.

6 years agoxlat: add SECCOMP_FILTER_FLAG_SPEC_ALLOW
Eugene Syromyatnikov [Wed, 23 May 2018 10:24:05 +0000 (12:24 +0200)]
xlat: add SECCOMP_FILTER_FLAG_SPEC_ALLOW

* xlat/seccomp_filter_flags.in (SECCOMP_FILTER_FLAG_SPEC_ALLOW): New
constant, introduced by Linux commit v4.17-rc3-24-g00a02d0.
* tests/seccomp-filter.c: Update expected output.
* tests/seccomp-filter-v.c: Likewise.

6 years agoprctl: add PR_GET_SPECULATION_CTRL/PR_SET_SPECULATION_CTRL decoding
Eugene Syromyatnikov [Tue, 22 May 2018 17:13:30 +0000 (19:13 +0200)]
prctl: add PR_GET_SPECULATION_CTRL/PR_SET_SPECULATION_CTRL decoding

* xlat/pr_spec_cmds.in: New fille.
* xlat/pr_spec_get_store_bypass_flags.in: Likewise.
* xlat/pr_spec_set_store_bypass_flags.in: Likewise.
* xlat/prctl_options.in (PR_GET_SPECULATION_CTRL,
PR_SET_SPECULATION_CTRL): New constants, introduced by Linux commit
v4.17-rc3-15-gb617cfc.
* prctl.c (SYS_FUNC(prctl)) <case PR_GET_SPECULATION_CTRL,
case PR_SET_SPECULATION_CTRL>: Implement decoding of new prctl options.
* tests/Makefile.am (check_PROGRAMS): Add prctl-spec-inject.
(DECODER_TESTS): Add prctl-spec-inject.test.
* tests/prctl-spec-inject.c: New file.
* tests/prctl-spec-inject.test: New test.
* tests/.gitignore: Add prctl-spec-inject.

6 years agotests: add keyctl variants with different xlat verbosity levels
Eugene Syromyatnikov [Mon, 21 May 2018 01:50:16 +0000 (03:50 +0200)]
tests: add keyctl variants with different xlat verbosity levels

* tests/keyctl-Xabbrev.c: New file.
* tests/keyctl-Xraw.c: Likewise.
* tests/keyctl-Xverbose.c: Likewise.
* tests/keyctl.c (XARG_STR): New macro.
(do_keyctl): Print command in accordance with XLAT_RAW/XLAT_VERBOSE settings.
(main): Update expected output.
* tests/pure_executables.list: Add keyctl-Xabbrev, keyctl-Xraw,
and keyctl-Xverbose.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (keyctl-Xabbrev, keyctl-Xraw, keyctl-Xverbose): New
tests.

6 years agokeyctl: print KEYCTL_SET_REQKEY_KEYRING argument as an integer
Eugene Syromyatnikov [Mon, 21 May 2018 01:46:48 +0000 (03:46 +0200)]
keyctl: print KEYCTL_SET_REQKEY_KEYRING argument as an integer

* xlat/key_reqkeys.in: Add #val_type int.
* keyctl.c (SYS_FUNC(keyctl)) <case KEYCTL_SET_REQKEY_KEYRING>: Print
arg2 as an integer.
* tests/keyctl.c: Update expected output.

6 years agokeyctl: respect xlat style when printing errno
Eugene Syromyatnikov [Mon, 21 May 2018 00:33:33 +0000 (02:33 +0200)]
keyctl: respect xlat style when printing errno

* keyctl.c (keyctl_reject_key): Use print_xlat_ex for printing error
argument.

6 years agosyscall.c: unify error value printing
Eugene Syromyatnikov [Mon, 21 May 2018 00:47:18 +0000 (02:47 +0200)]
syscall.c: unify error value printing

There's little reason not to decode error code for syscalls printed in
raw; moreover, it creates inconsistencies for unknown syscall printing.

Another issue was with error numbers unknown to strace: previously, they
were printed as "... = -1 1234 (Unknown error 1234)" which looked kinda
weird.

* syscall.c (print_err_ret): New function.
(syscall_exiting_trace): Remove u_error variable, use tcp->u_error
instead. Remove u_error_str variable.
(syscall_exiting_trace) <if (raw(tcp))>: Call print_err_ret if u_error
is non-zero.
(syscall_exiting_trace) <if (!(sys_res & RVAL_NONE) && tcp->u_error)>:
Use print_err_ret for default error printing.
* tests/nsyscalls.c [!LINUX_MIPSO32] (test_syscall): Update expected
output.
* tests/qual_fault.c (invoke) <if (is_raw)>: Likewise.
* strace.1.in (.SH DESCIPTION): Update unknown syscall example.

6 years agoioctl: implement INOTIFY_IOC_SETNEXTWD decoding
Eugene Syromyatnikov [Fri, 18 May 2018 17:16:17 +0000 (19:16 +0200)]
ioctl: implement INOTIFY_IOC_SETNEXTWD decoding

* inotify_ioctl.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (DECL_IOCTL(inotify)): New declaration.
* ioctl.c (ioctl_decode) <case 'I'>: Call inotify_ioctl.
* tests/ioctl_inotify.c: New file.
* tests/.gitignore: Add ioctl_inotify.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (ioctl_inotify): New test.

6 years agotests/test_nlattr.h: avoid testing cropped objects of size 1
Eugene Syromyatnikov [Wed, 23 May 2018 16:45:43 +0000 (18:45 +0200)]
tests/test_nlattr.h: avoid testing cropped objects of size 1

* tests/test_nlattr.h (TEST_NLATTR_OBJECT_EX_): Check
"len < sizeof(obj_)" case only if "sizeof(obj_) > 1".

6 years agotests: pass index to print_elem_ callback in TEST_NLATTR_ARRAY
Eugene Syromyatnikov [Thu, 10 May 2018 16:26:37 +0000 (18:26 +0200)]
tests: pass index to print_elem_ callback in TEST_NLATTR_ARRAY

* tests/test_nlattr.h (TEST_NLATTR_ARRAY): Pass array index to the
print_elem_ callback.
* tests/nlattr_inet_diag_msg.c (print_uint): Add index argument.
* tests/nlattr_netlink_diag_msg.c (print_xlong): Likewise.
* tests/nlattr_packet_diag_msg.c (print_packet_diag_mclist,
print_sock_filter): Likewise.
* tests/nlattr_unix_diag_msg.c (print_uint): Likewise.

6 years agotests: further cleanup bpf big address checks
Dmitry V. Levin [Thu, 24 May 2018 12:23:39 +0000 (12:23 +0000)]
tests: further cleanup bpf big address checks

Replace BIG_ADDR_IS_64BIT and BIG_ADDR_IS_32BIT with BIG_ADDR().

* tests/bpf.c (BIG_ADDR): New macro.
(BIG_ADDR_IS_64BIT, BIG_ADDR_IS_32BIT): Remove.
(BPF_PROG_LOAD_checks, BPF_OBJ_PIN_checks,
BPF_RAW_TRACEPOINT_OPEN_checks): Use BIG_ADDR() instead of
BIG_ADDR_IS_64BIT and BIG_ADDR_IS_32BIT.

6 years agotests: cleanup bpf big address checks
Dmitry V. Levin [Wed, 23 May 2018 23:27:43 +0000 (23:27 +0000)]
tests: cleanup bpf big address checks

Introduce BIG_ADDR_IS_64BIT and BIG_ADDR_IS_32BIT to reduce redundancy.

* tests/bpf.c (BIG_ADDR_IS_64BIT, BIG_ADDR_IS_32BIT): New macros.
(BPF_PROG_LOAD_checks, BPF_OBJ_PIN_checks,
BPF_RAW_TRACEPOINT_OPEN_checks): Use them.

6 years agobpf: add support for BPF_RAW_TRACEPOINT_OPEN command decoding
Eugene Syromyatnikov [Tue, 15 May 2018 13:38:54 +0000 (15:38 +0200)]
bpf: add support for BPF_RAW_TRACEPOINT_OPEN command decoding

* bpf_attr.h (struct BPF_RAW_TRACEPOINT_OPEN_struct): New type
definition.
(BPF_RAW_TRACEPOINT_OPEN_struct_size,
expected_BPF_RAW_TRACEPOINT_OPEN_struct_size): New macros.
* xlat/bpf_commands.in (BPF_RAW_TRACEPOINT_OPEN): New constant,
introduced by Linux commit v4.17-rc1~148^2~19^2~4^2~3.
* xlat/bpf_prog_types.in (BPF_PROG_TYPE_RAW_TRACEPOINT): Likewise.
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_RAW_TRACEPOINT_OPEN)): New bpf
command decoder.
(SYS_FUNC(bpf)) <bpf_cmd_decoders[]>: Add
BPF_CMD_ENTRY(BPF_RAW_TRACEPOINT_OPEN).
* tests/bpf.c (union bpf_attr_data): Add
BPF_ATTR_DATA_FIELD(BPF_RAW_TRACEPOINT_OPEN).
(BPF_PROG_LOAD_checks): Update.
(init_BPF_RAW_TRACEPOINT_attr2): New function.
(BPF_RAW_TRACEPOINT_OPEN_checks): New checks array.
(main) <checks>: Add CHK(BPF_RAW_TRACEPOINT_OPEN).

6 years agobpf: add support for decoding struct bpf_attr.expected_attach_type field
Eugene Syromyatnikov [Tue, 15 May 2018 12:19:01 +0000 (14:19 +0200)]
bpf: add support for decoding struct bpf_attr.expected_attach_type field

* bpf_attr.h (struct BPF_PROG_LOAD_struct): Add expected_attach_type
field.
(BPF_PROG_LOAD_struct_size): Update to offsetofend of
expected_attach_type field.
(expected_BPF_PROG_LOAD_struct_size): Update to 72.
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)): Decode
expected_attach_type field.
* tests/bpf.c: Update expected output.

6 years agonlattr: do not assume that SK_MEMINFO_VARS is constant
Eugene Syromyatnikov [Thu, 10 May 2018 17:37:29 +0000 (19:37 +0200)]
nlattr: do not assume that SK_MEMINFO_VARS is constant

SK_MEMINFO_VARS changes over time (as it was in Linux commit
v4.7-rc1~154^2~354^2~4, for example), so we cannot use it
for sanity checks.

* nlattr.c (print_meminfo): Remove.
(decode_nla_meminfo): Use generic print_uint32_array_member element
printer callback.
* tests/nlattr_inet_diag_msg.c (main): Update expected output.

6 years agoIntroduce print_uint32_array_member helper function
Eugene Syromyatnikov [Thu, 10 May 2018 17:35:46 +0000 (19:35 +0200)]
Introduce print_uint32_array_member helper function

Analogous to print_int32_array_member, this helper is going to be used
in various decoders, including BPF_PROG_QUERY, PERF_EVENT_IOC_*,
and netlink meminfo.

* defs.h (print_uint32_array_member): New declaration.
* util.c (print_uint32_array_member): New function.

6 years agoIntroduce print_int32_array_member helper function
Eugene Syromyatnikov [Mon, 7 May 2018 06:04:21 +0000 (08:04 +0200)]
Introduce print_int32_array_member helper function

Analogous to print_uint64_array_member, this helper is going to be used
for IFLA_AF_SPEC decoding.

* defs.h (print_int32_array_member): New declaration.
* util.c (print_int32_array_member): New function.

6 years agodefs.h: move print_uint64_array_member and print_array declarations down
Eugene Syromyatnikov [Mon, 7 May 2018 06:03:15 +0000 (08:03 +0200)]
defs.h: move print_uint64_array_member and print_array declarations down

In preparation for the forthcoming changes.

6 years agotests/test_nlattr.h: fix pointer calculation in TEST_NLATTR_ARRAY
Eugene Syromyatnikov [Thu, 10 May 2018 17:33:52 +0000 (19:33 +0200)]
tests/test_nlattr.h: fix pointer calculation in TEST_NLATTR_ARRAY

The old code works only when an array contains exactly two items.

* tests/test_nlattr.h (TEST_NLATTR_ARRAY): Fix pointer address
for the case of incomplete read.

6 years agosockaddr: add support for sockaddr_l2 without l2_bdaddr_type
Eugene Syromyatnikov [Tue, 8 May 2018 15:46:33 +0000 (17:46 +0200)]
sockaddr: add support for sockaddr_l2 without l2_bdaddr_type

Apparently, struct sockaddr_l2 changed over time: the l2_bdaddr_type
field was added only by commit v3.5-rc1~35^2~3^2~18^2^2~39.

* configure.ac (AC_CHECK_HEADERS): Move bluetooth/bluetooth.h check into
a separate check.
(AC_CHECK_HEADERS([bluetooth/bluetooth.h])): New check, also checks for
struct sockaddr_l2.l2_bdaddr_type member in case of success.
* sockaddr.c (print_sockaddr_data_bt) <case offsetof(struct sockaddr_l2,
l2_bdaddr_type)>: Add to sizeof(struct sockaddr_l2) case. Print
l2_bdaddr_type field only if the provided sockaddr is big enough.
* tests/net-sockaddr.c (check_l2): Put l2_bdaddr_type usage/printing
under HAVE_STRUCT_SOCKADDR_L2_L2_BDADDR_TYPE ifdef, add a check for the
sockaddr_l2 structure without the l2_bdaddr_type field.

6 years agosock: guess ifr_hwaddr size in SIOCSIFHWADDR/SIOCGIFHWADDR
Eugene Syromyatnikov [Mon, 7 May 2018 06:34:44 +0000 (08:34 +0200)]
sock: guess ifr_hwaddr size in SIOCSIFHWADDR/SIOCGIFHWADDR

And make the output more structured.

* sock.c: Include xlat/arp_hardware_types.h in XLAT_MACROS_ONLY mode.
(print_ifreq) <case SIOCSIFHWADDR, case SIOCGIFHWADDR>: Introduce
hwaddr_sizes array, print ifr_hwaddr.sa_family, print ifr_hwaddr.sa_data
using hwaddr_sizes and PRINT_FIELD_MAC_SZ.

6 years agoSimplify errnoent and signalent
Dmitry V. Levin [Tue, 22 May 2018 01:08:31 +0000 (01:08 +0000)]
Simplify errnoent and signalent

Remove personality support for errnoent and signalent as
there is nothing personality-specific in these files.

* linux/aarch64/errnoent1.h: Remove.
* linux/aarch64/signalent1.h: Likewise.
* linux/powerpc64/errnoent1.h: Likewise.
* linux/powerpc64/signalent1.h: Likewise.
* linux/riscv/errnoent1.h: Likewise.
* linux/riscv/signalent1.h: Likewise.
* linux/s390x/errnoent1.h: Likewise.
* linux/s390x/signalent1.h: Likewise.
* linux/sparc64/errnoent1.h: Likewise.
* linux/sparc64/signalent1.h: Likewise.
* linux/tile/errnoent1.h: Likewise.
* linux/tile/signalent1.h: Likewise.
* linux/x32/errnoent1.h: Likewise.
* linux/x32/signalent1.h: Likewise.
* linux/x86_64/errnoent1.h: Likewise.
* linux/x86_64/errnoent2.h: Likewise.
* linux/x86_64/signalent1.h: Likewise.
* linux/x86_64/signalent2.h: Likewise.
* Makefile.am (EXTRA_DIST): Remove them.
* defs.h (errnoent0): Rename to errnoent.
(signalent0): Rename signalent.
(nerrnos, nsignals): Change to const variables unconditionally.
* syscall.c (errnoent0): Rename to errnoent.
(signalent0): Rename signalent.
(nerrnos, nsignals): Change to const variables unconditionally.
(nerrnos0, nsignals0): Remove.
[SUPPORTED_PERSONALITIES > 1] (errnoent1, signalent1, nerrnos1,
nsignals1): Remove.
[SUPPORTED_PERSONALITIES > 2] (errnoent2, signalent2, nerrnos2,
nsignals2): Likewise.
(set_personality): Do not assign errnoent, signalent, nerrnos,
and nsignals.

6 years agostrace.1.in: mention -Xraw in -eraw description
Eugene Syromyatnikov [Mon, 21 May 2018 01:43:40 +0000 (03:43 +0200)]
strace.1.in: mention -Xraw in -eraw description

* strace.1.in (\fB\-e\ raw\fR=\,\fIset\fR): Mention -X raw.

6 years agostrace.1.in: display -k option description only if it is enabled
Eugene Syromyatnikov [Sun, 20 May 2018 20:23:03 +0000 (22:23 +0200)]
strace.1.in: display -k option description only if it is enabled

Leverage the fact that manpage is generated and add condition statements
around mentions of -k option.

* strace.1.in (.SH SYNOPSIS): Put option list inside an
".if '@ENABLE_STACKTRACE_TRUE@'#' .ig end_unwind_opt ... .end_unwind_opt"
condition; add a second list of options without -k and put it inside
".if '@ENABLE_STACKTRACE_FALSE@'#' .ig end_no_unwind_opt ... .end_no_unwind_opt"
condition.
(.SS Output format) <-k>: Put it inside
".if '@ENABLE_STACKTRACE_TRUE@'#' .ig end_unwind ... .end_unwind"
condition, remove the mention of --enable-stacktrace configuration
option requirement.

6 years agostrace.1.in: format a reference to "open" syscall using bold font
Eugene Syromyatnikov [Sun, 20 May 2018 20:22:13 +0000 (22:22 +0200)]
strace.1.in: format a reference to "open" syscall using bold font

* strace.1.in (.SH DESCRIPTION): Format a reference to "open" syscall
using bold font.

6 years agotests/qual_fault.test: add -efu arguments to the interpreter
Eugene Syromyatnikov [Mon, 21 May 2018 00:37:09 +0000 (02:37 +0200)]
tests/qual_fault.test: add -efu arguments to the interpreter

* tests/qual_fault.test (#!/bin/sh): Add -efu arguments.

6 years agotests/qual_fault.test: swap expected/output files in match_diff calls
Eugene Syromyatnikov [Mon, 21 May 2018 00:35:45 +0000 (02:35 +0200)]
tests/qual_fault.test: swap expected/output files in match_diff calls

match_diff expects the first argument as strace output and the second
argument as expected output.

* tests/qual_fault.test (check_fault_injection): Swap arguments
in match_diff calls.

6 years agodefs.h: convert some macro wrappers into static inline functions
Dmitry V. Levin [Mon, 21 May 2018 11:02:54 +0000 (11:02 +0000)]
defs.h: convert some macro wrappers into static inline functions

* defs.h (pathtrace_select, pathtrace_match, printxval_searchn,
printxval_indexn, sprintxval, sprintflags, printnum_slong,
printnum_ulong, printnum_ptr, printnum_kptr): Convert macro wrappers
into static inline functions.

6 years agoxlat: add support for xlat_styles in printxval_dispatch
Eugene Syromyatnikov [Mon, 7 May 2018 05:24:56 +0000 (07:24 +0200)]
xlat: add support for xlat_styles in printxval_dispatch

* defs.h (printxval_dispatch_ex): Rename from printxval_dispatch, add
style argument.
(printxval_dispatch): New static inline function, a thin wrapper around
printxval_dispatch_ex.
* xlat.c (printxval_dispatch): Rename to printxval_dispatch_ex, add
style argument, handle it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoMake printxval_dispatch publicly available
Eugene Syromyatnikov [Mon, 7 May 2018 05:22:05 +0000 (07:22 +0200)]
Make printxval_dispatch publicly available

* evdev.c (enum xlat_type, printxval_dispatch): Move elsewhere.
* defs.h (enum_xlat_type): Move from evdev.c.
(printxval_dispatch): New declaration.
* xlat.c (printxval_dispatch): Move from evdev.c, drop static qualifier.

6 years agoRevert "evdev: remove XT_NORMAL"
Eugene Syromyatnikov [Mon, 7 May 2018 05:17:29 +0000 (07:17 +0200)]
Revert "evdev: remove XT_NORMAL"

This reverts commit cc52da10c6f13feba577a83088f34916c6350165
in preparation for printxval_dispatch generalisation.

* evdev.c (enum xlat_type): Add XT_NORMAL back.
(printxval_dispatch): Handle XT_NORMAL again.

6 years agodefs.h: introduce is_bigendian macro
Eugene Syromyatnikov [Mon, 7 May 2018 05:13:54 +0000 (07:13 +0200)]
defs.h: introduce is_bigendian macro

This macro is going to be used in inline checks.

* defs.h (is_bigendian): New macro constant.

6 years agoutil.c: make memory allocation error messages more informative
Eugene Syromyatnikov [Mon, 9 Apr 2018 15:14:40 +0000 (17:14 +0200)]
util.c: make memory allocation error messages more informative

As those are pretty unusual, let's add some additional information
that can be reported by users.

* util.c (print_quoted_string_ex, dumpstr): Add reasons for memory
allocation errors.
(sizeof_iov): Change type from size_t to unsigned int.
(dumpiov_upto): Rewrite size initialisation similarly to the way it's
done in print_quoted_string_ex, add reasons for memory allocation errors.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agostrace.1.in: fix -A description
Eugene Syromyatnikov [Wed, 16 May 2018 22:56:03 +0000 (00:56 +0200)]
strace.1.in: fix -A description

* strace.1.in (.SS Output format) <-A>: Add missing .B.

6 years agostrace.1.in: document x32 64-bit syscall peculiarity
Eugene Syromyatnikov [Wed, 16 May 2018 18:19:50 +0000 (20:19 +0200)]
strace.1.in: document x32 64-bit syscall peculiarity

* strace.1.in (.SH NOTES): Document "#64" suffix for 64-bit syscalls on
x32.

6 years agolinux/x32/syscallent.h: change 64-bit syscall designation
Eugene Syromyatnikov [Wed, 16 May 2018 02:28:15 +0000 (04:28 +0200)]
linux/x32/syscallent.h: change 64-bit syscall designation

The current way of designation of 64-bit specific syscalls in x32
personality not only conflicts with fault injection specification
syntax, but also makes it impossible to specify such syscalls at all
(since everything that starts from a digit is considered a syscall
number specification).  So, let's change prefix to suffix and use
octothorpe instead of colon as a separator.

* linux/x32/syscallent.h (13, 15, 16, 19, 20, 45, 46, 47, 54, 55, 59,
101, 127, 128. 129, 131, 134, 156, 174, 177, 178, 180, 205, 206, 209,
211, 214, 215, 222, 236, 244, 246, 247, 273, 274, 278, 279, 295, 296,
297, 299, 307, 310, 311, 32, 327, 328): Change "64:" prefix to "#64"
suffix in syscall name.

Closes: https://github.com/strace/strace/issues/36
6 years agoxlat: add BPF_PROG_TYPE_SK_MSG
Eugene Syromyatnikov [Tue, 15 May 2018 12:32:11 +0000 (14:32 +0200)]
xlat: add BPF_PROG_TYPE_SK_MSG

* xlat/bpf_prog_types.in (BPF_PROG_TYPE_SK_MSG): New constant,
introduced by Linux commit v4.17-rc1~148^2~156^2~1^2~13.
* tests/bpf.c (BPF_PROG_LOAD_checks): Update expected output.

6 years agoxlat: update bpf_attach_type constants
Eugene Syromyatnikov [Tue, 15 May 2018 12:04:11 +0000 (14:04 +0200)]
xlat: update bpf_attach_type constants

* xlat/bpf_attach_type.in (BPF_SK_MSG_VERDICT): New constant,
introduced by Linux commit v4.17-rc1~148^2~156^2~1^2~13.
(BPF_CGROUP_INET4_BIND, BPF_CGROUP_INET6_BIND): New constants,
introduced by Linux commit v4.17-rc1~148^2~19^2^2~6.
(BPF_CGROUP_INET4_CONNECT, BPF_CGROUP_INET6_CONNECT): New constants,
introduced by Linux commit v4.17-rc1~148^2~19^2^2~3.
(BPF_CGROUP_INET4_POST_BIND, BPF_CGROUP_INET6_POST_BIND): New constants,
introduced by Linux commit v4.17-rc1~148^2~19^2^2~1.
* tests/bpf.c (BPF_PROG_QUERY_checks): Update expected output.

6 years agoxlat/sock_rds_options.in: make it sorted
Eugene Syromyatnikov [Wed, 9 May 2018 12:04:43 +0000 (14:04 +0200)]
xlat/sock_rds_options.in: make it sorted

Define SO_TIMESTAMP twice, for PA-RISC and all the other architectures.

* xlat/sock_rds_options.in [!__hppa__] (SO_TIMESTAMP): Define to 29.
[__hppa__] (SO_TIMESTAMP): Define to 0x4012.
* net.c (print_sockopt_fd_level_name) <case SOL_RDS>: Use
printxval_search instead of printxval.

6 years agoUpdate ioctl entries from linux v4.17
Gleb Fotengauer-Malinovskiy [Wed, 16 May 2018 17:54:59 +0000 (20:54 +0300)]
Update ioctl entries from linux v4.17

* linux/32/ioctls_inc_align16.h: Update from linux v4.17-rc5
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/i386/ioctls_arch0.h: Likewise.
* linux/x86_64/ioctls_arch0.h: Likewise.
* NEWS: Mention this.

6 years agomaint: update for linux 4.17-rc5
Gleb Fotengauer-Malinovskiy [Wed, 16 May 2018 17:15:54 +0000 (20:15 +0300)]
maint: update for linux 4.17-rc5

* maint/ioctls_sym.sh: (x86_list): Add KVM_HYPERV_EVENTFD.

6 years agobpf: use indexed lookups where appropriate
Dmitry V. Levin [Wed, 16 May 2018 10:58:32 +0000 (10:58 +0000)]
bpf: use indexed lookups where appropriate

* xlat/bpf_attach_type.in: Add "#value_indexed" directive.
* xlat/bpf_class.in: Likewise.
* xlat/bpf_map_types.in: Likewise.
* xlat/bpf_map_update_elem_flags.in: Likewise.
* xlat/bpf_prog_types.in: Likewise.
* xlat/ebpf_class.in: Likewise.
* bpf_filter.c (print_bpf_filter_code): Use printxval_index
instead of printxval for decoding bpf_class and ebpf_class.
* print_fields.h (PRINT_FIELD_XVAL_INDEX): New macro.
* bpf.c: Use it instead of PRINT_FIELD_XVAL for decoding bpf_attach_type,
bpf_map_types, bpf_map_update_elem_flags, and bpf_prog_types.

6 years agobpf: use printxval_index lookup instead of printxval
Dmitry V. Levin [Tue, 15 May 2018 21:41:47 +0000 (21:41 +0000)]
bpf: use printxval_index lookup instead of printxval

* xlat/bpf_commands.in: Add "#value_indexed" directive.
* bpf.c (SYS_FUNC(bpf)): Use printxval_index instead of printxval.

6 years agotime: use indexed lookups
Dmitry V. Levin [Tue, 15 May 2018 21:41:47 +0000 (21:41 +0000)]
time: use indexed lookups

* defs.h (xlat_idx): New prototype.
* xlat.c (xlat_idx): Remove static qualifier.
* time.c (do_adjtimex): Use xlat_idx instead of xlookup.
(SYS_FUNC(getitimer), SYS_FUNC(setitimer)): Use printxval_index
instead of printxval.
[ALPHA] (SYS_FUNC(osf_getitimer), SYS_FUNC(osf_setitimer)): Likewise.
(printclockname) [CLOCKID_TO_FD]: Likewise.
* xlat/adjtimex_state.in: Add "#value_indexed" directive.
* xlat/clocknames.in: Likewise.
* xlat/cpuclocknames.in: Add "#value_indexed" directive, add default
values to constants.
* xlat/itimer_which.in: Likewise.

6 years agolinux/arm/raw_syscall.h: avoid r7 specified register variables with Thumb
Andre McCurdy [Tue, 15 May 2018 22:34:39 +0000 (15:34 -0700)]
linux/arm/raw_syscall.h: avoid r7 specified register variables with Thumb

If Thumb code is being generated and frame pointers are enabled, the
Thumb frame pointer in r7 clashes with any local variable which may
need to be assigned to r7 (e.g. the syscall NR when making a raw
syscall).

With gcc, the double use of r7 results in a build error, e.g.

  strace-4.22/tests/inject-nf.c:86:1: error: r7 cannot be used in asm here

With clang, the double use of r7 can result in the compiler silently
generating broken code which crashes at run time due to frame pointer
corruption:

  https://bugs.llvm.org/show_bug.cgi?id=34165

In most cases the problem isn't visible as frame pointers will be
disabled automatically due to optimisation level. However to handle
cases where frame pointers are enabled (e.g. when CFLAGS etc are set
to support a debug build, etc) provide a version of raw_syscall_0
which manually saves and restores the frame pointer value in r7
to a temporary register before setting up the syscall NR in r7
and invoking the syscall.

* linux/arm/raw_syscall.h (raw_syscall_0) [__thumb__]: Provide
an alternative version.

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
6 years agosockaddr: use printxval_index lookup instead of printxval
Dmitry V. Levin [Tue, 15 May 2018 21:41:47 +0000 (21:41 +0000)]
sockaddr: use printxval_index lookup instead of printxval

* xlat/addrfams.in: Add "#value_indexed" directive.
* xlat/af_packet_types.in: Likewise.
* xlat/hci_channels.in: Likewise.
* sockaddr.c (print_sockaddr_data_bt, print_sockaddr,
* print_sockaddr_data_ll): Use printxval_index instead of printxval.

6 years agosockaddr: use printxval_search for ARPHRD_* constants
Eugene Syromyatnikov [Mon, 7 May 2018 06:32:45 +0000 (08:32 +0200)]
sockaddr: use printxval_search for ARPHRD_* constants

This xlat table is quite big.

* sockaddr.c (print_sockaddr_data_ll): Replace printxval call with
printxval_search for printing of struct sockaddr_ll.sll_hatype field.

6 years agoAdd a common MAC address printing routine
Eugene Syromyatnikov [Sun, 6 May 2018 22:04:18 +0000 (00:04 +0200)]
Add a common MAC address printing routine

* print_mac.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (sprint_mac_addr): New declaration.
(print_mac_addr): New function, a thin wrapper around sprint_mac_addr.
* print_fields.h (PRINT_FIELD_MAC, PRINT_FIELD_MAC_SZ): New macros.
* rtnl_link.c (decode_ifla_bridge_id): Use PRINT_FIELD_MAC for bridge
address printing.
* sock.c (print_ifreq) <case SIOCGIFHWADDR>: Use print_mac_addr for
ifr_hwaddr printing.
* sockaddr.c (print_sockaddr_data_bt): Use print_mac_addr for
{sco,rc,l2}_bdaddr field printing.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agosockaddr: decode Bluetooth L2 CID values
Eugene Syromyatnikov [Sun, 6 May 2018 19:24:32 +0000 (21:24 +0200)]
sockaddr: decode Bluetooth L2 CID values

* xlat/bluetooth_l2_cid.in: New file.
* sockaddr.c: Include xlat/bluetooth_l2_cid.h.
(print_bluetooth_l2_cid): New function.
(print_sockaddr_data_bt): Use it to decode struct sockaddr_l2.l2_cid
field.
* tests/net-sockaddr.c (check_l2): Update expected output.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agosockaddr: decode Bluetooth L2 PSM values
Eugene Syromyatnikov [Sun, 6 May 2018 19:07:31 +0000 (21:07 +0200)]
sockaddr: decode Bluetooth L2 PSM values

* xlat/bluetooth_l2_psm.in: New file.
* sockaddr.c: Include xlat/bluetooth_l2_psm.h.
(print_bluetooth_l2_psm): New function.
(print_sockaddr_data_bt): Use it to decode struct sockaddr_l2.l2_psm
field.
* tests/net-sockaddr.c (check_l2): Update expected output.

6 years agosockaddr: decode bluetooth address type names
Eugene Syromyatnikov [Sun, 6 May 2018 18:28:09 +0000 (20:28 +0200)]
sockaddr: decode bluetooth address type names

* xlat/bdaddr_types.in: New file.
* sockaddr.c: Include xlat/bdaddr_types.h.
(print_sockaddr_data_bt): Decode struct sockaddr_l2.l2_bdaddr_type field
using constants from bdaddr_types xlat.
* tests/net-sockaddr.c (check_l2): Check decoding
of struct sockaddr_l2.l2_bdaddr_type field.

6 years agosockaddr: decode Bluetooth socket address unconditionally
Eugene Syromyatnikov [Sun, 6 May 2018 17:53:56 +0000 (19:53 +0200)]
sockaddr: decode Bluetooth socket address unconditionally

* sockaddr.c [HAVE_BLUETOOTH_BLUETOOTH_H]: Do not include
bluetooth/bluetooth.h, bluetooth/hci.h, bluetooth/l2cap.h,
bluetooth/rfcomm.h, and bluetooth/sco.h.
[!HAVE_BLUETOOTH_BLUETOOTH_H]: Include xlat/hci_channels.h.
(btohs): New function.
(print_sockaddr_data_bt): Define unconditionally, add definitions
of struct sockaddr_hci, struct bdaddr, struct sockaddr_sco,
struct sockaddr_rc, and struct sockaddr_l2.
(sa_printers) <AF_BLUETOOTH>: Define unconditionally.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoAvoid using print_array as a local variable name
Eugene Syromyatnikov [Mon, 7 May 2018 06:26:29 +0000 (08:26 +0200)]
Avoid using print_array as a local variable name

We have a function with the same name.

* netlink.c (decode_netlink) <print_array>: Rename to is_array, all
users updated.
* nlattr.c (decode_nlattr) <print_array>: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoxlat: update MSG_* constants
Eugene Syromyatnikov [Fri, 27 Apr 2018 18:04:22 +0000 (20:04 +0200)]
xlat: update MSG_* constants

Sync them with kernel's include/linux/socket.h, since syscalls perform
almost no checks for incorrect flags.

* xlat/msg_flags.in (MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_CTRUNC,
MSG_PROBE, MSG_TRUNC, MSG_DONTWAIT, MSG_EOR, MSG_WAITALL, MSG_FIN,
MSG_SYN, MSG_CONFIRM, MSG_RST, MSG_ERRQUEUE, MSG_NOSIGNAL, MSG_MORE,
MSG_WAITFORONE, MSG_FASTOPEN, MSG_CMSG_CLOEXEC): Add default values
to all constants.
(MSG_SENDPAGE_NOTLAST, MSG_NO_SHARED_FRAGS): New constants.  It is
an internal one, but, apparently, nothing prohibits passing it
to the kernel.
(MSG_CMSG_COMPAT): New constant.  Override the value provided
by system headers.
(MSG_EOF): Commented out, as it is a synonym for MSG_FIN.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agosocketutils: use exact match of unix domain sockets on fresh kernels
Dmitry V. Levin [Mon, 14 May 2018 22:54:33 +0000 (22:54 +0000)]
socketutils: use exact match of unix domain sockets on fresh kernels

* socketutils.c (unix_send_query): Do not add NLM_F_DUMP to nlmsg_flags
when kernel version is 4.4.4 or later, initialize udiag_cookie
unconditionally.

Complements: v4.12~536 ("Change unix_diag requests back to use full dump instead of exact match")

6 years agosocketutils: do not request NDIAG_SHOW_MEMINFO
Eugene Syromyatnikov [Mon, 14 May 2018 17:20:21 +0000 (19:20 +0200)]
socketutils: do not request NDIAG_SHOW_MEMINFO

This information is not used and it looks like it negatively affects
ability to find the socket under high load.

* socketutils.c (netlink_send_query) <req>: Remove NDIAG_SHOW_MEMINFO
flag from netlink_diag_req.ndiag_show field.
* tests/netlink_netlink_diag.c (send_query) <req>: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: introduce midtail_alloc and use it in netlink tests
Eugene Syromyatnikov [Tue, 8 May 2018 05:10:16 +0000 (07:10 +0200)]
tests: introduce midtail_alloc and use it in netlink tests

netlink tests happen to access memory located before the tail_malloc'ed
pointers, a practice that doesn't go well with the latest compilers
because tail_malloc is marked with ATTRIBUTE_MALLOC.
For example, glibc in -D_FORTIFY_SOURCE=2 mode and gcc 8 with
-Warray-bounds enabled complain about negative offsets out of bounds.
Fix this issue by introducing midtail_alloc.

* tests/tests.h (midtail_alloc): New macro.
* tests/netlink_crypto.c: Use it instead of tail_malloc for nlh0 allocation.
* tests/netlink_netfilter.c: Likewise.
* tests/netlink_protocol.c: Likewise.
* tests/netlink_route.c: Likewise.
* tests/netlink_selinux.c: Likewise.
* tests/netlink_sock_diag.c: Likewise.
* tests/nlattr_br_port_msg.c: Likewise.
* tests/nlattr_crypto_user_alg.c: Likewise.
* tests/nlattr_dcbmsg.c: Likewise.
* tests/nlattr_fib_rule_hdr.c: Likewise.
* tests/nlattr_ifaddrlblmsg.c: Likewise.
* tests/nlattr_ifaddrmsg.c: Likewise.
* tests/nlattr_ifinfomsg.c: Likewise.
* tests/nlattr_ifla_brport.c: Likewise.
* tests/nlattr_ifla_port.c: Likewise.
* tests/nlattr_ifla_xdp.c: Likewise.
* tests/nlattr_inet_diag_msg.c: Likewise.
* tests/nlattr_inet_diag_req_compat.c: Likewise.
* tests/nlattr_inet_diag_req_v2.c: Likewise.
* tests/nlattr_mdba_mdb_entry.c: Likewise.
* tests/nlattr_mdba_router_port.c: Likewise.
* tests/nlattr_ndmsg.c: Likewise.
* tests/nlattr_ndtmsg.c: Likewise.
* tests/nlattr_netconfmsg.c: Likewise.
* tests/nlattr_netlink_diag_msg.c: Likewise.
* tests/nlattr_nlmsgerr.c: Likewise.
* tests/nlattr_packet_diag_msg.c: Likewise.
* tests/nlattr_rtgenmsg.c: Likewise.
* tests/nlattr_rtmsg.c: Likewise.
* tests/nlattr_smc_diag_msg.c: Likewise.
* tests/nlattr_tc_stats.c: Likewise.
* tests/nlattr_tca_stab.c: Likewise.
* tests/nlattr_tcamsg.c: Likewise.
* tests/nlattr_tcmsg.c: Likewise.
* tests/nlattr_unix_diag_msg.c: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoUse MIN where appropriate
Eugene Syromyatnikov [Mon, 7 May 2018 06:15:19 +0000 (08:15 +0200)]
Use MIN where appropriate

* netlink.c (decode_nlmsghdr_with_payload): Use MIN.
* netlink_packet_diag.c (print_packet_diag_mclist): Likewise.
* nlattr.c (decode_nlattr_with_data): Likewise.
* rtnl_route.c (decode_rta_multipath): Likewise.

6 years agoxlat: add fallback definitions to {msg,sem,shm}ctl command constants
Eugene Syromyatnikov [Sun, 15 Apr 2018 23:12:08 +0000 (01:12 +0200)]
xlat: add fallback definitions to {msg,sem,shm}ctl command constants

* xlat/msgctl_flags.in: Add default values to all constants, reorder
to make them sorted by value.
* xlat/semctl_flags.in: Likewise.
* xlat/shmctl_flags.in: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoxlat: add MSG_STAT_ANY
Eugene Syromyatnikov [Sun, 15 Apr 2018 21:49:42 +0000 (23:49 +0200)]
xlat: add MSG_STAT_ANY

* xlat/msgctl_flags.in (MSG_STAT_ANY): New constant, introduced
by Linux commit v4.17-rc1~52^2~21.
* tests/ipc_msg.c: Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoxlat: add SEM_STAT_ANY
Eugene Syromyatnikov [Sun, 15 Apr 2018 21:56:47 +0000 (23:56 +0200)]
xlat: add SEM_STAT_ANY

* xlat/semctl_flags.in (SEM_STAT_ANY): New constant, introduced
by Linux commit v4.17-rc1~52^2~22.
* tests/ipc_sem.c: Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoxlat: add SHM_STAT_ANY
Eugene Syromyatnikov [Sun, 15 Apr 2018 22:59:56 +0000 (00:59 +0200)]
xlat: add SHM_STAT_ANY

* xlat/shmctl_flags.in (SHM_STAT_ANY): New constant, introduced
by Linux commit v4.17-rc1~52^2~23.
* tests/ipc_shm.c: Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agonet: print SO_GET_FILTER in getsockopt
Eugene Syromyatnikov [Wed, 9 May 2018 12:44:28 +0000 (12:44 +0000)]
net: print SO_GET_FILTER in getsockopt

SO_ATTACH_FILTER and SO_GET_FILTER have the same value; the former
constant is intended for use in setsockopt, and the latter is for
getsockopt.  Handle that the same way as similar SOL_IP/SOL_IPV6 socket
options are handled.

* xlat/getsock_options.in: New file.
* xlat/setsock_options.in: Likewise.
* xlat/sockoptions.in (SO_ATTACH_FILTER): Move to
xlat/setsock_options.in.
* net.c: Include "xlat/setsock_options.h" and "xlat/getsock_options.h".
(print_sockopt_fd_level_name) <case SOL_SOCKET>: Use
getsock_options or setsock_options as auxiliary xlats based on the value
of is_getsockopt flag.
* tests/sock_filter-v.c: Update expected output.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: add sock_filtrer-v variants with different xlat verbosity levels
Eugene Syromyatnikov [Wed, 9 May 2018 12:44:28 +0000 (12:44 +0000)]
tests: add sock_filtrer-v variants with different xlat verbosity levels

* tests/sock_filter-v-Xabbrev.c: New file.
* tests/sock_filter-v-Xraw.c: Likewise.
* tests/sock_filter-v-Xverbose.c: Likewise.
* tests/sock_filter-v.c (PRINT_STMT_SYM, PRINT_STMT_SYM_,
PRINT_STMT_VAL, PRINT_STMT_VAL_, PRINT_JUMP_): Remove.
(HEX_FMT, XLAT_FMT, XLAT_ARGS, PRINT_STMT): New macros.
(PRINT_JUMP): Rewrite.
(print_filter): Rewrite using PRINT_STMT and new PRINT_JUMP.
(main): Print SOL_SOCKET, SO_ATTACH_FILTER, and SO_ATTACH_REUSEPORT_CBPF
using XLAT_FMT/XLAT_ARGS macros.
* tests/pure_executables.list: Add sock_filter-v-Xabbrev,
sock_filter-v-Xraw, and sock_filter-v-Xverbose.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (sock_filter-v-Xabbrev, sock_filter-v-Xraw,
sock_filter-v-Xverbose): New tests.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agodefs.h: fix ethernet_protocols comment
Eugene Syromyatnikov [Mon, 7 May 2018 05:28:54 +0000 (07:28 +0200)]
defs.h: fix ethernet_protocols comment

Starting with commit v4.22~109, sorted xlat tables are terminated
with XLAT_END.

* defs.h (ethernet_protocols): Remove the "unterminated" part from
description.

6 years agoxlat: rename *sock*options xlat tables
Dmitry V. Levin [Tue, 8 May 2018 20:59:20 +0000 (20:59 +0000)]
xlat: rename *sock*options xlat tables

Such names as sockrxrpcoptions are incomprehensible.

* xlat/getsockipoptions.in: Rename to xlat/getsock_ip_options.in.
* xlat/getsockipv6options.in: Rename to xlat/getsock_ipv6_options.in.
* xlat/setsockipoptions.in: Rename to xlat/setsock_ip_options.in.
* xlat/setsockipv6options.in: Rename to xlat/setsock_ipv6_options.in.
* xlat/sockalgoptions.in: Rename to xlat/sock_alg_options.in.
* xlat/sockbluetoothoptions.in: Rename to xlat/sock_bluetooth_options.in.
* xlat/sockcaifoptions.in: Rename to xlat/sock_caif_options.in.
* xlat/sockdccpoptions.in: Rename to xlat/sock_dccp_options.in.
* xlat/sockipoptions.in: Rename to xlat/sock_ip_options.in.
* xlat/sockipv6options.in: Rename to xlat/sock_ipv6_options.in.
* xlat/sockipxoptions.in: Rename to xlat/sock_ipx_options.in.
* xlat/sockirdaoptions.in: Rename to xlat/sock_irda_options.in.
* xlat/sockiucvoptions.in: Rename to xlat/sock_iucv_options.in.
* xlat/sockkcmoptions.in: Rename to xlat/sock_kcm_options.in.
* xlat/sockllcoptions.in: Rename to xlat/sock_llc_options.in.
* xlat/socknetlinkoptions.in: Rename to xlat/sock_netlink_options.in.
* xlat/socknfcllcpoptions.in: Rename to xlat/sock_nfcllcp_options.in.
* xlat/sockoptions.in: Rename to xlat/sock_options.in.
* xlat/sockpacketoptions.in: Rename to xlat/sock_packet_options.in.
* xlat/sockpnpoptions.in: Rename to xlat/sock_pnp_options.in.
* xlat/sockpppol2tpoptions.in: Rename to xlat/sock_pppol2tp_options.in.
* xlat/sockrawoptions.in: Rename to xlat/sock_raw_options.in.
* xlat/sockrdsoptions.in: Rename to xlat/sock_rds_options.in.
* xlat/sockrxrpcoptions.in: Rename to xlat/sock_rxrpc_options.in.
* xlat/socksctpoptions.in: Rename to xlat/sock_sctp_options.in.
* xlat/socktcpoptions.in: Rename to xlat/sock_tcp_options.in.
* xlat/socktipcoptions.in: Rename to xlat/sock_tipc_options.in.
* xlat/socktlsoptions.in: Rename to xlat/sock_tls_options.in.
* xlat/sockudpoptions.in: Rename to xlat/sock_udp_options.in.
* net.c: Update.

6 years agonet: decode more SOL_* socket options
Eugene Syromyatnikov [Mon, 7 May 2018 06:10:41 +0000 (06:10 +0000)]
net: decode more SOL_* socket options

* xlat/sockalgoptions.in: New file.
* xlat/sockbluetoothoptions.in: Likewise.
* xlat/sockcaifoptions.in: Likewise.
* xlat/sockdccpoptions.in: Likewise.
* xlat/sockiucvoptions.in: Likewise.
* xlat/sockkcmoptions.in: Likewise.
* xlat/sockllcoptions.in: Likewise.
* xlat/socknfcllcpoptions.in: Likewise.
* xlat/sockpnpoptions.in: Likewise.
* xlat/sockpppol2tpoptions.in: Likewise.
* xlat/sockrdsoptions.in: Likewises.
* xlat/sockrxrpcoptions.in: Likewise.
* xlat/socktipcoptions.in: Likewise.
* xlat/socktlsoptions.in: Likewise.
* xlat/sockudpoptions.in: Likewise.
* net.c: Include "xlat/sockalgoptions.h", "xlat/sockbluetoothoptions.h",
"xlat/sockcaifoptions.h", "xlat/sockdccpoptions.h",
"xlat/sockiucvoptions.h", "xlat/sockkcmoptions.h",
"xlat/sockllcoptions.h", "xlat/socknfcllcpoptions.h",
"xlat/sockpnpoptions.h", "xlat/sockpppol2tpoptions.h",
"xlat/sockrdsoptions.h", "xlat/sockrxrpcoptions.h",
"xlat/socktipcoptions.h", "xlat/socktlsoptions.h",
and "xlat/sockudpoptions.h".
(print_sockopt_fd_level_name): Decode SOL_UDP, SOL_IRDA, SOL_LLC,
SOL_DCCP, SOL_TIPC, SOL_RXRPC, SOL_PPPOL2TP, SOL_BLUETOOTH, SOL_PNPIPE,
SOL_RDS, SOL_IUCV, SOL_CAIF, SOL_ALG, SOL_NFC, SOL_KCM, and SOL_TLS
socket option names.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agonet: decode more AF_* protocol names
Eugene Syromyatnikov [Mon, 7 May 2018 06:10:41 +0000 (06:10 +0000)]
net: decode more AF_* protocol names

* xlat/caif_protocols.in: New file.
* xlat/can_protocols.in: Likewise.
* xlat/irda_protocols.in: Likewise.
* xlat/isdn_protocols.in: Likewise.
* xlat/kcm_protocols.in: Likewise.
* xlat/nfc_protocols.in: Likewise.
* xlat/phonet_protocols.in: Likewise.
* xlat/smc_protocols.in: Likewise.
* net.c: Include "xlat/irda_protocols.h", "xlat/can_protocols.h",
"xlat/isdn_protocols.h", "xlat/phonet_protocols.h",
"xlat/caif_protocols.h", "xlat/nfc_protocols.h",
"xlat/kcm_protocols.h", and "xlat/smc_protocols.h".
(SYS_FUNC(socket)): Decode AF_IRDA, AF_CAN, AF_RXRPC, AF_ISDN,
AF_PHONET, AF_CAIF, AF_NFC, AF_KCM, and AF_SMC protocol names.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoRemove some duplicate fallback definitions
Eugene Syromyatnikov [Mon, 7 May 2018 06:10:41 +0000 (08:10 +0200)]
Remove some duplicate fallback definitions

There is no need to provide duplicate fallback definitions anymore,
inclusion of the appropriate xlat header in XLAT_MACROS_ONLY mode
does the right thing.

* btrfs.c [!BTRFS_FIRST_FREE_OBJECTID] (BTRFS_FIRST_FREE_OBJECTID):
Remove, a fallback definition is already provided by included
"xlat/btrfs_tree_objectids.h".
* net.c: Include "xlat/addrfams.h" in XLAT_MACROS_ONLY mode.
[!AF_BLUETOOTH] (AF_BLUETOOTH): Remove.
* syscall.c: Include "xlat/nt_descriptor_types.h" in XLAT_MACROS_ONLY
mode.
[!NT_PRSTATUS] (NT_PRSTATUS): Remove.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoxlat/gen.sh: introduce XLAT_MACROS_ONLY macro
Eugene Syromyatnikov [Mon, 7 May 2018 00:43:34 +0000 (02:43 +0200)]
xlat/gen.sh: introduce XLAT_MACROS_ONLY macro

Sometimes we need just fallback definitions and nothing else.
This change adds an interface of skipping xlat table prototypes
and definitions.

* xlat/gen.sh (gen_header): Place xlat table prototype or definition
under "#ifndef XLAT_MACROS_ONLY" guard.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agortnl_link: print IFLA_NEW_IFINDEX using decode_nla_ifindex
Eugene Syromyatnikov [Mon, 7 May 2018 06:38:18 +0000 (08:38 +0200)]
rtnl_link: print IFLA_NEW_IFINDEX using decode_nla_ifindex

As it is an interface index.

* rtnl_link.c (ifinfomsg_nla_decoders) <[IFLA_NEW_IFINDEX]>: Change
the value from decode_nla_s32 to decode_nla_ifindex.

6 years agoci: install libbluetooth-dev
Eugene Syromyatnikov [Sun, 6 May 2018 20:44:45 +0000 (22:44 +0200)]
ci: install libbluetooth-dev

* ci/install-dependencies.sh (common_packages): Add libbluetooth-dev.

6 years agoxlat: provide fallback definitions for HCI_CHANNEL_* constants
Eugene Syromyatnikov [Sun, 6 May 2018 18:10:59 +0000 (20:10 +0200)]
xlat: provide fallback definitions for HCI_CHANNEL_* constants

* xlat/hci_channels.in: Provide fallback definitions.

6 years agos390: simplify s390_runtime_instr command printing
Eugene Syromyatnikov [Sun, 15 Apr 2018 23:14:02 +0000 (01:14 +0200)]
s390: simplify s390_runtime_instr command printing

As the header with command definitions is now a part of UAPI (since
Linux commit v4.16-rc1~21^2~11), there's no need for a very special
printing routine for command names.

* s390.c (SYS_FUNC(s390_runtime_instr)): Use printxval_d to print
the command argument.
* tests/s390_runtime_instr.c: Update expected output.

6 years agotests/init.sh: add run_prog_match_grep
Eugene Syromyatnikov [Sun, 29 Apr 2018 18:46:45 +0000 (20:46 +0200)]
tests/init.sh: add run_prog_match_grep

* tests/init.sh (run_prog_match_grep): New function, similar
to run_prog_match_diff.

6 years agotests: add so_peercred variants with different xlat verbosity levels
Eugene Syromyatnikov [Wed, 11 Apr 2018 17:34:31 +0000 (19:34 +0200)]
tests: add so_peercred variants with different xlat verbosity levels

* tests/so_peercred-Xabbrev.c: New file.
* tests/so_peercred-Xraw.c: Likewise.
* tests/so_peercred-Xverbose.c: Likewise.
* tests/pure_executables.list: Add so_peercred-Xabbrev,
so_peercred-Xraw, and so_peercred-Xverbose.
* tests/.gitignore: Likewise.
* tests/so_peercred.c: Add handling of XLAT_RAW and XLAT_VERBOSE flags.
* tests/gen_tests.in (so_peercred-Xabbrev, so_peercred-Xraw,
so_peercred-Xverbose): New tests.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: add personality variants with different xlat verbosity levels
Eugene Syromyatnikov [Wed, 11 Apr 2018 00:41:16 +0000 (02:41 +0200)]
tests: add personality variants with different xlat verbosity levels

* tests/personality-Xabbrev.c: New file.
* tests/personality-Xraw.c: Likewise.
* tests/personality-Xverbose.c: Likewise.
* tests/pure_executables.list: Add personality-Xabbrev,
personality-Xraw, and personality-Xverbose.
* tests/.gitignore: Likewise.
* tests/personality.c: Add handling of XLAT_RAW and XLAT_VERBOSE flags.
* tests/personality.test: Add support for accepting test arguments.
* tests/gen_tests.in (personality-Xabbrev, personality-Xraw,
personality-Xverbose): New tests.

6 years agotests: add fanotify_mark variants with different xlat verbosity levels
Eugene Syromyatnikov [Tue, 10 Apr 2018 13:10:44 +0000 (15:10 +0200)]
tests: add fanotify_mark variants with different xlat verbosity levels

* tests/fanotify_mark-Xabbrev.c: New file.
* tests/fanotify_mark-Xraw.c: Likewise.
* tests/fanotify_mark-Xverbose.c: Likewise.
* tests/pure_executables.list: Add fanotify_mark-Xabbev,
fanotify_mark-Xraw, and fanotify_mark-Xverbose.
* tests/.gitignore: Likewise.
* tests/fanotify_mark.c: Add handling of XLAT_RAW and XLAT_VERBOSE
flags.
* tests/gen_tests.in (fanotify_mark-Xabbev, fanotify_mark-Xraw,
fanotify_mark-Xverbose): New tests.

6 years agoxlat: provide fallback definitions for IFF_* constants
Eugene Syromyatnikov [Mon, 7 May 2018 07:15:45 +0000 (09:15 +0200)]
xlat: provide fallback definitions for IFF_* constants

* xlat/iffflags.in: Provide fallback definitions.  Mention that
the array is sorted.

6 years agoxlat: update IFF_* constants
Eugene Syromyatnikov [Mon, 7 May 2018 07:09:30 +0000 (09:09 +0200)]
xlat: update IFF_* constants

* xlat/iffflags.in (IFF_DYNAMIC): New constant, had been introduced
before the current git repository was conceived.
(IFF_LOWER_UP, IFF_DORMANT): New constants, introduced by Linux commit
v2.6.17-rc1~1175^2~206.
(IFF_ECHO): New constant, introduced by Linux commit
v2.6.25-rc1~1162^2~1415.

6 years agoxlat: provide fallback definitions for ARPHRD_* constants
Eugene Syromyatnikov [Sun, 6 May 2018 22:30:21 +0000 (00:30 +0200)]
xlat: provide fallback definitions for ARPHRD_* constants

* xlat/arp_hardware_types.in: Provide fallback definitions, sort.

6 years agotests: add more v4l2 checks
Eugene Syromyatnikov [Mon, 9 Apr 2018 15:12:32 +0000 (17:12 +0200)]
tests: add more v4l2 checks

* tests/ioctl_v4l2.c (main): Add more VIDIOC_S_EXT_CTRLS checks.

6 years agotests: add variants of IPC tests with different xlat verbosity levels
Eugene Syromyatnikov [Sat, 7 Apr 2018 00:30:43 +0000 (02:30 +0200)]
tests: add variants of IPC tests with different xlat verbosity levels

* tests/.gitignore: Add ipc_msg-Xabbrev, ipc_msg-Xraw, ipc_msg-Xverbose,
ipc_msgbuf-Xabbrev, ipc_msgbuf-Xraw, ipc_msgbuf-Xverbose,
ipc_sem-Xabbrev, ipc_sem-Xraw, ipc_sem-Xverbose, ipc_shm-Xabbrev,
ipc_shm-Xraw, and ipc_shm-Xverbose.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (ipc_msg-Xabbrev, ipc_msg-Xraw, ipc_msg-Xverbose,
ipc_msgbuf-Xabbrev, ipc_msgbuf-Xraw, ipc_msgbuf-Xverbose,
ipc_sem-Xabbrev, ipc_sem-Xraw, ipc_sem-Xverbose, ipc_shm-Xabbrev,
ipc_shm-Xraw, ipc_shm-Xverbose): New tests.
* tests/ipc_msg-Xabbrev.c: New file.
* tests/ipc_msg-Xraw.c: Likewise.
* tests/ipc_msg-Xverbose.c: Likewise.
* tests/ipc_msgbuf-Xabbrev.c: Likewise.
* tests/ipc_msgbuf-Xraw.c: Likewise.
* tests/ipc_msgbuf-Xverbose.c: Likewise.
* tests/ipc_sem-Xabbrev.c: Likewise.
* tests/ipc_sem-Xraw.c: Likewise.
* tests/ipc_sem-Xverbose.c: Likewise.
* tests/ipc_shm-Xabbrev.c: Likewise.
* tests/ipc_shm-Xraw.c: Likewise.
* tests/ipc_shm-Xverbose.c: Likewise.
* tests/ipc.sh: Add support for accepting test arguments.
* tests/ipc_msgbuf.test: Likewise.
* tests/ipc_msg.c: Add handling of XLAT_RAW and XLAT_VERBOSE flags.
* tests/ipc_msgbuf.c: Likewise.
* tests/ipc_sem.c: Likewise.
* tests/ipc_shm.c: Likewise.

6 years agotests: make ipc tests a bit more strict
Eugene Syromyatnikov [Sat, 7 Apr 2018 00:25:59 +0000 (02:25 +0200)]
tests: make ipc tests a bit more strict

* tests/gen_tests.in (ipc_msg, ipc_sem, ipc_shm): Add -a option.
* tests/ipc_msg.c: Replace " +" with " " in expected output.
* tests/ipc_sem.c: Likewise.
* tests/ipc_shm.c: Likewise.

6 years agoipc_shm: print SHM_HUGE_SHIFT using print_xlat_u
Eugene Syromyatnikov [Sat, 7 Apr 2018 00:12:10 +0000 (02:12 +0200)]
ipc_shm: print SHM_HUGE_SHIFT using print_xlat_u

* ipc_shm.c (SYS_FUNC(shmget)): Print SHM_HUGE_SHIFT using print_xlat_u.

6 years agotests: check all bits of mtype in ipc_msgbuf test
Eugene Syromyatnikov [Fri, 6 Apr 2018 17:03:04 +0000 (19:03 +0200)]
tests: check all bits of mtype in ipc_msgbuf test

* tests/ipc_msgbuf.c: Include <unistd.h> and <asm/unistd.h>.
(sys_msgrcv): New function.
(msgrcv): Use it instead of msgrcv.  Add bits to mtype,
check for -mtype in msgrcv.

6 years agotests: print expected output by ipc_msgbuf test itself
Eugene Syromyatnikov [Fri, 6 Apr 2018 17:01:39 +0000 (19:01 +0200)]
tests: print expected output by ipc_msgbuf test itself

* tests/ipc_msgbuf.expected: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove tests/ipc_msgbuf.expected.
* tests/ipc_msgbuf.c: Add expected output.
* tests/ipc_msgbuf.test: Add -a31.  Redirect output to $EXP.  Call
match_grep with $LOG and $EXP arguments.

6 years agoxlat: provide fallback definitions for SKF_*_OFF constants
Dmitry V. Levin [Mon, 7 May 2018 10:52:16 +0000 (10:52 +0000)]
xlat: provide fallback definitions for SKF_*_OFF constants

* xlat/skf_off.in: New file.
* bpf_sock_filter.c: Include "xlat/skf_off.h".

6 years agoxlat: provide fallback definitions for BPF_* constants
Dmitry V. Levin [Mon, 7 May 2018 10:52:16 +0000 (10:52 +0000)]
xlat: provide fallback definitions for BPF_* constants

* xlat/bpf_class.in: Add default values for constants.
* xlat/bpf_miscop.in: Likewise.
* xlat/bpf_mode.in: Likewise.
* xlat/bpf_op_alu.in: Likewise.
* xlat/bpf_op_jmp.in: Likewise.
* xlat/bpf_rval.in: Likewise.
* xlat/bpf_size.in: Likewise.
* xlat/bpf_src.in: Likewise.

6 years agoxlat: fix F_* fallback definitions on mips64
Dmitry V. Levin [Sun, 6 May 2018 23:28:24 +0000 (23:28 +0000)]
xlat: fix F_* fallback definitions on mips64

* xlat/fcntlcmds.in (F_GETLK64, F_SETLK64, F_SETLKW64) [__mips64]: Fix
default values.

Fixes: v4.22-122-gfa8f486 ("xlat: fix F_* fallback definitions on alpha, hppa, mips, and sparc")
6 years agoxlat: add fallback definitions to SO_* constants
Eugene Syromyatnikov [Fri, 4 May 2018 16:19:07 +0000 (18:19 +0200)]
xlat: add fallback definitions to SO_* constants

Regenerate xlat/sockoptions.in using the following script:

  sed -n 's/^\(SO_[^[:space:]]*\).*/\1/p' xlat/sockoptions.in |
  uniq |
  while read name; do
    sed -rn 's/#define[[:space:]]+('"$name"')[[:space:]]+([[:digit:]]+)$/\2\t\1/p' \
      /path/to/linux/include/uapi/asm-generic/socket.h
  done |
  sort -n |
  while read def name; do
    grep -EH '#define[[:space:]]+'"$name"'[[:space:]]+(0x[[:xdigit:]]+|[[:digit:]]+)' \
      /path/to/linux/arch/*/include/uapi/asm/socket.h |
    sed -rn 's|^[^#]*/arch/([^/]+)/include/uapi/asm/socket\.h:#define[[:space:]]+'"$name"'[[:space:]]+([^[:space:]]+)([[:space:]].*)?$|\1\t\2|p' |
    sed s/parisc/hppa/ |sort |
    awk -vname="$name" -vdef="$def" '
      {
        i=strtonum($2)
        if (i == def) next
        if (a[i])
          a[i]=a[i] " || defined __" $1 "__"
        else
          a[i]="defined __" $1 "__"
      }
      END {
        iftext="#if"
        for (i in a) {
          printf("%s %s\n%s %u\n",iftext,a[i],name,i)
          iftext="#elif"
        }
        if (iftext != "#if")
          print "#else"
        printf("%s %s\n", name, def)
        if (iftext == "#if")
          print ""
        else
          print "#endif\n"
      }'
  done

* xlat/sockoptions.in: Add fallback definitions.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoxlat: remove socket options with duplicate names
Eugene Syromyatnikov [Fri, 4 May 2018 16:01:48 +0000 (18:01 +0200)]
xlat: remove socket options with duplicate names

* xlat/sockoptions.in (SO_GET_FILTER): Remove as it is defined
to SO_ATTACH_FILTER.
(SO_DETACH_BPF): Remove as it is defined to SO_DETACH_FILTER.

6 years agoxlat: remove socket options that do not exist in Linux
Eugene Syromyatnikov [Fri, 4 May 2018 16:00:00 +0000 (18:00 +0200)]
xlat: remove socket options that do not exist in Linux

* xlat/sockoptions.in (SO_ALLRAW, SO_ICS, SO_IMASOCKET, SO_LISTENING,
SO_MGMT, SO_ORDREL, SO_PARALLELSVR, SO_PROTOTYPE, SO_RDWRSO_SEMA,
SO_USELOOPBACK): Remove.

6 years agoxlat: treat socketlayers as a sorted array
Eugene Syromyatnikov [Wed, 11 Apr 2018 14:32:30 +0000 (16:32 +0200)]
xlat: treat socketlayers as a sorted array

* xlat/socketlayers.in: Add a comment that the xlat is sorted.
* net.c (print_sockopt_fd_level_name): Use printxval_search
instead of printxval for decoding socket layer name.

6 years agonet: decode Bluetooth protocol names unconditionally
Eugene Syromyatnikov [Wed, 11 Apr 2018 11:53:54 +0000 (13:53 +0200)]
net: decode Bluetooth protocol names unconditionally

As we have all BTPROTO_* constant definitions now, there is no need
to rely on bluetooth.h header anymore.

* net.c (AF_BLUETOOTH): Provide a fallback definition.
[HAVE_BLUETOOTH_BLUETOOTH_H]: Do not include <bluetooth/bluetooth.h>.
[!HAVE_BLUETOOTH_BLUETOOTH_H]: Include "xlat/bt_protocols.h".
[!HAVE_BLUETOOTH_BLUETOOTH_H] (decode_sockbuf): Decode AF_BLUETOOTH.
(decode_sockbuf) <case AF_BLUETOOTH>: Use printxval_index.
* xlat/bt_protocols.in: Add "#value_indexed" directive.

6 years agoxlat/gen.sh: invoke the shell interpreter with -e -u options
Eugene Syromyatnikov [Thu, 26 Apr 2018 23:27:45 +0000 (01:27 +0200)]
xlat/gen.sh: invoke the shell interpreter with -e -u options

* xlat/gen.sh: Change interpreter from "/bin/sh" to "/bin/sh -eu".