]> granicus.if.org Git - strace/log
strace
4 years agoRemove XLAT_END master
Dmitry V. Levin [Wed, 23 Oct 2019 23:31:26 +0000 (23:31 +0000)]
Remove XLAT_END

* xlat.h (XLAT_END): Remove.
* process.c (struct_user_offsets_data): Replace XLAT_END with a zero
xlat_data entry.

Complements: v5.3~105 "Add xlat description structure"

4 years agobfin, csky, m68k, sh: fix build regression
Dmitry V. Levin [Wed, 23 Oct 2019 23:31:26 +0000 (23:31 +0000)]
bfin, csky, m68k, sh: fix build regression

* xlat/cacheflush_flags.in: New file.
* cacheflush.c [M68K || BFIN || CSKY || SH] (cacheflush_flags): Remove,
include "xlat/cacheflush_flags.h" instead.

Fixes: v5.3~105 "Add xlat description structure"
4 years agostrace.spec.in: add support for old distros that cannot handle .tar.xz
Eugene Syromyatnikov [Wed, 21 Sep 2016 00:23:57 +0000 (03:23 +0300)]
strace.spec.in: add support for old distros that cannot handle .tar.xz

4 years agoxlat: update V4L2_CTRL_TYPE_* constants
Eugene Syromyatnikov [Thu, 1 Nov 2018 17:22:50 +0000 (18:22 +0100)]
xlat: update V4L2_CTRL_TYPE_* constants

* xlat/v4l2_control_types.in: Add fallback definitions for constants,
and #sorted.
* configure.ac (AC_CHECK_MEMBERS): Check for struct
v4l2_ext_control.string field.
* v4l2.c (print_v4l2_ext_control): Change guard macro
to HAVE_STRUCT_V4L2_EXT_CONTROL_STRING.

4 years agoxlat: update V4L2_COLORSPACE_* constants
Eugene Syromyatnikov [Sun, 20 Oct 2019 20:01:15 +0000 (22:01 +0200)]
xlat: update V4L2_COLORSPACE_* constants

* xlat/v4l2_colorspaces.in: Add #value_indexed.
(V4L2_COLORSPACE_DEFAULT): New constant introduced by Linux commit
v4.2-rc1~107^2~184.
(V4L2_COLORSPACE_ADOBERGB): Rename to V4L2_COLORSPACE_OPRGB, per Linux
commit v4.20-rc1~69^2~122.
(V4L2_COLORSPACE_SMPTE170M, V4L2_COLORSPACE_SMPTE240M,
V4L2_COLORSPACE_REC709, V4L2_COLORSPACE_BT878,
V4L2_COLORSPACE_470_SYSTEM_M, V4L2_COLORSPACE_470_SYSTEM_BG,
V4L2_COLORSPACE_JPEG, V4L2_COLORSPACE_SRGB, V4L2_COLORSPACE_OPRGB,
V4L2_COLORSPACE_BT2020, V4L2_COLORSPACE_RAW, V4L2_COLORSPACE_DCI_P3):
Add fallback definitions.

4 years agoxlat: Provide fallback definitions for V4L2_FIELD_* constants
Eugene Syromyatnikov [Sun, 20 Oct 2019 19:06:28 +0000 (21:06 +0200)]
xlat: Provide fallback definitions for V4L2_FIELD_* constants

* xlat/v4l2_fields.in: Add fallback definitions for constants.

4 years agoxlat: update V4L2_BUF_TYPE_* constants
Eugene Syromyatnikov [Thu, 3 Jan 2019 14:40:36 +0000 (15:40 +0100)]
xlat: update V4L2_BUF_TYPE_* constants

* xlat/v4l2_buf_types.in: Add fallback definitions for constants,
mention V4L2_BUF_TYPE_PRIVATE in comment, add #value_indexed.
* configure.ac (AC_CHECK_MEMBERS): Add checks for
struct v4l2_format.fmt.pix_mp, struct v4l2_format.fmt.sdr, and
struct v4l2_format.fmt.sliced.
* v4l2.c (print_v4l2_format_fmt): Use the relevant HAVE_STRUCT_* macros
instead of HAVE_DECL_V4L2_BUF_TYPE_*.

4 years agoxlat: provide fallback definitions for V4L2_CAP_* constants
Eugene Syromyatnikov [Thu, 3 Jan 2019 14:39:26 +0000 (15:39 +0100)]
xlat: provide fallback definitions for V4L2_CAP_* constants

* xlat/v4l2_device_capabilities_flags.in: Sort, add fallback definitions
for constants.
* configure.ac (AC_CHECK_MEMBERS): Check for struct
v4l2_capability.device_caps.
* v4l2.c (print_v4l2_capability): Change V4L2_CAP_DEVICE_CAPS guard
to HAVE_STRUCT_V4L2_CAPABILITY_DEVICE_CAPS.

4 years agoevdev: decode struct input_absinfo regardless of in-kernel definitions
Eugene Syromyatnikov [Thu, 17 Oct 2019 13:29:50 +0000 (15:29 +0200)]
evdev: decode struct input_absinfo regardless of in-kernel definitions

* evdev.c (struct_input_absinfo): New typedef.
(abs_ioctl): Add code argument. Add orig_sz, res_sz, sz, read_sz local
variables. Decode resolution field regardless of
HAVE_STRUCT_INPUT_ABSINFO_RESOLUTION.
(evdev_read_ioctl, evdev_write_ioctl): Pass code to abs_ioctl.
* tests/ioctl_evdev-success.c (print_input_absinfo): Update expected
output.
(main): Add absinfo_sz, absinfo_24, absinfo_32 local variables; add
additional checks for struct input_absinfo.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agoevdev: do not rely on EVIOC* constants provided in <linux/input.h>
Eugene Syromyatnikov [Sun, 13 Oct 2019 15:18:38 +0000 (17:18 +0200)]
evdev: do not rely on EVIOC* constants provided in <linux/input.h>

* xlat/evdev_ioctl_cmds.in: New file.
* configure.ac (AC_CHECK_HEADERS([linux/input.h])): Check for struct
input_keymap_entry and struct input_mask.
* evdev.c [!INPUT_PROP_MAX] (INPUT_PROP_MAX): New macro definition.
(struct_input_keymap_entry, struct_input_mask): New typedefs.
[HAVE_STRUCT_INPUT_KEYMAP_ENTRY]: Add a static_assert to check
that sizeof(struct input_keymap_entry) has the expected value.
[HAVE_STRUCT_INPUT_MASK]: Add a static_assert to check
that sizeof(struct input_mask) has the expected value.
[!EVIOCGPROP] (EVIOCGPROP): New macro definition.
[!EVIOCGMTSLOTS] (EVIOCGMTSLOTS): Likewise.
[!EVIOCGSW] (EVIOCGSW): Likewise.
[!EVIOCGKEYCODE_V2] (keycode_V2_ioctl): Remove guard.
(keycode_V2_ioctl): Change type of ike to struct_input_keymap_entry.
[!EVIOCGMTSLOTS] (mtslots_ioctl): Remove guard.
[!EVIOCGREP || EVIOCSREP] (repeat_ioctl): Likewise.
(evdev_read_ioctl) [!EVIOCGREP] <case EVIOCGREP>: Likewise.
(evdev_read_ioctl) [!EVIOCGKEYCODE_V2] <case EVIOCGKEYCODE_V2>:
Likewise.
(evdev_read_ioctl) [!EVIOCGMTSLOTS] <case EVIOCGMTSLOTS>: Likewise.
(evdev_read_ioctl) [!EVIOCGPROP] <case EVIOCGPROP>: Likewise.
(evdev_read_ioctl) [!EVIOCGSW] <case EVIOCGSW>: Likewise.
(evdev_write_ioctl) [!EVIOCSREP] <case EVIOCSREP>: Likewise.
(evdev_write_ioctl) [!EVIOCSKEYCODE_V2] <case EVIOCSKEYCODE_V2>: Likewise.
(evdev_write_ioctl) [!EVIOCREVOKE] <case EVIOCREVOKE>: Likewise.
(evdev_write_ioctl) [!EVIOCSCLOCKID] <case EVIOCSCLOCKID>: Likewise.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agotests/nsyscalls.c: remove redundant definition of SYSCALL_BIT
Dmitry V. Levin [Mon, 21 Oct 2019 21:12:38 +0000 (21:12 +0000)]
tests/nsyscalls.c: remove redundant definition of SYSCALL_BIT

Starting with commit v5.3~111, tests/nsyscalls.c includes "scno.h"
which already defines SYSCALL_BIT where appropriate.

* tests/nsyscalls.c (SYSCALL_BIT): Remove.

4 years agotests: replace "sed -E" with "sed -r"
Dmitry V. Levin [Mon, 21 Oct 2019 00:07:20 +0000 (00:07 +0000)]
tests: replace "sed -E" with "sed -r"

because the latter is more portable.

* tests/strace-D.test: Replace "sed -E" with "sed -r".

