]> granicus.if.org Git - strace/log
strace
6 years agouserfaultfd: enhance decoding of struct uffdio_api.features
Dmitry V. Levin [Wed, 19 Jul 2017 00:33:56 +0000 (00:33 +0000)]
userfaultfd: enhance decoding of struct uffdio_api.features

As struct uffdio_api.features has read-write semantics,
print the value returned by the kernel only when it differs
from the value passed to the kernel.

* userfaultfd.c (uffdio_ioctl) <UFFDIO_API>: On entering syscall,
save the value of struct uffdio_api.features.  On exiting syscall, do
not print struct uffdio_api.features when it's the same as on entering.
* tests/ioctl_uffdio.c (main): Update expected output.

6 years agouserfaultfd: use PRINT_FIELD_* macros
Dmitry V. Levin [Tue, 18 Jul 2017 21:54:38 +0000 (21:54 +0000)]
userfaultfd: use PRINT_FIELD_* macros

This also fixes output correctness for struct uffdio_api.features.

* userfaultfd.c: Include "print_fields.h".
(tprintf_uffdio_range): Use PRINT_FIELD_X.
(PRINT_FIELD_UFFDIO_RANGE): New macro.
(uffdio_ioctl): Use it, PRINT_FIELD_FLAGS64, and PRINT_FIELD_X.
* tests/ioctl_uffdio.c (main): Update expected output.

6 years agoIntroduce PRINT_FIELD_FLAGS64 and PRINT_FIELD_XVAL64
Dmitry V. Levin [Tue, 18 Jul 2017 21:54:38 +0000 (21:54 +0000)]
Introduce PRINT_FIELD_FLAGS64 and PRINT_FIELD_XVAL64

* print_fields.h (PRINT_FIELD_FLAGS64, PRINT_FIELD_XVAL64): New macros.

6 years agoUpdate NEWS
Dmitry V. Levin [Mon, 17 Jul 2017 19:55:17 +0000 (19:55 +0000)]
Update NEWS

6 years agoaio: change struct iocb.aio_lio_opcode output format
Dmitry V. Levin [Mon, 17 Jul 2017 11:59:26 +0000 (11:59 +0000)]
aio: change struct iocb.aio_lio_opcode output format

* aio.c (tprint_lio_opcode): Change opcode output format to match
the kernel.
* tests/aio.c (main): Update expected output.

6 years agoaio: use PRINT_FIELD_* macros
Dmitry V. Levin [Mon, 17 Jul 2017 11:59:26 +0000 (11:59 +0000)]
aio: use PRINT_FIELD_* macros

This also fixes output correctness for struct iocb.

* aio.c: Include "print_fields.h".
(print_common_flags, print_iocb_header, print_iocb, print_io_event):
Use PRINT_FIELD_D, PRINT_FIELD_U, PRINT_FIELD_X, PRINT_FIELD_FD,
and PRINT_FIELD_STRN.
* tests/aio.c (main): Update expected output.

6 years agoIntroduce PRINT_FIELD_FD and PRINT_FIELD_STRN
Dmitry V. Levin [Mon, 17 Jul 2017 11:59:26 +0000 (11:59 +0000)]
Introduce PRINT_FIELD_FD and PRINT_FIELD_STRN

* print_fields.h (PRINT_FIELD_FD, PRINT_FIELD_STRN): New macros.

6 years agoUpdate BPF_* constants
Dmitry V. Levin [Sun, 16 Jul 2017 22:31:34 +0000 (22:31 +0000)]
Update BPF_* constants

* xlat/bpf_commands.in: Add BPF_PROG_TEST_RUN, BPF_PROG_GET_NEXT_ID,
BPF_MAP_GET_NEXT_ID, BPF_PROG_GET_FD_BY_ID, BPF_MAP_GET_FD_BY_ID,
and BPF_OBJ_GET_INFO_BY_FD introduced by linux kernel commits
v4.12-rc1~64^3~287^2~5, v4.13-rc1~157^2~271^2~5,
v4.13-rc1~157^2~271^2~4, v4.13-rc1~157^2~271^2~3, and
v4.13-rc1~157^2~271^2~1, respectively.
* xlat/bpf_attach_type.in: Add BPF_CGROUP_SOCK_OPS introduced
by linux kernel commit v4.13-rc1~157^2~37^2~15.
* xlat/bpf_prog_types.in: Add BPF_PROG_TYPE_SOCK_OPS introduced
by the same commit.

6 years agoUpdate SO_* constants
Dmitry V. Levin [Sun, 16 Jul 2017 22:24:54 +0000 (22:24 +0000)]
Update SO_* constants

* xlat/sockoptions.in: Add SO_PEERGROUPS introduced by linux kernel
commit v4.13-rc1~157^2~124.

6 years agoUpdate SCM_* constants
Dmitry V. Levin [Sun, 16 Jul 2017 22:21:34 +0000 (22:21 +0000)]
Update SCM_* constants

* xlat/scmvals.in: Add SCM_TIMESTAMPING_PKTINFO introduced
by linux kernel commit v4.13-rc1~157^2~405^2~3.

6 years agotests: check decoding of NETLINK_SELINUX protocol
JingPiao Chen [Sat, 15 Jul 2017 01:11:33 +0000 (09:11 +0800)]
tests: check decoding of NETLINK_SELINUX protocol

* test_netlink.h (TEST_NETLINK_OBJECT): New macro.
* tests/netlink_selinux.c: Include "test_netlink.h"
instead of "netlink.h".
(test_selnl_msg_unspec, test_selnl_msg_setenforce,
test_selnl_msg_policyload): New functions.
(main): Use them.

6 years agonetlink: decode NETLINK_SELINUX protocol
JingPiao Chen [Fri, 14 Jul 2017 05:16:36 +0000 (13:16 +0800)]
netlink: decode NETLINK_SELINUX protocol

* netlink_selinux.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (decode_netlink_selinux): New prototype.
* netlink.c (netlink_decoders): Add NETLINK_SELINUX.

6 years agosg_io_v3: use PRINT_FIELD_* macros
Dmitry V. Levin [Sat, 15 Jul 2017 00:08:12 +0000 (00:08 +0000)]
sg_io_v3: use PRINT_FIELD_* macros

* sg_io_v3.c: Include "print_fields.h".
(PRINT_FIELD_SG_IO_BUFFER): New macro.
(decode_request, decode_response): Use it, PRINT_FIELD_D, PRINT_FIELD_U,
PRINT_FIELD_X, PRINT_FIELD_PTR, PRINT_FIELD_FLAGS, and PRINT_FIELD_XVAL.

6 years agoIntroduce PRINT_FIELD_PTR
Dmitry V. Levin [Sat, 15 Jul 2017 00:08:12 +0000 (00:08 +0000)]
Introduce PRINT_FIELD_PTR

* print_fields.h (PRINT_FIELD_PTR): New macro.

6 years agoProvide mpers_ptr_t definition for non-mpers case
Dmitry V. Levin [Sat, 15 Jul 2017 00:08:12 +0000 (03:08 +0300)]
Provide mpers_ptr_t definition for non-mpers case

In mpers case, mpers_ptr_t is already defined by DEF_MPERS_TYPE(...).
This allows use of mpers_ptr_t regardless of IN_MPERS state.

* mpers_type.h [!IN_MPERS] (mpers_ptr_t): New typedef.

6 years agoMove is_negated_errno() to new header negated_errno.h
Lazar Trsic [Fri, 14 Jul 2017 09:31:03 +0000 (11:31 +0200)]
Move is_negated_errno() to new header negated_errno.h

Move is_negated_errno() to a separate new header file negated_errno.h
and include it just for architectures which require it.

is_negated_errno() is not used on those architectures
that have a dedicated register to signal a syscall error.

The issue was raised when compiling with clang, which is more
strict regarding semantics of unused static inline functions
defined in C files and will issue a -Wunused-function warrning
if they are not used anywhere.

* syscall.c (is_negated_errno): Move to ...
* negated_errno.h: ... new file.
* Makefile.am (strace_SOURCES): Add it.
* linux/aarch64/get_error.c: Include it.
* linux/arc/get_error.c: Likewise.
* linux/arm/get_error.c: Likewise.
* linux/avr32/get_error.c: Likewise.
* linux/bfin/get_error.c: Likewise.
* linux/crisv10/get_error.c: Likewise.
* linux/hppa/get_error.c: Likewise.
* linux/i386/get_error.c: Likewise.
* linux/ia64/get_error.c: Likewise.
* linux/m68k/get_error.c: Likewise.
* linux/metag/get_error.c: Likewise.
* linux/microblaze/get_error.c: Likewise.
* linux/or1k/get_error.c: Likewise.
* linux/riscv/get_error.c: Likewise.
* linux/s390/get_error.c: Likewise.
* linux/sh/get_error.c: Likewise.
* linux/sh64/get_error.c: Likewise.
* linux/tile/get_error.c: Likewise.
* linux/x86_64/get_error.c: Likewise.
* linux/xtensa/get_error.c: Likewise.

6 years agosg_io_v4: use PRINT_FIELD_* macros
Dmitry V. Levin [Fri, 14 Jul 2017 03:59:13 +0000 (03:59 +0000)]
sg_io_v4: use PRINT_FIELD_* macros

* sg_io_v4.c: Include "print_fields.h".
(PRINT_FIELD_SG_IO_BUFFER): New macro.
(decode_request, decode_response): Use it, PRINT_FIELD_D, PRINT_FIELD_U,
PRINT_FIELD_X, PRINT_FIELD_FLAGS, and PRINT_FIELD_XVAL.

6 years agodm: use PRINT_FIELD_* macros
Dmitry V. Levin [Fri, 14 Jul 2017 00:08:09 +0000 (00:08 +0000)]
dm: use PRINT_FIELD_* macros

* dm.c (dm_decode_values, dm_decode_dm_target_spec,
dm_decode_dm_target_deps, dm_decode_dm_target_msg, dm_known_ioctl): Use
PRINT_FIELD_D, PRINT_FIELD_U, and PRINT_FIELD_FLAGS.

6 years agoMove macros related to kernel types to kernel_types.h
Dmitry V. Levin [Thu, 13 Jul 2017 21:56:29 +0000 (21:56 +0000)]
Move macros related to kernel types to kernel_types.h

Some macros related to kernel types are defined both in defs.h and
tests/tests.h.  Avoid this redundancy by moving these definitions
to kernel_types.h.

* defs.h (PRI_kl, PRI_kld, PRI_klu, PRI_klx, PRI__64, PRI__d64,
PRI__u64, PRI__x64): Move ...
* kernel_types.h: ... here.
* tests/tests.h (PRI__64, PRI__d64, PRI__u64, PRI__x64): Remove.

6 years agomips64: fix PRI__64 macro definition when compiled for Android
Lazar Trsic [Mon, 10 Jul 2017 15:05:44 +0000 (17:05 +0200)]
mips64: fix PRI__64 macro definition when compiled for Android

By default for MIPS64 in Android __u64 type is exported
as unsigned long long.  This caused compilation -Wformat warnings
and would break the build if -Werror is used.

* defs.h [SIZEOF_LONG != 4 && MIPS && __ANDROID__] (PRI__64): Change
from "l" to "ll".

6 years agoblock: use PRINT_FIELD_* macros
Dmitry V. Levin [Thu, 13 Jul 2017 12:38:51 +0000 (12:38 +0000)]
block: use PRINT_FIELD_* macros

This also fixes output correctness for struct blkpg_ioctl_arg.

* block.c (print_blkpg_req): Use PRINT_FIELD_D and PRINT_FIELD_XVAL.
(block_ioctl): Use PRINT_FIELD_U.
* tests/ioctl_block.c (main): Update expected output.

6 years agonetlink_sock_diag: enhance decoding of long meminfo arrays
Dmitry V. Levin [Wed, 12 Jul 2017 21:08:03 +0000 (21:08 +0000)]
netlink_sock_diag: enhance decoding of long meminfo arrays

Print trailing dots instead of silent truncation if the array
is too long.

* netlink_sock_diag.c (decode_meminfo): Do not apply SK_MEMINFO_VARS
limit to nmemb, specify element count to print_array instead.
(print_meminfo): Check element count and terminate printing
if the element count exceeds SK_MEMINFO_VARS.
* tests/nlattr_inet_diag_msg.c (main): Check it.

6 years agotests: extend coverage of netlink_diag_req decoder
Dmitry V. Levin [Wed, 12 Jul 2017 19:33:25 +0000 (19:33 +0000)]
tests: extend coverage of netlink_diag_req decoder

Add one more NETLINK_SOCK_DIAG check to ressurrect full coverage
of netlink_diag_req decoder that was lost after commit
v4.18-58-g37ef2d0d.

* tests/netlink_sock_diag.c (test_netlink_diag_req): Add a check for
sdiag_protocol != NDIAG_PROTO_ALL.

6 years agotests: check decoding of NETLINK_CRYPTO nlmsg_flags
JingPiao Chen [Fri, 9 Jun 2017 11:44:57 +0000 (19:44 +0800)]
tests: check decoding of NETLINK_CRYPTO nlmsg_flags

* tests/netlink_crypto.c (test_nlmsg_flags): New function.
(main): Use it.

6 years agonetlink: add decoding of NETLINK_CRYPTO nlmsg_flags
JingPiao Chen [Fri, 9 Jun 2017 11:42:30 +0000 (19:42 +0800)]
netlink: add decoding of NETLINK_CRYPTO nlmsg_flags

* netlink.c (decode_nlmsg_flags): Add NETLINK_CRYPTO.

6 years agotests: check decoding of NETLINK_CRYPTO message types
JingPiao Chen [Sun, 9 Jul 2017 13:57:19 +0000 (21:57 +0800)]
tests: check decoding of NETLINK_CRYPTO message types