4 years agoxlat: add BPF_MAP_TYPE_DEVMAP_HASH to bpf_map_types
Eugene Syromyatnikov [Sun, 20 Oct 2019 18:10:04 +0000 (20:10 +0200)]
xlat: add BPF_MAP_TYPE_DEVMAP_HASH to bpf_map_types

* xlat/bpf_map_types.in (BPF_MAP_TYPE_DEVMAP_HASH): New constant,
introduced by Linux commit v5.4-rc1~131^2~248^2~16^2~3.
* tests/bpf.c: Update expected output.

4 years agoxlat: add BPF_F_CLONE to bpf_map_flags
Eugene Syromyatnikov [Sun, 20 Oct 2019 17:07:24 +0000 (19:07 +0200)]
xlat: add BPF_F_CLONE to bpf_map_flags

* xlat/bpf_map_flags.in (BPF_F_CLONE): New flag, introduced by Linux
commit v5.4-rc1~131^2~62^2~34^2~2.
* tests/bpf.c: Update expected output.

4 years agoxlat: add BPF_F_TEST_STATE_FREQ to bpf_prog_flags
Eugene Syromyatnikov [Sun, 20 Oct 2019 16:43:43 +0000 (18:43 +0200)]
xlat: add BPF_F_TEST_STATE_FREQ to bpf_prog_flags

* xlat/bpf_prog_flags.in (BPF_F_TEST_STATE_FREQ): New constant,
introduced by Linux commit v5.4-rc1~131^2~62^2~17^2~3.
* tests/bpf.c: Update expected output.

4 years agoxlat: update waitid_types
Eugene Syromyatnikov [Sun, 20 Oct 2019 17:21:55 +0000 (19:21 +0200)]
xlat: update waitid_types

* xlat/waitid_types.in (P_PIDFD): New constant, introduced by Linux
commit v5.4-rc1~203^2~4.
(P_ALL, P_PID, P_PGID): Add fallback values.
(P_PPID, P_SID, P_CID, P_UID, P_GID, P_LWPID): Remove.

4 years agoxlat: update v4l2_format_description_flags
Eugene Syromyatnikov [Sun, 20 Oct 2019 17:05:16 +0000 (19:05 +0200)]
xlat: update v4l2_format_description_flags

* xlat/v4l2_format_description_flags.in (V4L2_FMT_FLAG_COMPRESSED,
V4L2_FMT_FLAG_EMULATED): Add fallback definitions.
(V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM): New constant, introduced by Linux
commit v5.4-rc1~145^2~69.
(V4L2_FMT_FLAG_DYN_RESOLUTION): New constant, introduced by Linux commit
v5.4-rc1~145^2~68.

4 years agoxlat: update sock_sctp_options
Eugene Syromyatnikov [Sun, 20 Oct 2019 16:41:34 +0000 (18:41 +0200)]
xlat: update sock_sctp_options

* xlat/sock_sctp_options.in (SCTP_ASCONF_SUPPORTED): New constant,
introduced by Linux commit v5.4-rc1~131^2~204^2~4.
(SCTP_AUTH_SUPPORTED): New constant, introduced by Linux commit
v5.4-rc1~131^2~204^2~1.
(SCTP_ECN_SUPPORTED): New constant, introduced by Linux commit
v5.4-rc1~131^2~140^2.

4 years agoxlat: add EROFS_SUPER_MAGIC_V1 to fsmagic
Eugene Syromyatnikov [Sun, 20 Oct 2019 16:40:12 +0000 (18:40 +0200)]
xlat: add EROFS_SUPER_MAGIC_V1 to fsmagic

* xlat/fsmagic.in (EROFS_SUPER_MAGIC_V1): New constant, introduced
by Linux commit v5.4-rc1~134^2~105.

4 years agortnl_route: decode struct rta_mfc_stats and struct rtvia unconditionally
Eugene Syromyatnikov [Sun, 20 Oct 2019 10:59:51 +0000 (12:59 +0200)]
rtnl_route: decode struct rta_mfc_stats and struct rtvia unconditionally

* rtnl_route.c (struct_rta_mfc_stats, struct_rtvia): New typedefs.
[HAVE_STRUCT_RTA_MFC_STATS]: Add a static_assert to check
that sizeof(struct rta_mfc_stats) has the expected value.
[HAVE_STRUCT_RTVIA]: Add a static_assert to check that sizeof(struct
rtvia) has the expected value.
(decode_rta_mfc_stats) [HAVE_STRUCT_RTA_MFC_STATS]: Remove guard.
(decode_rta_mfc_stats): Change the type of mfcs variable to
struct_rta_mfc_stats.
(decode_rtvia): Change the type of via variable to struct_rtvia.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agortnl_neightbl: always decode struct ndt_config and struct ndt_stats
Eugene Syromyatnikov [Thu, 17 Oct 2019 13:50:09 +0000 (15:50 +0200)]
rtnl_neightbl: always decode struct ndt_config and struct ndt_stats

* rtnl_neightbl.c (struct_ndt_config, struct_ndt_stats): New typedefs.
[HAVE_STRUCT_NDT_CONFIG]: New static_assert to check
that sizeof(struct ndt_config) has the expected value.
[HAVE_STRUCT_NDT_STATS]: New static_assert to check
that sizeof(struct ndt_stats) has the expected value.
(decode_ndt_config) [HAVE_STRUCT_NDT_CONFIG]: Remove guard.
(decode_ndt_config): Change the type of ndtc variable
to struct_ndt_config.
(decode_ndt_stats) [HAVE_STRUCT_NDT_STATS]: Remove guard.
(decode_ndt_stats): Change the type of ndtst variable
to struct_ndt_stats.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agortnl_mdb: decode messages regardless of availability of kernel headers
Eugene Syromyatnikov [Thu, 10 Oct 2019 11:58:44 +0000 (13:58 +0200)]
rtnl_mdb: decode messages regardless of availability of kernel headers

* netlink_route.c [!HAVE_STRUCT_BR_PORT_MSG]: Do not skip decoding of
RTM_DELMDB, RTM_GETMDB, and RTM_NEWMDB messages.
* rtnl_mdb.c: Remove #ifdef HAVE_STRUCT_BR_PORT_MSG guard.
(struct_br_port_msg, struct_br_mdb_entry): New typedefs.
[HAVE_STRUCT_BR_PORT_MSG]: Static assert check for struct br_port_msg
size.
[HAVE_STRUCT_BR_NDB_ENTRY]: Static assert check for strucr br_mdb_entry
size.
(decode_mdba_mdb_entry_info) [!HAVE_STRUCT_BR_MDB_ENTRY]: Remove.
(decode_mdba_mdb_entry_info): Change entry type to struct_br_mdb_entry.
(decode_mdba_mdb_entry_info) [HAVE_STRUCT_BR_MDB_ENTRY_FLAGS,
HAVE_STRUCT_BR_MDB_ENTRY_VID]: Remove guards.
(decode_br_port_msg): Change bpm type to struct_br_port_msg.
* tests/nlattr_ifinfomsg.c: Use TEST_NLATTR_OBJECT_MINSZ to test
struct rtnl_link_stats printing.
* tests/nlattr_mdba_mdb_entry.c: Update expected output.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agortnl_link: print pad field in the struct ifla_port_vsi decoder
Eugene Syromyatnikov [Sat, 19 Oct 2019 08:44:36 +0000 (10:44 +0200)]
rtnl_link: print pad field in the struct ifla_port_vsi decoder

And steamline the flow a bit.

* rtnl_link.c (decode_ifla_port_vsi): Factor the printing code out of
the conditional statement, add pad field printing.
* tests/nlattr_ifla_port.c: Add check for the pad field printing.

4 years agortnl_link: use internal rtnl_link_stats* and ifla_port_vsi definitions
Eugene Syromyatnikov [Thu, 10 Oct 2019 09:08:51 +0000 (11:08 +0200)]
rtnl_link: use internal rtnl_link_stats* and ifla_port_vsi definitions

Define substitutes for struct rtnl_link_stats, struct
rtnl_link_stats64, and struct ifla_port_vsi internally.
Add a static_assert that informs about future growth of the structures
provided by the kernel headers.

* rtnl_link.c (struct_rtnl_link_stats, struct_rtnl_link_stats64,
struct_ifla_port_vsi): New typedefs.
[HAVE_STRUCT_RTNL_LINK_STATS_RX_NOHANDLER]: Add a static_assert to check
that sizeof(struct rtnl_link_stats) has the expected value.
[HAVE_STRUCT_RTNL_LINK_STATS64_RX_NOHANDLER]: Add a static_assert
to check that sizeof(struct rtnl_link_stats) has the expected value.
[HAVE_STRUCT_IFLA_PORT_VSI]: Add a static_assert to check
that sizeof(struct ifla_port_vsi) has the expected value.
(decode_rtnl_link_stats) [HAVE_STRUCT_RTNL_LINK_STATS_RX_NOHANDLER]:
Remove guard.
(decode_rtnl_link_stats): Change the type of st variable to
struct_rtnl_link_stats; use struct_rtnl_link_stats in offsetofend
statement for min_size definition.
(decode_rtnl_link_stats64) [HAVE_STRUCT_RTNL_LINK_STATS64,
HAVE_STRUCT_RTNL_LINK_STATS64_RX_NOHANDLER]: Remove guards.
(decode_rtnl_link_stats64): Change the type of st variable
to struct_rtnl_link_stats64.
(decode_ifla_port_vsi) [HAVE_STRUCT_IFLA_PORT_VSI]: Remove guard.
(decode_ifla_port_vsi): Change the type of vsi variable
to struct_ifla_port_vsi.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agoEnable building of netlink_crypto decoder without linux/cryptouser.h
Eugene Syromyatnikov [Wed, 9 Oct 2019 18:07:58 +0000 (20:07 +0200)]
Enable building of netlink_crypto decoder without linux/cryptouser.h