* configure.ac (AC_CHECK_HEADERS): Add linux/cryptouser.h.
* tests/netlink_crypto.c: New file.
* tests/gen_tests.in (netlink_crypto): New entry.
* tests/pure_executables.list: Add netlink_crypto.
* tests/.gitignore: Likewise.

6 years agonetlink: add decoding of NETLINK_CRYPTO message types
JingPiao Chen [Fri, 9 Jun 2017 09:47:49 +0000 (17:47 +0800)]
netlink: add decoding of NETLINK_CRYPTO message types

* xlat/nl_crypto_types.in: New file.
* netlink.c: Include "xlat/nl_crypto_types.h".
(nlmsg_types): Add NETLINK_CRYPTO.

6 years agotests: introduce TEST_NETLINK and TEST_NETLINK_ macros
JingPiao Chen [Sat, 8 Jul 2017 08:36:46 +0000 (16:36 +0800)]
tests: introduce TEST_NETLINK and TEST_NETLINK_ macros

* tests/test_netlink.h: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
* tests/netlink_sock_diag.c: Include "test_netlink.h"
instead of "netlink.h".
(TEST_SOCK_DIAG): New macro.
(test_unix_diag_req, test_unix_diag_msg,
test_netlink_diag_req, test_netlink_diag_msg,
test_packet_diag_req, test_packet_diag_msg,
test_inet_diag_req, test_inet_diag_req_v2,
test_inet_diag_msg, test_smc_diag_req,
test_smc_diag_msg): Use it.
(test_odd_family_req, test_odd_family_msg,
test_inet_diag_sockid): Use TEST_NETLINK macro.

6 years agotests: check decoding of nlattr_inet_diag_req_v2 attributes
JingPiao Chen [Wed, 5 Jul 2017 07:48:28 +0000 (15:48 +0800)]
tests: check decoding of nlattr_inet_diag_req_v2 attributes

* tests/nlattr_inet_diag_req_v2.c: New file.
* tests/gen_tests.in (nlattr_inet_diag_req_v2): New entry.
* tests/pure_executables.list: Add nlattr_inet_diag_req_v2.
* tests/.gitignore: Likewise.

6 years agotests: check decoding of nlattr_inet_diag_req_compat attributes
JingPiao Chen [Wed, 5 Jul 2017 07:46:43 +0000 (15:46 +0800)]
tests: check decoding of nlattr_inet_diag_req_compat attributes

* tests/nlattr_inet_diag_req_compat.c: New file.
* tests/gen_tests.in (nlattr_inet_diag_req_compat): New entry.
* tests/pure_executables.list: Add nlattr_inet_diag_req_compat.
* tests/.gitignore: Likewise.

6 years agonetlink: decode AF_INET inet_diag_req_* attributes
JingPiao Chen [Wed, 24 May 2017 06:55:59 +0000 (14:55 +0800)]
netlink: decode AF_INET inet_diag_req_* attributes

* linux/inet_diag.h (inet_diag_bc_op, inet_diag_hostcond,
inet_diag_markcond): New structures.
(INET_DIAG_BC_*): New enum.
* netlink_sock_diag.c: Include "xlat/inet_diag_bytecodes.h".
(decode_inet_addr, decode_inet_diag_hostcond,
print_inet_diag_bc_op, decode_inet_diag_markcond,
decode_bytecode_data, decode_inet_diag_bc_op): New functions.
(inet_diag_req_nla_decoders): New array.
(decode_inet_diag_req_compat, decode_inet_diag_req_v2): Use it.
* xlat/inet_diag_bytecodes.in: New file.

6 years agoIntroduce PRINT_FIELD_CSTRING
Dmitry V. Levin [Tue, 11 Jul 2017 00:20:54 +0000 (00:20 +0000)]
Introduce PRINT_FIELD_CSTRING

* print_fields.h (PRINT_FIELD_CSTRING): New macro.
* block.c (print_blkpg_req, block_ioctl): Use PRINT_FIELD_CSTRING
instead of print_quoted_string.
* btrfs.c (btrfs_ioctl): Likewise.
* dm.c (dm_decode_device, dm_decode_dm_target_spec): Likewise.
* loop.c (decode_loop_info, decode_loop_info64): Likewise.
* v4l2.c (print_v4l2_capability, print_v4l2_fmtdesc,
print_v4l2_standard, print_v4l2_input, print_v4l2_tuner,
print_v4l2_queryctrl): Likewise.
* netlink_sock_diag.c (decode_smc_diag_lgrinfo): Use PRINT_FIELD_CSTRING
instead of PRINT_FIELD_STRING.
* uname.c (PRINT_UTS_MEMBER): Remove.
(SYS_FUNC(uname)): Use PRINT_FIELD_CSTRING instead of PRINT_UTS_MEMBER.

6 years agoRename PRINT_FIELD_QUOTED_STRING to PRINT_FIELD_STRING
Dmitry V. Levin [Tue, 11 Jul 2017 00:20:54 +0000 (00:20 +0000)]
Rename PRINT_FIELD_QUOTED_STRING to PRINT_FIELD_STRING

As string fields are always qouted when printed, choose a shorter name
for the helper macro.

* print_fields.h (PRINT_FIELD_QUOTED_STRING): Rename
to PRINT_FIELD_STRING.  All callers updated.

6 years agoUpdate RWF_* constants
Dmitry V. Levin [Mon, 10 Jul 2017 15:27:51 +0000 (15:27 +0000)]
Update RWF_* constants

* xlat/rwf_flags.in: Add RWF_NOWAIT introduced by linux kernel
commit v4.12-rc5-150-gb745fafa.

6 years agoIntorduce PRINT_FIELD_0X
Dmitry V. Levin [Mon, 10 Jul 2017 02:23:00 +0000 (02:23 +0000)]
Intorduce PRINT_FIELD_0X

* print_fields.h (PRINT_FIELD_0X): New macro.
* sockaddr.c (print_sockaddr_data_ipx, print_sockaddr_data_nl): Use it
instead of manual tprintf statements.
* netlink_sock_diag.c (PRINT_FIELD_SMC_DIAG_CONNINFO_FLAGS): Remove.
(decode_smc_diag_conninfo): Replace it with PRINT_FIELD_0X.

6 years agoprint_inet_addr: use inet_addr-based output format for IPv4
Dmitry V. Levin [Mon, 10 Jul 2017 01:45:18 +0000 (01:45 +0000)]
print_inet_addr: use inet_addr-based output format for IPv4

* sockaddr.c (print_inet_addr): Remove af_name variable.
<AF_INET>: Use inet_addr-based output format.
* tests/netlink_sock_diag.c (test_inet_diag_sockid, test_inet_diag_req,
test_inet_diag_req_v2, test_inet_diag_msg, test_smc_diag_req,
test_smc_diag_msg): Update expected output.
* tests/nlattr_inet_diag_msg.c (print_inet_diag_msg): Likewise.
* tests/nlattr_smc_diag_msg.c (print_smc_diag_msg): Likewise.

6 years agotests: check decoding of netlink smc_diag_msg attributes
JingPiao Chen [Mon, 26 Jun 2017 00:32:08 +0000 (08:32 +0800)]
tests: check decoding of netlink smc_diag_msg attributes

* tests/nlattr_smc_diag_msg.c: New file.
* tests/gen_tests.in (nlattr_smc_diag_msg): New entry.
* tests/pure_executables.list: Add nlattr_smc_diag_msg.
* tests/.gitignore: Likewise.

6 years agonetlink: decode AF_SMC smc_diag_msg attributes
JingPiao Chen [Sun, 21 May 2017 11:49:43 +0000 (19:49 +0800)]
netlink: decode AF_SMC smc_diag_msg attributes

* linux/smc_diag.h (smc_diag_cursor, smc_diag_conninfo
smc_diag_linkinfo, smc_diag_lgrinfo): New structures.
* netlink_sock_diag.c: Include "xlat/smc_link_group_roles.h".
(decode_smc_diag_conninfo, decode_smc_diag_lgrinfo): New functions.
(smc_diag_msg_nla_decoders): New array.
(decode_smc_diag_msg): Use it.
* xlat/smc_link_group_roles.in: New file.

6 years agopathtrace.c: introduce user-provided sets of paths
Nikolay Marchuk [Sat, 8 Jul 2017 08:28:56 +0000 (15:28 +0700)]
pathtrace.c: introduce user-provided sets of paths

* defs.h (struct path_set): New structure.
(global_path_set): New variable prototype.
(tracing_paths): Change macro body to use global_path_set variable.
(pathtrace_select_set): Add "struct path_set *" argument.
(pathtrace_match_set): Likewise.  Change return type to bool.
(pathtrace_select, pathtrace_match): Change into thin macro wrappers
around pathtrace_select_set and pathtrace_match_set, repsectively.
* pathtrace.c (global_path_set): New variable.
(storepath, pathtrace_select_set): Add "struct path_set *" argument.
(pathmatch, upathmatch, fdmatch, pathtrace_match_set): Likewise.
Change return type to bool.

6 years agotests: check decoding of MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
tests: check decoding of MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP

* tests/group_req.c: New file.
* tests/gen_tests.in (group_req): New entry.
* tests/pure_executables.list: Add group_req.
* tests/.gitignore: Likewise.

6 years agoMpersify struct group_req
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
Mpersify struct group_req

The size of struct group_req depends on alignment of long and therefore
has to be mpersified.

* print_group_req.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* net.c (print_group_req): Move to print_group_req.c, wrap into
MPERS_PRINTER_DECL.

6 years agonet: enhance decoding of MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
net: enhance decoding of MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP

* net.c (print_group_req): Allow option length greater than
sizeof(struct group_req) to match the kernel behaviour.
When the option length is invalid, print the address.
* NEWS: Mention this.

6 years agonet: hook up MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP decoding for SOL_IPV6
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
net: hook up MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP decoding for SOL_IPV6

As multicast socket options are shared between IPv4 and IPv6,
they should be decoded both for SOL_IP and SOL_IPV6.

* net.c (print_setsockopt) <SOL_IPV6> [MCAST_JOIN_GROUP]: Handle
MCAST_JOIN_GROUP and MCAST_LEAVE_GROUP.

6 years agoxlat: add MCAST_* to sockipv6options
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
xlat: add MCAST_* to sockipv6options

Multicast socket options are shared between IPv4 and IPv6.

* xlat/sockipv6options.in: Add MCAST_JOIN_GROUP, MCAST_BLOCK_SOURCE,
MCAST_UNBLOCK_SOURCE, MCAST_LEAVE_GROUP, MCAST_JOIN_SOURCE_GROUP,
MCAST_LEAVE_SOURCE_GROUP, and MCAST_MSFILTER.

6 years agonet: enhance decoding of IP_ADD_MEMBERSHIP et al socket options
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
net: enhance decoding of IP_ADD_MEMBERSHIP et al socket options

* net.c (print_mreq, print_mreq6): Treat negative option length
as invalid to match the kernel behaviour.  When the option length
is invalid, print the address.
* NEWS: Mention it.
* tests/ip_mreq.c (main): Check it.  Update expected output.

6 years agonet: enhance decoding of setsockopt's SO_LINGER negative option length
Dmitry V. Levin [Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)]
net: enhance decoding of setsockopt's SO_LINGER negative option length

* net.c (print_set_linger): Treat negative option length as invalid
to match the kernel behaviour.
* tests/so_linger.c (main): Check it.

6 years agomsghdr: use PRINT_FIELD_* macros
Dmitry V. Levin [Sun, 9 Jul 2017 16:04:24 +0000 (16:04 +0000)]
msghdr: use PRINT_FIELD_* macros

* msghdr.c (print_scm_creds): Use PRINT_FIELD_U and PRINT_FIELD_UID.
(print_cmsg_ip_recverr): Use PRINT_FIELD_U.
(print_struct_msghdr): Use PRINT_FIELD_U and PRINT_FIELD_FLAGS.

6 years agoIntorduce PRINT_FIELD_SOCKADDR
Dmitry V. Levin [Sun, 9 Jul 2017 16:04:24 +0000 (16:04 +0000)]
Intorduce PRINT_FIELD_SOCKADDR

* print_fields.h (PRINT_FIELD_SOCKADDR): New macro.
* msghdr.c (print_cmsg_ip_recverr): Use it instead of print_sockaddr.
* net.c (print_group_req): Likewise.
* sock.c (PRINT_IFREQ_ADDR): Remove.
(print_ifreq, print_ifconf_ifreq): Use PRINT_FIELD_SOCKADDR
instead of PRINT_IFREQ_ADDR.

6 years agoprint_sockaddr: remove "struct tcb *" argument
Dmitry V. Levin [Sun, 9 Jul 2017 16:04:24 +0000 (16:04 +0000)]
print_sockaddr: remove "struct tcb *" argument

print_sockaddr does not use its first argument, remove it.

* defs.h (print_sockaddr): Remove argument.
* sockaddr.c (print_sockaddr): Remove argument.  All callers updated.
* sock.c (PRINT_IFREQ_ADDR): Likewise.

6 years agonet: use PRINT_FIELD_* macros
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
net: use PRINT_FIELD_* macros

* net.c (print_tpacket_stats, print_tpacket_req): Use PRINT_FIELD_U.
(print_group_req): Use PRINT_FIELD_IFINDEX.
(print_packet_mreq): Use PRINT_FIELD_IFINDEX, PRINT_FIELD_U,
and PRINT_FIELD_XVAL.

6 years agonetlink_sock_diag: introduce PRINT_FIELD_INET_DIAG_SOCKID
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
netlink_sock_diag: introduce PRINT_FIELD_INET_DIAG_SOCKID

* netlink_sock_diag.c (PRINT_FIELD_INET_DIAG_SOCKID): New macro.
(decode_inet_diag_req_compat, decode_inet_diag_req_v2,
decode_inet_diag_msg, decode_smc_diag_req, decode_smc_diag_msg): Use it
instead of print_inet_diag_sockid.