* xlat/crypto_msgs.in: New file.
* configure.ac (AC_CHECK_TYPES): Check for struct crypto_user_alg.
* netlink.c: Include "xlat/crypto_msgs.h" with XLAT_MACROS_ONLY defined.
(netlink_decoders[]): Remove HAVE_LINUX_CRYPTOUSER_H guard around
[NETLINK_CRYPTO] item.
* netlink_crypto.c: Remove HAVE_LINUX_CRYPTOUSER_H guard; include
<linux/cryptouser.h> under HAVE_LINUX_CRYPTOUSER_H; include
"xlat/crypto_msgs.h" with XLAT_MACROS_ONLY defined.
[!CRYPTO_MAX_NAME] (CRYPTO_MAX_NAME): New macro.
(struct_crypto_user_alg, struct_crypto_report_hash,
struct_crypto_report_cipher, struct_crypto_report_blkcipher,
struct_crypto_report_aead, struct_crypto_report_rng): New typedefs.
[HAVE_STRUCT_CRYPTO_USER_ALG]: New static_assert to check
that sizeof(struct crypto_user_alg) has the expected value.
[HAVE_STRUCT_CRYPTO_REPORT_HASH]: New static_assert to check
that sizeof(struct crypto_report_hash) has the expected value.
[HAVE_STRUCT_CRYPTO_REPORT_CIPHER]: New static_assert to check
that sizeof(struct crypto_report_cipher) has the expected value.
[HAVE_STRUCT_CRYPTO_REPORT_BLKCIPHER]: New static_assert to check
that sizeof(struct crypto_report_blkcipher) has the expected value.
[HAVE_STRUCT_CRYPTO_REPORT_AEAD]: New static_assert to check
that sizeof(struct crypto_report_aead) has the expected value.
[HAVE_STRUCT_CRYPTO_REPORT_RNG]: New static_assert to check
that sizeof(struct crypto_report_rng) has the expected value.
(decode_crypto_report_hash) [!HAVE_STRUCT_CRYPTO_REPORT_HASH]: Remove.
(decode_crypto_report_hash): Change type of rhash to
struct_crypto_report_hash.
(decode_crypto_report_blkcipher) [!HAVE_STRUCT_CRYPTO_REPORT_BLKCIPHER]:
Remove.
(decode_crypto_report_blkcipher): Change type of rblkcipher to
struct_crypto_report_blkcipher.
(decode_crypto_report_aead) [!HAVE_STRUCT_CRYPTO_REPORT_AEAD]: Remove.
(decode_crypto_report_aead): Change type of raead to
struct_crypto_report_aead.
(decode_crypto_report_rng) [!HAVE_STRUCT_CRYPTO_REPORT_RNG]: Remove.
(decode_crypto_report_rng): Change type of rrng to
struct_crypto_report_rng.
(decode_crypto_report_cipher) [!HAVE_STRUCT_CRYPTO_REPORT_CIPHER]:
Remove.
(decode_crypto_report_cipher): Change type of rcipher to
struct_crypto_report_cipher.
(decode_crypto_user_alg): Change type of alg to struct_crypto_user_alg.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agomacros.h: include <stddef.h>
Eugene Syromyatnikov [Thu, 17 Oct 2019 13:28:46 +0000 (15:28 +0200)]
macros.h: include <stddef.h>

Since offsetofend macro definition relies on presence of offsetof
declaration.

* macros.h: Include <stddef.h>.

4 years agoevdev: remove additional indentation level for switch case labels
Eugene Syromyatnikov [Sun, 13 Oct 2019 15:13:52 +0000 (17:13 +0200)]
evdev: remove additional indentation level for switch case labels

And while we are here, factor out evdev_write_ioctl_mpers call
out of the switch statement.

* evdev.c (bit_ioctl, evdev_read_ioctl, evdev_ioctl): Remove
one indentation level inside the switch statements.
(evedev_write_ioctl): Remove one indentation level inside the switch
statement; move default branch out of the switch statement.

4 years agotests: introduce TEST_NLATTR_OBJECT_MINSZ
Eugene Syromyatnikov [Thu, 10 Oct 2019 16:19:31 +0000 (18:19 +0200)]
tests: introduce TEST_NLATTR_OBJECT_MINSZ

It is useful in cases where a structure grows over time and we support
decoding of only part of it.

* tests/test_nlattr.h (TEST_NLATTR_OBJECT_EX_, TEST_NLATTR_OBJECT_EX):
Add minsz_ parameter, use it instead of sizeof(obj_).
(TEST_NLATTR_OBJECT): Pass sizeof(obj_) as minsz_.
(TEST_NLATTR_OBJECT_MINSZ): New macro.
* tests/nlattr_crypto_user_alg.c (main): Add proper minsz_ argument to
TEST_NLATTR_OBJECT_EX instances.

4 years agoxlat: provide fallback definitions for ABS_MT_* constants
Eugene Syromyatnikov [Sun, 13 Oct 2019 15:06:08 +0000 (17:06 +0200)]
xlat: provide fallback definitions for ABS_MT_* constants

* xlat/evdev_mtslots.in: Add fallback definitions.  Add #sorted.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agodefs.h: compact struct tcb a bit by moving currpers field
Eugene Syromyatnikov [Sun, 13 Oct 2019 14:35:53 +0000 (16:35 +0200)]
defs.h: compact struct tcb a bit by moving currpers field

As reported by pahole, struct tcb has size of 328 bytes and 8 bytes
of holes on x86_64; by moving currpers after qual_flg, both holes are
leminated and the structure fits into 8 cache lines now.  This should
also benefit other 64-bit architectures.

* defs.h [SUPPORTED_PERSONALITIES > 1] (struct tcb): Move currpers field
after qual_flg field.

4 years agoxlat: use unsgined type for mount_flags fallback values
Eugene Syromyatnikov [Thu, 17 Oct 2019 11:13:45 +0000 (13:13 +0200)]
xlat: use unsgined type for mount_flags fallback values

Reported by cppcheck:

    strace/xlat/mount_flags.h:256: error[shiftTooManyBitsSigned]:
    Shifting signed 32-bit value by 31 bits is undefined behaviour
    #  254|    XLAT(MS_BORN),
    #  255|    XLAT(MS_ACTIVE),
    #  256|->  XLAT(MS_NOUSER),
    #  257|    XLAT_END
    #  258|   };

* xlat/mount_flags.in: Use 1U instead of 1 as a bit shifting operand.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1747524

4 years agortnl_rule: decode fib_rule_uid_range without use of <linux/fib_rules.h>
Eugene Syromyatnikov [Thu, 10 Oct 2019 08:27:40 +0000 (10:27 +0200)]
rtnl_rule: decode fib_rule_uid_range without use of <linux/fib_rules.h>

* rtnl_rule.c (decode_fib_rule_uid_range): Define struct type for
fib_rule_uid_range explicitly.
(decode_fib_rule_uid_range) [!HAVE_STRUCT_FIB_RULE_UID_RANGE]: Remove.
* xlat/fib_rule_flags.in: Add fallback definitions.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agoxlat: update MDB_FLAGS_* constants
Eugene Syromyatnikov [Thu, 10 Oct 2019 09:49:02 +0000 (11:49 +0200)]
xlat: update MDB_FLAGS_* constants

Also, provide fallback definitions for constants.

* xlat/mdb_flags.in (MDB_FLAGS_OFFLOAD): Add fallback definition.
(MDB_FLAGS_FAST_LEAVE): New constant, introduced by Linux commit
v5.4-rc1~131^2~321.

4 years agoxlat: provide fallback definitions for XDP_FLAGS_* constants
Eugene Syromyatnikov [Thu, 10 Oct 2019 09:23:00 +0000 (11:23 +0200)]
xlat: provide fallback definitions for XDP_FLAGS_* constants

* xlat/xdp_flags.in: Add fallback definitions.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agoxlat: provide fallback definitions for netlink_ack_flags constants
Eugene Syromyatnikov [Wed, 9 Oct 2019 18:12:41 +0000 (20:12 +0200)]
xlat: provide fallback definitions for netlink_ack_flags constants

* xlat/netlink_ack_flags.in: Add fallback definitions.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agoxlat: provide fallback definitions for UFFD_FEATURE_* constants
Eugene Syromyatnikov [Wed, 9 Oct 2019 18:06:15 +0000 (20:06 +0200)]
xlat: provide fallback definitions for UFFD_FEATURE_* constants