6 years agoIntorduce PRINT_FIELD_DEV
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
Intorduce PRINT_FIELD_DEV

* print_fields.h (PRINT_FIELD_DEV): New macro.
* dm.c (dm_decode_device, dm_decode_dm_name_list): Use it
instead of print_dev_t.
* loop.c (decode_loop_info, decode_loop_info64): Likewise.
* netlink_sock_diag.c (decode_unix_diag_vfs): Likewise.

6 years agoIntorduce PRINT_FIELD_INET4_ADDR
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
Intorduce PRINT_FIELD_INET4_ADDR

* print_fields.h (PRINT_FIELD_INET4_ADDR): New macro.
* msghdr.c (print_cmsg_ip_pktinfo): Use it instead of manual
tprintf statements.
* net.c (print_mreq): Likewise.
* sockaddr.c (print_sockaddr_data_in): Likewise.

6 years agoIntorduce PRINT_FIELD_NET_PORT
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
Intorduce PRINT_FIELD_NET_PORT

* print_fields.h (PRINT_FIELD_NET_PORT): New macro.
* netlink_sock_diag.c (print_inet_diag_sockid): Use it
instead of a manual tprintf statement.
* sockaddr.c (print_sockaddr_data_in, print_sockaddr_data_in6,
print_sockaddr_data_ipx): Likewise.

6 years agoIntorduce PRINT_FIELD_IFINDEX
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
Intorduce PRINT_FIELD_IFINDEX

* print_fields.h (PRINT_FIELD_IFINDEX): New macro.
* msghdr.c (print_cmsg_ip_pktinfo): Use it instead of print_ifindex.
* net.c (print_mreq6): Likewise.
* netlink_sock_diag.c (print_packet_diag_mclist,
print_inet_diag_sockid): Likewise.
* sockaddr.c (print_sockaddr_data_in6, print_sockaddr_data_ll):
Likewise.

6 years agoIntorduce PRINT_FIELD_INET_ADDR
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
Intorduce PRINT_FIELD_INET_ADDR

* print_fields.h (PRINT_FIELD_INET_ADDR): New macro.
* net.c (print_mreq6): Use it instead of print_inet_addr.
* netlink_sock_diag.c (print_inet_diag_sockid): Likewise.
* sockaddr.c (print_sockaddr_data_in6): Likewise.

6 years agonet: move print_ifindex to a separate file
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
net: move print_ifindex to a separate file

* print_ifindex.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* net.c (print_ifindex): Move to print_ifindex.c.

6 years agonet: move parsers of bind, listen, and shutdown to separate files
Dmitry V. Levin [Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)]
net: move parsers of bind, listen, and shutdown to separate files

* bind.c: New file.
* listen.c: Likewise.
* shutdown.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* net.c (SYS_FUNC(bind)): Move to bind.c.
(SYS_FUNC(listen)): Move to listen.c.
(SYS_FUNC(shutdown)): Move to shutdown.c.

7 years agotests: check decoding of packet_diag_msg attributes
JingPiao Chen [Mon, 26 Jun 2017 00:28:56 +0000 (08:28 +0800)]
tests: check decoding of packet_diag_msg attributes

* tests/netlink_sock_diag-v.sh: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/nlattr_packet_diag_msg.c: New file.
* tests/gen_tests.in (nlattr_packet_diag_msg): New entry.
* tests/pure_executables.list: Add nlattr_packet_diag_msg.
* tests/.gitignore: Likewise.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agonetlink: decode AF_PACKET packet_diag_msg attributes
JingPiao Chen [Sun, 21 May 2017 03:42:13 +0000 (11:42 +0800)]
netlink: decode AF_PACKET packet_diag_msg attributes

* linux/packet_diag.h (packet_diag_info, packet_diag_mclist,
packet_diag_ring): New structures.
(PDI_*): New macros.
* netlink_sock_diag.c: Include <linux/filter.h>
and "xlat/packet_diag_info_flags.h".
(decode_packet_diag_info, decode_packet_diag_mclist,
decode_packet_diag_ring, decode_packet_diag_filter): New functions.
(packet_diag_msg_nla_decoders): New array.
(decode_packet_diag_msg): Use it.
* print_fields.h (PRINT_FIELD_QUOTED_STRING): New macro.
* xlat/packet_diag_info_flags.in: New file.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agotests: fix TEST_NLATTR_OBJECT and TEST_NLATTR_ARRAY for large objects
JingPiao Chen [Wed, 5 Jul 2017 01:39:34 +0000 (09:39 +0800)]
tests: fix TEST_NLATTR_OBJECT and TEST_NLATTR_ARRAY for large objects

commit v4.17-161-gdbd0605 that adjusted TEST_NLATTR_OBJECT and
TEST_NLATTR_ARRAY for large objects, only changed the pattern
print length, large length still can be specified as nla_data_len,
resulting to output mismatch.

* tests/test_nlattr.h (TEST_NLATTR_OBJECT): Pass "plen"
both as nla_data_len and slen arguments of TEST_NLATTR_
in len < sizeof(object) case.
(TEST_NLATTR_ARRAY): Likewise, Pass "plen" both as nla_data_len
and slen arguments of TEST_NLATTR_ in len < sizeof(object[0]) case.

7 years agotests: introduce TEST_NLATTR_nla macro in test_nlattr.h
JingPiao Chen [Wed, 5 Jul 2017 13:25:13 +0000 (21:25 +0800)]
tests: introduce TEST_NLATTR_nla macro in test_nlattr.h

Explicitly make struct nlattr * pointer which is internal
to TEST_NLATTR_ macro available to its varadic arguments.

* tests/test_nlattr.h (TEST_NLATTR_): Rename nla to TEST_NLATTR_nla.

7 years agotests: check decoding of SO_PEERCRED socket option
Dmitry V. Levin [Sat, 8 Jul 2017 19:27:26 +0000 (19:27 +0000)]
tests: check decoding of SO_PEERCRED socket option

* tests/so_peercred.c: New file.
* tests/gen_tests.in (so_peercred): New entry.
* tests/pure_executables.list: Add so_peercred.
* tests/.gitignore: Likewise.

7 years agonet: accept arbitrary option length for getsockopt's SO_PEERCRED
Dmitry V. Levin [Sat, 8 Jul 2017 19:27:26 +0000 (19:27 +0000)]
net: accept arbitrary option length for getsockopt's SO_PEERCRED

* print_fields.h (PRINT_FIELD_UID): New macro.
* net.c (print_ucred): Rewrite to match the kernel behaviour.
* NEWS: Mention this.

7 years agotests: check decoding of socket filters
Dmitry V. Levin [Sat, 8 Jul 2017 14:57:44 +0000 (14:57 +0000)]
tests: check decoding of socket filters

* tests/sock_filter-v.c: New file.
* tests/gen_tests.in (sock_filter-v): New entry.
* tests/pure_executables.list: Add sock_filter-v.
* tests/.gitignore: Likewise.

7 years agoImplement decoding of linux socket filter programs
Dmitry V. Levin [Sat, 8 Jul 2017 14:57:44 +0000 (14:57 +0000)]
Implement decoding of linux socket filter programs

* bpf_sock_filter.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/skf_ad.in: New file.
* defs.h (decode_sock_fprog, print_sock_fprog): New prototypes.
* fetch_bpf_fprog.c (get_bpf_fprog_size): New mpers printer.
* net.c (print_getsockopt): Use decode_sock_fprog to print
socket filter programs for SO_GET_FILTER socket option.
(print_setsockopt): Use decode_sock_fprog and get_bpf_fprog_size
to print socket filter programs for SO_ATTACH_FILTER
and SO_ATTACH_REUSEPORT_CBPF socket options.
* NEWS: Mention this.

7 years agotests: check decoding of SO_LINGER socket option
Dmitry V. Levin [Sat, 8 Jul 2017 14:57:44 +0000 (14:57 +0000)]
tests: check decoding of SO_LINGER socket option

* tests/so_linger.c: New file.
* tests/gen_tests.in (so_linger): New entry.
* tests/pure_executables.list: Add so_linger.
* tests/.gitignore: Likewise.

7 years agotests: fix print_quoted_hex output of bytes with high bit set
Dmitry V. Levin [Sat, 8 Jul 2017 14:57:44 +0000 (14:57 +0000)]
tests: fix print_quoted_hex output of bytes with high bit set

* tests/tests.h (print_quoted_memory, print_quoted_hex): Change the type
of first argument from "const char *" to "const void *".
* tests/print_quoted_string.c: Likewise.
(print_quoted_hex): Print bytes as unsigned char objects to avoid
unwanted sign extension.
* tests/netlink_protocol.c (send_query): Remove the cast of print_quoted_hex
first argument which is now redundant.

7 years agonet: accept arbitrary option length for getsockopt's SO_LINGER
Dmitry V. Levin [Sat, 8 Jul 2017 14:57:44 +0000 (14:57 +0000)]
net: accept arbitrary option length for getsockopt's SO_LINGER

* net.c (print_linger): Rename to print_set_linger.
(print_setsockopt): Replace print_linger with print_set_linger.
(print_get_linger): New function that accepts arbitrary option length
to match the kernel behaviour.
(print_getsockopt): Replace print_linger with print_get_linger.
* NEWS: Mention this.

7 years agonet: accept large option length for SO_LINGER
Dmitry V. Levin [Sat, 8 Jul 2017 14:57:44 +0000 (14:57 +0000)]
net: accept large option length for SO_LINGER

* net.c (print_linger): Allow len > sizeof(struct linger) to match
the kernel behaviour.

7 years agonet: fix printing of struct linger's field names
Dmitry V. Levin [Sat, 8 Jul 2017 14:57:44 +0000 (14:57 +0000)]
net: fix printing of struct linger's field names

* net.c: Include "print_fields.h".
(print_linger): Print fields of struct linger using PRINT_FIELD_D.

7 years agonet: enhance decoding of getsockopt's optlen argument
Dmitry V. Levin [Sat, 8 Jul 2017 14:57:44 +0000 (14:57 +0000)]
net: enhance decoding of getsockopt's optlen argument

As the last argument of getsockopt syscall has read-write semantics,
print both user and kernel values when they differ.

* net.c (SYS_FUNC(getsockopt)): On entering syscall, fetch and save
the length specified to the kernel.  On error, print the length saved
on entering.  When the saved length and the length returned by the
kernel differ, print both values.
* NEWS: Mention this.
* tests/net-icmp_filter.c (main): Update expected output.

7 years agonet: move printing of [gs]etsockopt's socklen argument to toplevel parsers
Dmitry V. Levin [Sat, 8 Jul 2017 14:57:44 +0000 (14:57 +0000)]
net: move printing of [gs]etsockopt's socklen argument to toplevel parsers

* net.c (print_getsockopt, print_setsockopt): Remove "done" label,
replace "goto done" statement with "return".
Move printing of "len" argument ...
(SYS_FUNC(getsockopt), SYS_FUNC(setsockopt)): ... here.

7 years agoGeneralize seccomp filter parser
Dmitry V. Levin [Sat, 8 Jul 2017 01:49:00 +0000 (01:49 +0000)]
Generalize seccomp filter parser

Linux socket filter uses almost the same classic BPF as seccomp filter,
The only difference noticeable from strace PoV is the meaning of generic
multiuse field.

Transform the parser of seccomp filters to a more generic parser
of classic BPF, parametrized with a method of parsing the generic
multiuse field in BPF_STMT.

* bpf_filter.c: New file.
* bpf_filter.h: Likewise.
* bpf_fprog.h: Likewise.
* bpf_seccomp_filter.c: Likewise.
* fetch_bpf_fprog.c: Likewise.
* fetch_seccomp_fprog.c: Remove.
* seccomp_fprog.h: Likewise.
* Makefile.am (strace_SOURCES): Add bpf_filter.c, bpf_filter.h,
bpf_fprog.h, bpf_seccomp_filter.c, and fetch_bpf_fprog.c.
Remove fetch_seccomp_fprog.c and seccomp_fprog.h.
* seccomp.c: Do not include linux/filter.h and xlat header files.
Do not define SECCOMP_RET_ACTION.
(bpf_filter, decode_bpf_code, decode_bpf_stmt, decode_bpf_jump,
print_bpf_filter, print_seccomp_fprog, print_seccomp_filter): Remove.
* defs.h (print_seccomp_filter): Rename to decode_seccomp_fprog.
(SYS_FUNC(seccomp)): Replace print_seccomp_filter
with decode_seccomp_fprog.
* prctl.c (SYS_FUNC(prctl)): Likewise.

7 years agoAssume that <linux/filter.h> is always available
Dmitry V. Levin [Sat, 8 Jul 2017 01:49:00 +0000 (01:49 +0000)]
Assume that <linux/filter.h> is always available

<linux/filter.h> was introduced in linux 2.1.75, way before
the minimal kernel version supported by strace.

* configure.ac (AC_CHECK_HEADERS): Remove linux/filter.h.
* seccomp.c: Assume HAVE_LINUX_FILTER_H.
* tests/prctl-seccomp-filter-v.c: Likewise.
* tests/seccomp-filter-v.c: Likewise.
* tests/seccomp-filter.c: Likewise.

7 years agoxlat: add BPF_END to BPF_ALU opcode list
Dmitry V. Levin [Fri, 7 Jul 2017 16:43:41 +0000 (16:43 +0000)]
xlat: add BPF_END to BPF_ALU opcode list

BPF_END is one of three eBPF-only opcodes for BPF_ALU class.
Other two (BPF_MOV and BPF_ARSH) has been added earlier.

* xlat/bpf_op_alu.in: Add BPF_END.

7 years agonetlink_sock_diag: print unrecognized data in hex
JingPiao Chen [Fri, 7 Jul 2017 01:52:06 +0000 (09:52 +0800)]
netlink_sock_diag: print unrecognized data in hex