* xlat/uffd_api_features.in: Add fallback definitions.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

4 years agoriscv64: remove dead code left after riscv64 mpers removal
Eugene Syromyatnikov [Sat, 12 Oct 2019 08:38:29 +0000 (10:38 +0200)]
riscv64: remove dead code left after riscv64 mpers removal

Since there is no compat on RISCV64 so far, its dead remains are only
confusing.

* linux/riscv64/arch_get_personality.c: Remove.
* Makefile.am (EXTRA_DIST): Remove it.

Reported-by: Elvira Khabirova <lineprinter0@gmail.com>
Suggested-by: Dmitry V. Levin <ldv@altlinux.org>
Complements: v5.3~18 "riscv64: remove mpers support"

4 years agotests: try to avoid false positives in times sanity check
Eugene Syromyatnikov [Fri, 11 Oct 2019 11:36:15 +0000 (13:36 +0200)]
tests: try to avoid false positives in times sanity check

Checking clock_gettime(CLOCK_PROCESS_CPUTIME_ID) starting from the
second iteration may produce false positives sometimes, try to spend
more iterations before starting checking it.

* tests/times.c (NUM_USER_ITERS_SQRT): New enum entity.
(NUM_USER_ITERS): Define via NUM_USER_ITERS_SQRT.
(main): Check i against NUM_USER_ITERS_SQRT first before checking
the returned CPU time for sanity.

4 years agofilter_seccomp: fix build on antique systems
Dmitry V. Levin [Wed, 9 Oct 2019 09:24:06 +0000 (09:24 +0000)]
filter_seccomp: fix build on antique systems

Fixed build on systems that do not provide necessary definitions
of AUDIT_ARCH_* constants.

* filter_seccomp.c [PERSONALITY0_AUDIT_ARCH]: Include
"xlat/elf_em.h" and "xlat/audit_arch.h" under XLAT_MACROS_ONLY.
* tests/filter_seccomp-flag.c: Likewise.
* NEWS: Mention this fix.

Fixes: v5.3~7 "Introduce seccomp-assisted syscall filtering"
4 years agotests: check -DD and -DDD options
Dmitry V. Levin [Mon, 7 Oct 2019 11:33:37 +0000 (11:33 +0000)]
tests: check -DD and -DDD options

* tests/strace-D.test: Check -DD and -DDD.
* tests/strace-DD.test: New test.
* tests/strace-DDD.test: Likewise.
* tests/strace-DD.expected: New file.
* tests/strace-DDD.expected: Likewise.
* tests/tracer_ppid_pgid_sid.c: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add tracer_ppid_pgid_sid.
(MISC_TESTS): Add strace-DD.test and strace-DDD.test.
(EXTRA_DIST): Add strace-DD.expected and strace-DDD.expected.

4 years agostrace: expand -D option
Fanda Uchytil [Sat, 5 Oct 2019 22:55:13 +0000 (00:55 +0200)]
strace: expand -D option