* netlink_sock_diag.c (decode_family): Replace printstrn with
printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/netlink_sock_diag.c (test_odd_family_req,
test_odd_family_msg): Update expected output.

7 years agonetlink: print unrecognized nlattr in hex
JingPiao Chen [Fri, 7 Jul 2017 01:47:17 +0000 (09:47 +0800)]
netlink: print unrecognized nlattr in hex

* nlattr.c (fetch_nlattr): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/nlattr.c (test_nlattr): Update expected output.

7 years agonetlink: print unrecognized netlink messages in hex
JingPiao Chen [Fri, 7 Jul 2017 01:44:09 +0000 (09:44 +0800)]
netlink: print unrecognized netlink messages in hex

* netlink.c (fetch_nlmsghdr): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/netlink_protocol.c (send_query): Update expected output.

7 years agonetlink: print unrecognized netlink payload in hex
JingPiao Chen [Fri, 7 Jul 2017 01:34:59 +0000 (09:34 +0800)]
netlink: print unrecognized netlink payload in hex

* netlink.c (decode_payload): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/netlink_protocol.c (send_query, test_nlmsgerr,
test_nlmsg_done): Update expected output.
* tests/netlink_generic.c (test_nlmsg_type): Likewise.

7 years agonetlink: print unrecognized nlmsgerr in hex
JingPiao Chen [Fri, 7 Jul 2017 01:10:17 +0000 (09:10 +0800)]
netlink: print unrecognized nlmsgerr in hex

* netlink.c (decode_nlmsgerr): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/netlink_protocol.c (test_nlmsgerr): Update expected output.

7 years agonetlink: print unrecognized attribute data in hex
JingPiao Chen [Tue, 4 Jul 2017 06:21:18 +0000 (14:21 +0800)]
netlink: print unrecognized attribute data in hex

* nlattr.c (decode_nlattr_with_data): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/tests.h (print_quoted_hex): New prototype.
* tests/print_quoted_string.c (print_quoted_hex): New function.
* tests/test_nlattr.h (TEST_NLATTR_OBJECT, TEST_NLATTR_ARRAY): Use it
for updated expected output.  Change the type of "plen" variable
to unsigned int.
* tests/nlattr.c (test_nlattr): Update expected output.

7 years agotests: print quotation marks in print_quoted_memory
JingPiao Chen [Tue, 4 Jul 2017 06:46:21 +0000 (14:46 +0800)]
tests: print quotation marks in print_quoted_memory

* tests/print_quoted_string.c (print_quoted_memory): Print opening
and closing quotation marks.
* tests/getcwd.c (main): Do not print quotation marks around
print_quoted_string.
* tests/uname.c (main): Likewise.
* tests/keyctl.c (print_quoted_string_limit): Do not print quotation
marks around print_quoted_memory.
* tests/netlink_protocol.c (send_query): Likewise.
* tests/xattr.c (main): Likewise.

7 years agostrace.1: remove misleading remark that -i option is weakly supported
Dmitry V. Levin [Thu, 6 Jul 2017 12:52:54 +0000 (12:52 +0000)]
strace.1: remove misleading remark that -i option is weakly supported

Given that -i functionality is covered by pc.test, the remark that
it is weakly supported is wrong.

* strace.1 (BUGS): Remove the remark about weakly supported -i option.

7 years agoPost-release administrivia
Dmitry V. Levin [Thu, 6 Jul 2017 12:50:55 +0000 (12:50 +0000)]
Post-release administrivia

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

7 years agoPrepare for 4.18 release v4.18
Dmitry V. Levin [Wed, 5 Jul 2017 07:08:09 +0000 (07:08 +0000)]
Prepare for 4.18 release

* NEWS: Update for 4.18 release.

7 years agotests: robustify create_nl_socket based tests against the race condition
Dmitry V. Levin [Tue, 4 Jul 2017 22:31:08 +0000 (22:31 +0000)]
tests: robustify create_nl_socket based tests against the race condition

There is a race condition between the moment a netlink socket is created
and the moment it is reported via SOCK_DIAG_BY_FAMILY interface.
Add one more operation on the socket created by create_nl_socket
to increase chances of winning the race.

* tests/create_nl_socket.c (create_nl_socket_ext): Add a getsockopt call
with the created socket.

7 years agoUpdate NEWS
Dmitry V. Levin [Tue, 4 Jul 2017 17:52:54 +0000 (17:52 +0000)]
Update NEWS

7 years agonios2: fix wrong access to "SP" register in user_pt_regs
Romain Naour [Tue, 4 Jul 2017 16:37:18 +0000 (18:37 +0200)]
nios2: fix wrong access to "SP" register in user_pt_regs

Starting with linux commit v4.0-rc4~21^2, "SP" register
is available via regs[PTR_SP] member of struct user_pt_regs.

* linux/nios2/arch_regs.h (nios2_sp_ptr): Change type
to "unsigned int *".
* linux/nios2/arch_regs.c (nios2_sp_ptr): Likewise.
Replace .sp with .regs[PTR_SP].

Fixes: http://autobuild.buildroot.net/results/b9f/b9fc25b82f3280872fe1593ac252a8529ba83576
Fixes: v4.16-34-g6117728a ("nios2: export nios2_sp_ptr")
Signed-off-by: Romain Naour <romain.naour@smile.fr>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agotests: add multi-process check to qual_fault.test
Eugene Syromyatnikov [Mon, 3 Jul 2017 19:29:28 +0000 (21:29 +0200)]
tests: add multi-process check to qual_fault.test

Check that syscall counters used for tampering are per-tcb.

* tests/qual_fault.c: Include <fcntl.h> for open(),
<sys/param.h> for PATH_MAX, and <sys/wait.h> for wait().
(expfd): Rename to exp_fd, remove const qualifier and initialization.
(gotfd): Rename to got_fd, remove const qualifier and initialization.
(out_fd): New variable, for the expected strace output.
(open_file): New helper function.
(main): Remove st, add num_procs, proc, exp_prefix, got_prefix,
out_prefix, pid_prefix.  Remove stat asserts, update argc assert.
Add num_procs, exp_prefix, got_prefix, out_prefix, pid_prefix
initialization.  Add per-process loop, open expfd, gotfd, out_fd, pidfd
in each one, print process's pid to pidfd, print exit message to out_fd.
Add wait() call for each forked process.
* tests/qual_fault.test (N): increase to 100 in order to check
concurrent process execution.
(check_fault_injection): Take additional argument for the process
count, pass it to qual_fault, add filename variables for expected strace
output and pid file, pass them to qual_fault.
Specify -ff parameter to strace invocation.
Compare write and strace output for the each process.
Update all check_fault_injection invocation with process count argument,
add an invocation with 4 concurrent processes.
* tests/init.sh (TIMEOUT_DURATION): Raise from 120 to 300.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agotests: adjust TEST_NLATTR_OBJECT and TEST_NLATTR_ARRAY for large objects
Dmitry V. Levin [Mon, 3 Jul 2017 15:14:54 +0000 (15:14 +0000)]
tests: adjust TEST_NLATTR_OBJECT and TEST_NLATTR_ARRAY for large objects