As of now, despite of being stated that -D option runs strace as a "detached"
grandchild (and the option name being named after "daemon"), strace
still runs in the same process group and session, thus not being
"detached" in a common sense and being subjected to process group kill
and session termination kill. Quoting[1]:

    I stumble upon unexpected behavior: if strace is used with option '-D'
    (tracer as a detached grandchild) and process (leader) kills whole
    process group, it will kill strace too.

    It can be easily reproduced by `timeout` from "coreutils":

      # timeout -s KILL 2 strace -D -o ./strace-inside.log /bin/sleep 10 &

    Here we can see, that `strace` didn't finished its output (because it
    was killed):

      # tail -n 1 ./strace-inside.log
      nanosleep({tv_sec=10, tv_nsec=0},

    If `timeout` is not run in '--foreground' mode, it changes process group
    and after "timeout" it sends two kills:

      setpgid(0, 0)                           = 0
      kill(37337, SIGKILL)                    = 0
      kill(0, SIGKILL)                        = ?

    The first kill is for the `sleep` and the second one is for the process
    group (which is `strace` part of). PIDs and their relations are:

      timeout  pid=30595   [ppid=476   bash   ]     pgrp=30595
      sleep    pid=37337   [ppid=30595 timeout]     pgrp=30595
      strace   pid=30603   [ppid=1     systemd]     pgrp=30595

    Here is "strace log" of `strace` inside `timeout`:

      strace: Process 30603 attached
      wait4(-1,  <unfinished ...>)            = ?
      +++ killed by SIGKILL +++

    I think that detached `strace` should not be killed like that -- it
    should not be part of former grandparents' "job pipeline".

While this behaviour is not exactly intuitive, it is implemented this
way for quite some time, so it might be relied upon by some of strace
users.  In order to address this issue, two new levels of
"daemonisation" are added, that put strace in a separate process group
and session, respectively.

[1] https://lists.strace.io/pipermail/strace-devel/2019-October/009160.html

* strace.1.in (.SH SYNOPSIS): Update.
(.SS Tracing): Document -DD and -DDD.
* strace.c (DAEMONIZE_NONE, DAEMONIZE_GRANDCHILD, DAEMONIZE_NEW_PGROUP,
* DAEMONIZE_NEW_SESSION, DAEMONIZE_OPTS_GUARD__, MAX_DAEMONIZE_OPTS):
* New enumeration entities.
(daemonized_tracer): Change type to unsigned int.
(usage): Document -DD and -DDD.
(startup_attach) <daemonized_tracer == DAEMONIZE_NEW_PGROUP>: Call
setpgid.
<daemonized_tracer == DAEMONIZE_NEW_SESSION>: Call setsid.
(init) <case 'D'>: Increase daemonized_tracer instead of setting to 1.
(init): Bail out if too many -D's are given.
* NEWS: Mention this improvement.
* tests/options-syntax.test: Add checks for -D option usage.

Co-authored-by: Eugene Syromyatnikov <evgsyr@gmail.com>
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
4 years agoFix -b execve when --seccomp-bpf option is specified
Dmitry V. Levin [Fri, 4 Oct 2019 21:58:20 +0000 (21:58 +0000)]
Fix -b execve when --seccomp-bpf option is specified

As --seccomp-bpf does not support detaching, explicitly turn off
this option when -b execve is specified.

* strace.c (init): Turn off --seccomp-bpf when -b execve is specified.
* NEWS: Mention this fix.
* tests/bexecve.test: Check it.

Fixes: v5.3~7 "Introduce seccomp-assisted syscall filtering"
4 years agofilter_seccomp: fix build for no-MMU targets
Dmitry V. Levin [Fri, 4 Oct 2019 13:16:33 +0000 (13:16 +0000)]
filter_seccomp: fix build for no-MMU targets

Avoid unsupported fork() call on no-MMU Linux systems to fix
the following link error:

ld: strace-filter_seccomp.o: in function `check_seccomp_filter':
filter_seccomp.c:(.text+0x39a): undefined reference to `fork'
collect2: error: ld returned 1 exit status

* filter_seccomp.c (__gcov_flush, check_seccomp_order_do_child,
check_seccomp_order_tracer): Move under HAVE_FORK guard.
(check_seccomp_order): Move fork code under HAVE_FORK guard.
(check_seccomp_filter_properties): Do not check for NOMMU_SYSTEM.
* NEWS: Mention this fix.

Reported-and-tested-by: Baruch Siach <baruch@tkos.co.il>
Fixes: v5.3~7 "Introduce seccomp-assisted syscall filtering"
4 years agotests: check -D option
Dmitry V. Levin [Fri, 4 Oct 2019 21:58:20 +0000 (21:58 +0000)]
tests: check -D option

* tests/strace-D.test: New test.
* tests/strace-D.expected: New file.
* tests/Makefile.am (MISC_TESTS): Add strace-D.test.
(EXTRA_DIST): Add strace-D.expected.

4 years agotests: check -F and -zZ options
Dmitry V. Levin [Fri, 4 Oct 2019 21:58:20 +0000 (21:58 +0000)]
tests: check -F and -zZ options

* tests/options-syntax.test: Check error diagnostics of -F and -zZ
options.

4 years agotests: extend checks of --seccomp-bpf diagnostics
Dmitry V. Levin [Fri, 4 Oct 2019 21:58:20 +0000 (21:58 +0000)]
tests: extend checks of --seccomp-bpf diagnostics

* tests/options-syntax.test: Add --seccomp-bpf checks.

4 years agotests: add support of multi-line diagnostics to check_h
Dmitry V. Levin [Fri, 4 Oct 2019 21:58:20 +0000 (21:58 +0000)]
tests: add support of multi-line diagnostics to check_h

* tests/syntax.sh (check_h): Add support of multi-line diagnostics.

4 years agoMove FLAG_ macro from defs.h to macros.h
Eugene Syromyatnikov [Thu, 22 Aug 2019 14:06:41 +0000 (16:06 +0200)]
Move FLAG_ macro from defs.h to macros.h

Rename it to FLAG and implement via newly added BIT helper macro,
in preparation for general use

* defs.h: Use FLAG instead of FLAG_.
(FLAG_): Move it...
* macros.h (FLAG): Here, implement using BIT macro.
[!BIT] (BIT): New macro.

4 years agoioctl: sort entries in ioctl_decode switch statement
Eugene Syromyatnikov [Tue, 11 Sep 2018 00:01:21 +0000 (02:01 +0200)]
ioctl: sort entries in ioctl_decode switch statement

* ioctl.c (ioctl_decode): Sort case branches in the switch statement.

4 years agoutil: avoid double printing of ellipsis in print_array
Eugene Syromyatnikov [Fri, 4 Oct 2019 13:13:40 +0000 (15:13 +0200)]
util: avoid double printing of ellipsis in print_array

When PAF_ARRAY_TRUNCATED flag is provided to print_array_ex.

* util.c (print_array_ex): Add truncated flag, set it when the output
is truncated, avoid explicit ellipsis printing when it is set.

Fixes: v5.3~14 "Add PAF_ARRAY_TRUNCATED flag for print_array_ex"
4 years agotests: add ioctl_evdev-success* test binaries to .gitignore
Eugene Syromyatnikov [Thu, 3 Oct 2019 00:51:16 +0000 (02:51 +0200)]
tests: add ioctl_evdev-success* test binaries to .gitignore

* tests/.gitignore: Add ioctl_evdev-success-Xabbrev,
ioctl_evdev-success-Xraw, ioctl_evdev-success-Xverbose,
ioctl_evdev-success-v-Xabbrev, ioctl_evdev-success-v-Xraw,
and ioctl_evdev-success-v-Xverbose.

Fixes: v5.3~9 "Handle xlat verbosity in evdev bitset printing"
4 years agotests/sigaction: workaround odd libcs on alpha and mips
Dmitry V. Levin [Wed, 2 Oct 2019 09:32:26 +0000 (09:32 +0000)]
tests/sigaction: workaround odd libcs on alpha and mips

Apparently, some libcs define SA_RESTORER on alpha and mips
despite of the absence of sa_restorer field.  Workaround this
to match the logic implemented in decode_old_sigaction().

* tests/sigaction.c (main) [ALPHA || MIPS]: Do not check decoding
of sa_restorer field.

4 years agoDistribute copyright-year-gen, file-date-gen, and git-version-gen
Dmitry V. Levin [Wed, 2 Oct 2019 09:32:26 +0000 (09:32 +0000)]
Distribute copyright-year-gen, file-date-gen, and git-version-gen

These scripts have to be distributed along with configure.ac since
the latter uses them.

* Makefile.am (EXTRA_DIST): Add copyright-year-gen, file-date-gen,
and git-version-gen.

4 years agotests: fix -a argument in stat and lstat tests
Dmitry V. Levin [Tue, 1 Oct 2019 09:10:46 +0000 (09:10 +0000)]
tests: fix -a argument in stat and lstat tests

* tests/trace_lstat.in (lstat): Change -a argument from 32 to 31.
* tests/trace_stat.in (stat): Change -a argument from 32 to 30.
* tests/gen_tests.in (lstat): Change -a argument from 32 to 31.
(stat): Change -a argument from 32 to 30.

This fixes Debian bug #929715.

4 years agoPrefer https URLs where possible
Dmitry V. Levin [Tue, 1 Oct 2019 09:10:46 +0000 (09:10 +0000)]
Prefer https URLs where possible

* maint/README-release: Use https URL instead of http.
* xlat/elf_em.in: Likewise.

4 years agoUpdate debian/watch
Dmitry V. Levin [Tue, 1 Oct 2019 09:10:46 +0000 (09:10 +0000)]
Update debian/watch

* debian/watch: Sync with Debian strace-4.26-0.2 package.

4 years agoUpdate ax_prog_cc_for_build.m4
Dmitry V. Levin [Tue, 1 Oct 2019 09:10:46 +0000 (09:10 +0000)]
Update ax_prog_cc_for_build.m4

* m4/ax_prog_cc_for_build.m4: Update from autoconf-archive.

4 years agoUpdate auxiliary maintainer mode build tools
Dmitry V. Levin [Tue, 1 Oct 2019 09:10:46 +0000 (09:10 +0000)]
Update auxiliary maintainer mode build tools

* git-set-file-times: Update from rsync.
* git-version-gen: Update from gnulib.
* gitlog-to-changelog: Likewise.

4 years agoRemove traces of riscv64 mpers
Andreas Schwab [Fri, 27 Sep 2019 15:59:02 +0000 (17:59 +0200)]
Remove traces of riscv64 mpers

* tests/options-syntax.test: Remove riscv64.
* tests/qualify_personality.sh: Likewise.
* tests/strace-V.test: Likewise.

Fixes: v5.3~18 "riscv64: remove mpers support"
4 years agostrace.1.in: move --seccomp-bpf description down
Eugene Syromyatnikov [Wed, 25 Sep 2019 18:21:16 +0000 (20:21 +0200)]
strace.1.in: move --seccomp-bpf description down

Option descriptions generally maintain lexicographical order.

* strace.1.in (.SS Miscellaneous): Move --seccomp-bpf option description
down in order to maintain lexicographical option description order.

4 years agostrace.1.in: mention seccomp(2) in --seccomp-bpf option description
Eugene Syromyatnikov [Wed, 25 Sep 2019 18:19:35 +0000 (20:19 +0200)]
strace.1.in: mention seccomp(2) in --seccomp-bpf option description

And format ptrace(2) properly as well.

* strace.1.in (.SS Miscellaneous): Mention seccomp(2), format ptrace(2)
mention.

4 years agostrace.1.in: describe time format specification
Eugene Syromyatnikov [Wed, 25 Sep 2019 18:14:33 +0000 (20:14 +0200)]
strace.1.in: describe time format specification

Commits v5.3~74 and v5.3~73 have introduced an extended syntax
for time interval sizes specification, but the relevant descriotion
was lacking.  Fix it by adding the relevant section to the man page
and reference to it in the descriptions of the respective options.

* strace.1.in (.SH OPTIONS): Rewrite descriptions of -O,
-e inject=delay_enter, and -e inject=delay_exit values, refer to section
"Time specification format description".
(.SS "Time specification format description"): New section.

Complements: v5.3~74 "delay: use parse_ts for parsing delay value"
Complements: v5.3~73 "count: use parse_ts for parsing overhead value"

4 years agostrace.1.in: add a missing comma before "but"
Eugene Syromyatnikov [Wed, 25 Sep 2019 18:13:25 +0000 (20:13 +0200)]
strace.1.in: add a missing comma before "but"

* strace.1.in (.SH DESCRIPTION): Add a missing comma.

4 years agostrace.1.in: eliminate empty lines
Eugene Syromyatnikov [Wed, 25 Sep 2019 18:12:06 +0000 (20:12 +0200)]
strace.1.in: eliminate empty lines

Replace them with .IP or just remove.

4 years agostrace.1.in: properly indent -e inject description
Eugene Syromyatnikov [Wed, 25 Sep 2019 17:53:30 +0000 (19:53 +0200)]
strace.1.in: properly indent -e inject description

As inject option description is moved to a separate section, its
.TP macro now requires an argument.

* strace.1.in (.SS Tampering): Add indent size argument to the first
.TP macro instance.

Fixes: v5.3~99 "strace.1.in: reorder options"
4 years agoPost-release administrivia
Dmitry V. Levin [Wed, 25 Sep 2019 18:24:48 +0000 (18:24 +0000)]
Post-release administrivia

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

4 years agoPrepare for 5.3 release v5.3
Dmitry V. Levin [Wed, 25 Sep 2019 01:02:03 +0000 (01:02 +0000)]
Prepare for 5.3 release

* NEWS: Update for 5.3 release.

4 years agotests: workaround systemd-nspawn habit of disabling unimplemented syscalls
Dmitry V. Levin [Wed, 25 Sep 2019 01:02:03 +0000 (01:02 +0000)]
tests: workaround systemd-nspawn habit of disabling unimplemented syscalls

* tests/clone3.c (do_clone3_): Do not assume that unimplemented
syscalls always fail with ENOSYS.

4 years agoUpdate copyright headers
Dmitry V. Levin [Tue, 24 Sep 2019 21:35:26 +0000 (21:35 +0000)]
Update copyright headers

Headers updated automatically using maint/update_copyright_years.sh
script.

4 years agoFix preprocessor indentation
Dmitry V. Levin [Tue, 24 Sep 2019 21:35:26 +0000 (21:35 +0000)]
Fix preprocessor indentation

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

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

4 years agoUpdate NEWS
Eugene Syromyatnikov [Tue, 24 Sep 2019 08:36:39 +0000 (10:36 +0200)]
Update NEWS

4 years agotests: check seccomp-assisted syscall filtering
Chen Jingpiao [Mon, 6 Aug 2018 13:58:43 +0000 (21:58 +0800)]
tests: check seccomp-assisted syscall filtering

Test filter_seccomp-perf checks whether seccomp-filter is actually
enabled by comparing the number of syscalls performed in a time interval
when seccomp-filter is enabled vs. disabled.  The number of syscalls
should be at least one order of magnitude higher when seccomp-filter
is enabled.

Test filter_seccomp-flag ensures the audit_arch_vec[].flag constants do
not conflict with syscall numbers.  If this test fails, then the number
of syscalls grew high enough that the code for seccomp-filter needs to
be updated.

* tests/init.sh (test_prog_set): New function.
* tests/status-none-f.c: New file.
* tests/filter_seccomp.in: Likewise.
* tests/filter_seccomp.sh: Likewise.
* tests/filter_seccomp-perf.c: Likewise.
* tests/filter_seccomp-flag.c: Likewise.
* tests/filter_seccomp-perf.test: New test.
* tests/Makefile.am (EXTRA_DIST): Add filter_seccomp.in and
filter_seccomp.sh.
(MISC_TESTS): Add filter_seccomp-perf.test.
(check_PROGRAMS): Add filter_seccomp-perf and filter_seccomp-flag.
* tests/pure_executables.list: Add status-none-f.
* tests/.gitignore: Add status-none-f, filter_seccomp-perf, and
filter_seccomp-flag.
* tests/gen_tests.in (filter_seccomp, filter_seccomp-flag): New entries.

Co-authored-by: Paul Chaignon <paul.chaignon@gmail.com>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
4 years agofilter_seccomp: skip seccomp setup when there's nothing to filter
Paul Chaignon [Mon, 1 Jul 2019 19:14:15 +0000 (21:14 +0200)]
filter_seccomp: skip seccomp setup when there's nothing to filter

If the trace_set set is complete (no syscalls are filtered), seccomp
filtering is disabled.  This patch adds a new is_complete_set_array
function to check whether all sets of a set array are complete.

* number_set.c (is_complete_set_array): New function.
* number_set.h (is_complete_set_array): New prototype.
* filter_seccomp.c (check_seccomp_filter): Skip seccomp setup if there is
nothing to filter.

Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
4 years agoIntroduce seccomp-assisted syscall filtering
Chen Jingpiao [Thu, 3 May 2018 13:00:38 +0000 (21:00 +0800)]
Introduce seccomp-assisted syscall filtering

With this patch, strace can rely on seccomp to only be stopped at syscalls
of interest, instead of stopping at all syscalls.  The seccomp filtering
of syscalls is opt-in only; it must be enabled with the --seccomp-bpf
option.  Kernel support is first checked with check_seccomp_filter(),
which also ensures the BPF program derived from the syscalls to filter
is not larger than the kernel's limit.

The --seccomp-bpf option implies -f, but a warning is emitted if -f is not
explicitly specified.  Since a task's children inherit its seccomp
filters, we want to ensure all children are also traced to avoid their
syscalls failing with ENOSYS (cf. SECCOMP_RET_TRACE in seccomp man page).

Fork/vfork/clone children of traced processes are marked as not having a
seccomp filter until we receive a first seccomp-stop.  They are therefore
stopped at every syscall entries and exits until that first seccomp-stop.

The current BPF program implements a simple linear match of the syscall
numbers.  Contiguous sequences of syscall numbers are however matched as
an interval, with two instructions only.  The algorithm can be improved
or replaced in the future without impacting user-observed behavior.

The behavior of SECCOMP_RET_TRACE changed between Linux 4.7 and 4.8
(cf. PTRACE_EVENT_SECCOMP in ptrace man page).  This patch supports both
behaviors by checking the kernel's actual behavior before installing the
seccomp filter.

* filter_seccomp.c: New file.
* filter_seccomp.h: New file.
* Makefile.am (strace_SOURCES): Add filter_seccomp.c and
filter_seccomp.h.
* linux/aarch64/arch_defs_.h (PERSONALITY0_AUDIT_ARCH,
PERSONALITY1_AUDIT_ARCH): Define for aarch64.
* linux/powerpc64/arch_defs_.h (PERSONALITY0_AUDIT_ARCH,
PERSONALITY1_AUDIT_ARCH): Likewise for powerpc64.
* linux/s390x/arch_defs_.h (PERSONALITY0_AUDIT_ARCH,
* linux/sparc64/arch_defs_.h (PERSONALITY0_AUDIT_ARCH,
PERSONALITY1_AUDIT_ARCH): Likewise for sparc64.
PERSONALITY1_AUDIT_ARCH): Likewise for s390x.
* linux/tile/arch_defs_.h (PERSONALITY0_AUDIT_ARCH,
PERSONALITY1_AUDIT_ARCH): Likewise for tile.
* linux/x32/arch_defs_.h (PERSONALITY0_AUDIT_ARCH,
PERSONALITY1_AUDIT_ARCH): Likewise for x32.
* linux/x86_64/arch_defs_.h (PERSONALITY0_AUDIT_ARCH,
PERSONALITY1_AUDIT_ARCH, PERSONALITY2_AUDIT_ARCH): Likewise for x86_64.
* linux/ia64/arch_defs_.h (PERSONALITY0_AUDIT_ARCH): Likewise for IA64.
* strace.c (usage): Document --seccomp-bpf option.
(startup_child): Mark process has having seccomp filter.
(exec_or_die): Initialize seccomp filtering if requested.
(init): Handle --seccomp-bpf option and check that seccomp can be
enabled.
(print_debug_info): Handle PTRACE_EVENT_SECCOMP.
(next_event): Capture PTRACE_EVENT_SECCOMP event.
(dispatch_event): Handle PTRACE_EVENT_SECCOMP event.
* trace_event.h (trace_event): New enumeration entity.
* strace.1.in: Document new --seccomp-bpf option.
* NEWS: Mention this change.

Co-authored-by: Paul Chaignon <paul.chaignon@gmail.com>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
4 years agoAdd support for long options
Dmitry V. Levin [Tue, 24 Sep 2019 21:35:26 +0000 (21:35 +0000)]
Add support for long options

Recognize --help and --version options as aliases to -h and -V options,
respectively.

* strace.c: Include <getopt.h>.
(init): Move short options to optstring, add longopts array, use
getopt_long instead of getopt.
(usage): Document --help and --version options.
* strace.1.in: Likewise.
* tests/strace-V.test: Check that "strace --version" output is the same
as "strace -V" output.

4 years agoHandle xlat verbosity in evdev bitset printing
Eugene Syromyatnikov [Fri, 19 Jul 2019 11:27:29 +0000 (13:27 +0200)]
Handle xlat verbosity in evdev bitset printing

* defs.h (print_xint32_array_member, print_xint64_array_member): New
function declarations.
(print_xlong_array_member): New static inline function.
* util.c (print_xint32_array_member, print_xint64_array_member): New
functions.
* evdev.c (decode_bitset): Handle xlat verbosity option.
* tests/ioctl_evdev-Xabbrev.c: New file.
* tests/ioctl_evdev-Xraw.c: Likewise.
* tests/ioctl_evdev-Xverbose.c: Likewise.
* tests/ioctl_evdev-success-Xabbrev.c: Likewise.
* tests/ioctl_evdev-success-Xraw.c: Likewise.
* tests/ioctl_evdev-success-Xverbose.c: Likewise.
* tests/ioctl_evdev-success-v-Xabbrev.c: Likewise.
* tests/ioctl_evdev-success-v-Xraw.c: Likewise.
* tests/ioctl_evdev-success-v-Xverbose.c: Likewise.
* tests/ioctl_evdev-v-Xabbrev.c: Likewise.
* tests/ioctl_evdev-v-Xraw.c: Likewise.
* tests/ioctl_evdev-v-Xverbose.c: Likewise.
* tests/ioctl_evdev-success.c (test_evdev, print_getbit, main): Update
expected output.
* tests/ioctl_evdev.c (UNK_CMD): New macro.
(print_ffe_common, main): Update expected output.
* tests/Makefile.am (check_PROGRAMS): Add ioctl_evdev-success-Xabbrev,
ioctl_evdev-success-Xraw, ioctl_evdev-success-Xverbose,
ioctl_evdev-success-v-Xabbrev, ioctl_evdev-success-v-Xraw, and
ioctl_evdev-success-v-Xverbose.
* tests/gen_tests.in (ioctl_evdev-Xabbrev, ioctl_evdev-Xraw,
ioctl_evdev-Xverbose, ioctl_evdev-v-Xabbrev, ioctl_evdev-v-Xraw,
ioctl_evdev-v-Xverbose, ioctl_evdev-success-Xabbrev,
ioctl_evdev-success-Xraw, ioctl_evdev-success-Xverbose,
ioctl_evdev-success-v-Xabbrev, ioctl_evdev-success-v-Xraw,
ioctl_evdev-success-v-Xverbose tests): New entries.
(ioctl_evdev, ioctl_evdev-v): Add alignment option.
* tests/pure_executables.list: Add ioctl_evdev-Xabbrev,
ioctl_evdev-Xraw, ioctl_evdev-Xverbose, ioctl_evdev-v-Xabbrev,
ioctl_evdev-v-Xraw, ioctl_evdev-v-Xverbose.
* tests/.gitignore: Likewise.

4 years agoioctl: do not print comments twice in -Xverbose
Eugene Syromyatnikov [Sat, 7 Sep 2019 15:59:31 +0000 (16:59 +0100)]
ioctl: do not print comments twice in -Xverbose

Figure out whether the ioctl code is decoded inside a comment and adjust
printflags/printxval calls accordingly.

* ioctl.c (ioctl_print_code, evdev_decode_number): Add abbrev variable,
set it to true if xlat style is not XLAT_STYLE_VERBOSE, do not provide
dflt and set xlat style to XLAT_STYLE_ABBREV in printflags/printxval
calls (that are now changed to printflags_ex/printxval_ex to accomodate
the change).

4 years agotests/ioctl_evdev-success: rewrite ABS_MT check
Eugene Syromyatnikov [Fri, 19 Jul 2019 16:23:17 +0000 (18:23 +0200)]
tests/ioctl_evdev-success: rewrite ABS_MT check

Use null-terminating array instead of providing array size in the first
element.

* tests/ioctl_evdev-success.c (print_mtslots, main): Update
mtslots_str/invalid_mtslot_str array usage.

4 years agotests: add xlat verbosity support to printxval
Eugene Syromyatnikov [Fri, 19 Jul 2019 16:14:20 +0000 (18:14 +0200)]
tests: add xlat verbosity support to printxval

* tests/Makefile.am (libtests_a_SOURCES): Remove printxval.c, add
printxval-Xabbrev.c, printxval-Xraw.c, and printxval-Xverbose.c.
(EXTRA_DIST): Add printxval.c.
* tests/printxval.c [!XLAT_RAW] (lookup_xlat): New function.
(printxval): Wrap in XLAT_NAME.
(sprintxlat, sprintxval): New functions.
* tests/printxval-Xabbrev.c: New file.
* tests/printxval-Xraw.c: Likewise.
* tests/printxval-Xverbose.c: Likewise.
* tests/tests.h (printxval): Remove declaration.
(printxval_abbrev, printxval_raw, printxval_verbose, sprintxlat_abbrev,
sprintxlat_raw, sprintxlat_verbose, sprintxval_abbrev, sprintxval_raw,
sprintxval_verbose): New declarations.
(printxval, sprintxlat, sprintxval): New macros, defined based on values
of XLAT_RAW amd XLAT_VERBOSE macros.
* tests/ioprio.c: Simplify the printing code since printxval now has
xlat verbosity support.

4 years agotests/tests.h: add XLAT_STR macro
Eugene Syromyatnikov [Fri, 19 Jul 2019 11:08:40 +0000 (13:08 +0200)]
tests/tests.h: add XLAT_STR macro

XLAT_STR allows describing expected output succintly in some simple
cases.

* tests/tests.h (XLAT_STR): New macro.

4 years agoAdd PAF_ARRAY_TRUNCATED flag for print_array_ex
Eugene Syromyatnikov [Tue, 16 Jul 2019 00:08:24 +0000 (02:08 +0200)]
Add PAF_ARRAY_TRUNCATED flag for print_array_ex

PAF_ARRAY_TRUNCATED allows enforcing the fact that an array
is truncated, which is useful for arrays in local memory that are known
as being truncated.

* defs.h (xlat_style_private_flag_bits): Add PAF_ARRAY_TRUNCATED_BIT.
(xlat_style_private_flags): Add PAF_ARRAY_TRUNCATED.
* util.c (print_array_ex): Handle PAF_ARRAY_TRUNCATED in flags.

4 years agoAdd support for printing local arrays to print_array
Eugene Syromyatnikov [Tue, 16 Jul 2019 00:06:02 +0000 (02:06 +0200)]
Add support for printing local arrays to print_array

* defs.h (print_array_ex): Describe parameters.
(print_local_array): A wrapper for printing arrays in local memory
via print_array_ex.
* util.c (print_array_ex): Handle case of NULL tfetch_mem_func by
printing elements of array in local memory pointed by start_addr
parameter.

4 years agotests: move ioctl_evdev-v binary to pure_executables.list
Eugene Syromyatnikov [Fri, 19 Jul 2019 11:26:06 +0000 (13:26 +0200)]
tests: move ioctl_evdev-v binary to pure_executables.list

* tests/Makefile.am (check_PROGRAMS): Move ioctl_evdev-v ...
* tests/pure_executables.list: ... here.

4 years agotests: implement ioctl_evdev-success-v.test via ioctl_evdev-success.test
Eugene Syromyatnikov [Fri, 19 Jul 2019 11:19:06 +0000 (13:19 +0200)]
tests: implement ioctl_evdev-success-v.test via ioctl_evdev-success.test

* tests/ioctl_evdev-success-v.test: Remove.
* tests/Makefile.am (DECODER_TESTS): Remove ioctl_evdev-success-v.test.
* tests/gen_tests.in: Add ioctl_evdev-success-v as a wrapper for
ioctl_evdev-success.test.
* tests/ioctl_evdev-success.test: Save "$args" to $prog, increase -a
parameter value to 26 columns, inject "$@" into run_strace arguments,
call $prog instead of axplicit program name.

4 years agoriscv64: remove mpers support
Eugene Syromyatnikov [Tue, 24 Sep 2019 15:31:28 +0000 (17:31 +0200)]
riscv64: remove mpers support

There is no riscv32 Linux support in Linux mainline,
and no compat support in riscv64 as well.

* linux/riscv64/arch_defs_.h: Remove.
* linux/riscv64/ioctls_arch1.h: Likewise.
* linux/riscv64/ioctls_inc1.h: Likewise.
* linux/riscv64/syscallent1.h: Likewise.
* Makefile.am (EXTRA_DIST): Remove them.
* configure.ac (st_MPERS([m32])): Remove riscv64.
* strace.1.in (.SH "MULTIPLE PERSONALITY SUPPORT"): Remove RISC-V
from the list.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
4 years agoriscv: rename to riscv64
Dmitry V. Levin [Mon, 23 Sep 2019 23:19:45 +0000 (23:19 +0000)]
riscv: rename to riscv64

The only currently supported RISC-V architecture is the 64-bit RISC-V.
As the generic name we use causes confusion [1], rename it to riscv64.

[1] https://lists.strace.io/pipermail/strace-devel/2019-August/009057.html

* Makefile.am (EXTRA_DIST): Rename linux/riscv to linux/riscv64.
* configure.ac: Rename riscv to riscv64, RISCV to RISCV64.
* linux/riscv: Rename to linux/riscv64.
* riscv.c: Rename RISCV to RISCV64.
* tests/options-syntax.test: Rename riscv to riscv64.
* tests/qualify_personality.sh: Likewise.
* tests/strace-V.test: Likewise.

4 years agoclone: implement clone3 syscall decoding
Eugene Syromyatnikov [Wed, 28 Aug 2019 00:35:53 +0000 (02:35 +0200)]
clone: implement clone3 syscall decoding

* configure.ac (AC_CHECK_HEADERS): Check for linux/sched.h presence.
(AC_CHECK_TYPES): Check for struct clone_args in <linux/sched.h>.
* clone.c: Include "print_fields.h".
(struct strace_clone_args): New type.
(print_nonzero_bytes): New function.
(SYS_FUNC(clone3)): New decoder.
* linux/syscallent-common.h ([BASE_NR + 435]): Wire up clone3.
* NEWS: Mention this change.
* tests/clone3.c: New file.
* tests/clone3-Xabbrev.c: Likewise.
* tests/clone3-Xraw.c: Likewise.
* tests/clone3-Xverbose.c: Likewise.
* tests/clone3-success.c: Likewise.
* tests/clone3-success-Xabbrev.c: Likewise.
* tests/clone3-success-Xraw.c: Likewise.
* tests/clone3-success-Xverbose.c: Likewise.
* tests/clone3-success.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add clone3-success,
clone3-success-Xabbrev, clone3-success-Xraw, and
clone3-success-Xverbose.
(DECODER_TESTS): Add clone3-success.test.
* tests/gen_tests.in (clone3, clone3-Xabbrev, clone3-Xraw,
clone3-Xverbose, clone3-success-Xabbrev, clone3-success-Xraw,
clone3-success-Xverbose): New entries.
* tests/pure_executables.list: Add clone3, clone3-Xabbrev, clone3-Xraw,
and clone3-Xverbose.
* tests/.gitignore: Add clone3, clone3-Xabbrev, clone3-Xraw,
clone3-Xverbose, clone3-success, clone3-success-Xabbrev,
clone3-success-Xraw, and clone3-success-Xverbose.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
4 years agotests/tests.h: add XLAT_KNOWN and XLAT_UNKNOWN macros
Eugene Syromyatnikov [Fri, 19 Jul 2019 11:08:40 +0000 (13:08 +0200)]
tests/tests.h: add XLAT_KNOWN and XLAT_UNKNOWN macros

XLAT_KNOWN allows describing expected output succintly in some simple
cases.

* tests/tests.h (XLAT_KNOWN, XLAT_UNKNOWN): New macros, define based
on values of XLAT_RAW and XLAT_VERBOSE macros.

4 years agotests: fix umovestr_cached.test when process_vm_readv is not implemented
Dmitry V. Levin [Mon, 23 Sep 2019 10:19:22 +0000 (10:19 +0000)]
tests: fix umovestr_cached.test when process_vm_readv is not implemented

* tests/umovestr_cached.test: Run strace with -z option to filter out
failing process_vm_readv invocations.

4 years agotests: disable umovestr_cached.test on ia64
Dmitry V. Levin [Mon, 23 Sep 2019 10:19:22 +0000 (10:19 +0000)]
tests: disable umovestr_cached.test on ia64

ia64 invokes extra process_vm_readv syscalls to obtain syscall
arguments, see linux/ia64/get_syscall_args.c for details.

* tests/umovestr_cached.test [ $STRACE_ARCH == ia64 ]: Skip.

4 years agotests: fix format warnings on x32
Paul Chaignon [Sat, 21 Sep 2019 13:00:51 +0000 (15:00 +0200)]
tests: fix format warnings on x32

The type of __X32_SYSCALL_BIT changed from int to unsigned long by Linux
kernel commit v5.3-rc1-1-g45e29d119e9923ff14dfb840e3482bef1667bbfb.
Consequently, __NR_* macros are now defined to values of an unsigned long
integer type on x32.

tests/prctl-seccomp-filter-v.c (PRINT_ALLOW_SYSCALL, PRINT_DENY_SYSCALL):
Fix format warning.
tests/seccomp-filter-v.c (PRINT_ALLOW_SYSCALL, PRINT_DENY_SYSCALL):
Likewise.

Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
4 years agoImplement memory caching for umove* functions
Dmitry V. Levin [Sun, 15 Sep 2019 15:47:01 +0000 (15:47 +0000)]
Implement memory caching for umove* functions

When the data to be fetched by vm_read_mem resides in a single memory
page, fetch the whole page and cache it.  This implementation caches
up to two memory pages.

* defs.h (invalidate_umove_cache): New prototype.
* strace.c (next_event): Call invalidate_umove_cache.
* ucopy.c (cached_idx, cached_raddr): New static variables.
(process_read_mem): New function.
(vm_read_mem): Use them.  Implement fetched page caching.
* tests/umovestr_cached.test: New test.
* tests/Makefile.am (MISC_TESTS): Add umovestr_cached.test.
* tests/umovestr_cached.c: New file.
* tests/pure_executables.list: Add umovestr_cached.
* tests/.gitignore: Likewise.

4 years agoUpdate ioctl entries from linux v5.3
Gleb Fotengauer-Malinovskiy [Tue, 10 Sep 2019 10:11:41 +0000 (13:11 +0300)]
Update ioctl entries from linux v5.3

* linux/32/ioctls_inc_align16.h: Update from linux v5.3-rc8
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/s390/ioctls_arch0.h: Likewise.
* linux/s390x/ioctls_arch0.h: Likewise.
* linux/x86_64/ioctls_arch0.h: Likewise.
* NEWS: Mention this.

4 years agomaint: update for linux v5.3-rc8
Gleb Fotengauer-Malinovskiy [Tue, 10 Sep 2019 10:10:59 +0000 (13:10 +0300)]
maint: update for linux v5.3-rc8

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

4 years agoRewrite printnum_{slong,ulong,ptr,kptr} using dispatch_{word,klong}size
Eugene Syromyatnikov [Tue, 16 Jul 2019 00:00:59 +0000 (02:00 +0200)]
Rewrite printnum_{slong,ulong,ptr,kptr} using dispatch_{word,klong}size

* defs.h (printnum_long_int, printnum_addr_long_int, printnum_addr_klong_int):
Remove declaration.
(printnum_slong, printnum_ulong): Implement unconditionally using
dispatch_wordsize and opt_wordsize for the last argument.
(printnum_ptr): Implement unconditionally using dispatch_wordsize.
(printnum_kptr): Implement unconditionally using dispatch_klongsize.
* util.c (printnum_long_int, printnum_addr_long_int, printnum_addr_klong_int):
Remove.

4 years agodefs.h: introduce {opt,dispatch}_{word,klong}size
Eugene Syromyatnikov [Mon, 15 Jul 2019 23:56:46 +0000 (01:56 +0200)]
defs.h: introduce {opt,dispatch}_{word,klong}size

* defs.h (set_personality, current_personality, current_wordsize,
current_klongsize, max_addr, max_kaddr): Move upwards.
(opt_wordsize): New macro, calls the first or the second argument
depending on the word size.
(dispatch_wordsize): New macro, calls the first or the second function
with the rest of macro parameters as arguments depending on the word
size.
(opt_klongsize): New macro, calls the first or the second argument
depending on the kernel long size.
(dispatch_klongsize): New macro, calls the first or the second function
with the rest of macro parameters as arguments depending on the kernel
long size.

4 years agos390: fix PRINT_UNKNOWN_TAIL_EX
Eugene Syromyatnikov [Wed, 4 Sep 2019 08:50:59 +0000 (10:50 +0200)]
s390: fix PRINT_UNKNOWN_TAIL_EX

In the conversion of PRINT_UNKNOWN_TAIL into PRINT_UNKNOWN_TAIL_EX
the usage of sizeof(*(hdr_)) hasn't been replaced to (hdr_size_)
in all places.  Offset calculation also had to be changed.

* s390.c (PRINT_UNKNOWN_TAIL_EX): Fix addr and len arguments
in is_filled and print_quoted_string calls.

Fixes: v5.2-97-g210593c "s390: update sthyi decoder"
Reported-by: Dan HorĂ¡k <dan@danny.cz>
Resolves: https://github.com/strace/strace/issues/108

4 years agoxlat: add comment about CLONE_DETACHED to clone_flags.in
Eugene Syromyatnikov [Mon, 2 Sep 2019 12:48:40 +0000 (14:48 +0200)]
xlat: add comment about CLONE_DETACHED to clone_flags.in

It's ignored by kernel, but present in the UAPI header.

* xlat/clone_flags.in: Add a comment about CLONE_DETACHED.

4 years agoclone: fix print_tls_arg on x86
Eugene Syromyatnikov [Tue, 3 Sep 2019 11:55:53 +0000 (13:55 +0200)]
clone: fix print_tls_arg on x86

When strace is built for (32-bit) x86, it has HAVE_STRUCT_USER_DESC
and SUPPORTED_PERSONALITIES == 1, which led to execution of the both
branches.  Simplify the logic by including the SUPPORTED_PERSONALITIES
into the condition.

* clone.c (print_tls_arg): Include SUPPORTED_PERSONALITIES into the "if"
condition.

4 years agos390: update sthyi decoder
Eugene Syromyatnikov [Sun, 1 Sep 2019 15:54:21 +0000 (17:54 +0200)]
s390: update sthyi decoder

Sync up with the description[1].

[1] https://www.ibm.com/support/knowledgecenter/SSB27U_6.4.0/com.ibm.zvm.v640.hcpb4/hcpb4sth.htm

* s390.c (struct sthyi_machine): Add fields reserved_1__, infmplnm;
update comment for the infmval1 field; update the related static_assert.
(struct sthyi_partition): Update infpflg1 comment; update infpval1
comment; add infpplnm field; update the related static_assert.
(struct sthyi_hypervisor): Update infyflg1 field comment; add
infyinsf and infyautf fields; update the related static_assert.
(CHECK_SIZE_EX): Rename from CHECK_SIZE; add min_size_ argument, check size_
against it.
(CHECK_SIZE): New macro, a wrapper for CHECK_SIZE_EX.
(PRINT_UNKNOWN_TAIL_EX): Rename from PRINT_UNKNOWN_TAIL, add hdr_size_
argument.
(PRINT_UNKNOWN_TAIL): New macro, a wrapper for PRINT_UNKNOWN_TAIL_EX.
(print_sthyi_machine): New local variable last_decoded; use
CHECK_SIZE_EX instead of CHECK_SIZE to check against the initial value
of last_decoded; decode reserved_1__ and infmplnm fields if the returned
size indicates that they are present; use PRINT_UNKNOWN_TAIL_EX for
printing structure's tail.
(print_sthyi_partition): New local variable last_decoded; use
CHECK_SIZE_EX instead of CHECK_SIZE to check against the initial value
of last_decoded; decode infpplnm field if the returned size indicates
that it is present; use PRINT_UNKNOWN_TAIL_EX for printing structure's
tail.
(print_funcs): New function.
(print_sthyi_hypervisor): New local variable last_decoded; use
CHECK_SIZE_EX instead of CHECK_SIZE to check against the initial value
of last_decoded; update infyflg1 field decoding; decode infyinsf
and infyautf fields if the returned size indicates that they
are present; use PRINT_UNKNOWN_TAIL_EX for printing structure's tail.
(s390_sthyi): Update specification URL.
* tests/s390_sthyi.c: Update expected output.