* tests/test_nlattr.h (TEST_NLATTR_OBJECT, TEST_NLATTR_ARRAY): Add
support for objects larger than DEFAULT_STRLEN.
* tests/nlattr_inet_diag_msg.c (main): Change pattern size
from DEFAULT_STRLEN to 4096.
* tests/nlattr_netlink_diag_msg.c: Likewise.
* tests/nlattr_unix_diag_msg.c: Likewise.

Reported-by: JingPiao Chen <chenjingpiao@gmail.com>
7 years agotests: move DEFAULT_STRLEN macro to tests.h
Dmitry V. Levin [Mon, 3 Jul 2017 15:14:54 +0000 (15:14 +0000)]
tests: move DEFAULT_STRLEN macro to tests.h

* tests/tests.h [!DEFAULT_STRLEN] (DEFAULT_STRLEN): New macro.
* tests/mincore.c (DEFAULT_STRLEN): Remove.
* tests/mmsg_name.c: Likewise.
* tests/msg_control.c: Likewise.
* tests/netlink_protocol.c: Likewise.
* tests/nlattr.c: Likewise.
* tests/nlattr_inet_diag_msg.c: Likewise.
* tests/nlattr_netlink_diag_msg.c: Likewise.
* tests/nlattr_unix_diag_msg.c: Likewise.
* tests/printstr.c: Likewise.
* tests/xattr.c: Likewise.
* tests/execve.c: Likewise.
(main): Initialize str_a and str_b arrays at run time.
* tests/execveat.c: Likewise.

Suggested-by: JingPiao Chen <chenjingpiao@gmail.com>
7 years agotests: use unified diff in order to improve test log readability
Eugene Syromyatnikov [Sun, 2 Jul 2017 18:03:09 +0000 (21:03 +0300)]
tests: use unified diff in order to improve test log readability

* tests/init.sh (match_diff): Add -u option to the diff invocation.

7 years agoFix error diagnostics in case of zero argc
Dmitry V. Levin [Sun, 2 Jul 2017 10:01:22 +0000 (10:01 +0000)]
Fix error diagnostics in case of zero argc

* strace.c (init): Adjust argc along with argv,
check that adjusted argc is sane.
* tests/zeroargc.c: New file.
* tests/.gitignore: Add zeroargc.
* tests/Makefile.am (check_PROGRAMS): Likewise.
* tests/options-syntax.test: Check strace error diagnostics
in case of zero argc.

7 years agoUse program_invocation_name instead of a local progname variable
Dmitry V. Levin [Sun, 2 Jul 2017 00:31:50 +0000 (00:31 +0000)]
Use program_invocation_name instead of a local progname variable

Emulate program_invocation_name only if it is not provided by libc.

* configure.ac: Check for program_invocation_name variable.
* strace.c (progname): Remove.
[!HAVE_PROGRAM_INVOCATION_NAME] (program_invocation_name): New variable.
(verror_msg, error_msg_and_help): Use it instead of progname.
(init): Initialize program_invocation_name instead of progname.

7 years agoIntroduce generic STRINGIFY and STRINGIFY_VAL macros
Dmitry V. Levin [Sun, 2 Jul 2017 00:11:31 +0000 (00:11 +0000)]
Introduce generic STRINGIFY and STRINGIFY_VAL macros

* macros.h (STRINGIFY, STRINGIFY_VAL): New macros.
* mpers_type.h: Include "macros.h".
[IN_MPERS] (STRINGIFY): Remove.
* tests/sockname.c (TEST_SYSCALL_STR__, TEST_SYSCALL_STR_): Remove.
(TEST_SYSCALL_STR): Use STRINGIFY_VAL.

Co-authored-by: Victor Krapivensky <krapivenskiy.va@phystech.edu>
7 years agoIntroduce macros.h
Dmitry V. Levin [Sun, 2 Jul 2017 00:11:31 +0000 (00:11 +0000)]
Introduce macros.h

Introduce a separate header file for generic macros shared between
strace and its tests.  Start this unification with ARRAY_SIZE macro.

* defs.h: Include "macros.h".
(ARRAY_SIZE): Move ...
* macros.h: ... to new file.
* Makefile.am (strace_SOURCES): Add it.
* tests/tests.h: Include "macros.h".
(ARRAY_SIZE): Remove.  All callers updated.

7 years agoquota: use PRINT_FIELD_FLAGS
Dmitry V. Levin [Sat, 1 Jul 2017 20:08:39 +0000 (20:08 +0000)]
quota: use PRINT_FIELD_FLAGS

* quota.c (struct xfs_dqblk): Change d_flags field's type from int8_t
to uint8_t.
(decode_cmd_data): Use PRINT_FIELD_FLAGS.

7 years agoUnify different generic PRINT_FIELD_* implementations
Dmitry V. Levin [Sat, 1 Jul 2017 13:14:49 +0000 (13:14 +0000)]
Unify different generic PRINT_FIELD_* implementations

Create a new header print_fields.h and move generic PRINT_FIELD_*
macros there.

* print_fields.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* netlink_sock_diag.c: Include "print_fields.h".
(PRINT_FIELD_U, PRINT_FIELD_X, PRINT_FIELD_COOKIE, PRINT_FIELD_FLAGS,
PRINT_FIELD_XVAL): Move to print_fields.h file.
* quota.c: Include "print_fields.h".
(PRINT_FIELD_D): Move to print_fields.h file.
(PRINT_FIELD_U, PRINT_FIELD_X): Remove.
* statx.c: Include "print_fields.h".
(PRINT_FIELD_U): Remove.
(SYS_FUNC(statx)): Update PRINT_FIELD_U callers.
* tests/quotactl.h: Include "print_fields.h".
* tests/quotactl-xfs.c: Update callers of PRINT_FIELD_* macros.
* tests/quotactl.c: Likewise.
(PRINT_FIELD_D, PRINT_FIELD_U, PRINT_FIELD_X): Remove.
* tests/test_nlattr.h: Include "print_fields.h".
(PRINT_FIELD_U, PRINT_FIELD_X): Remove.
* tests/xstatx.c: Include "print_fields.h".
(PRINT_FIELD_U): Remove.
(print_stat): Update PRINT_FIELD_U callers.
* tests/tests.h [!STRACE_PRINTF] (STRACE_PRINTF): Define to printf.

7 years agoarc: fix wrong access to "sp" member in user_regs_struct
Eugeniy Paltsev [Fri, 30 Jun 2017 13:14:14 +0000 (16:14 +0300)]
arc: fix wrong access to "sp" member in user_regs_struct

"sp" register is a member of "scratch" structure (which is nested
in user_regs_struct)

* linux/arc/arch_regs.c: Replace .sp with .scratch.sp .

Fixes: v4.16-31-g134042a5 ("arc: export arc_sp_ptr")
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>