build: try to use _Static_assert if static_assert is not available
* configure.ac: Check for _Static_assert if static_assert
is not available.
* static_assert.h [!HAVE_STATIC_ASSERT && HAVE__STATIC_ASSERT]
(static_assert): Define to _Static_assert.
evdev: support various types of xlats in decode_bitset
* evdev.c (enum xlat_type): New enumeration.
(printxval_dispatch): New function.
(decode_bitset_): Rename from decode_bitset, add decode_nr_size
and xt arguments, call printxval_dispatch instead of printxval.
(decode_bitset): Add a decode_bitset_ wrapper that derives
decode_nr_size from the ARRAY_SIZE of decode_nr.
(bit_ioctl, evdev_read_ioctl): Update decode_bitset calls.
There are quite a few xlats that start from 0 and not too sparse,
we can push the search time for them down to O(1).
* defs.h (printxval_indexn_ex): New declaration.
(printxval_indexn, printxval_index, printxval_index_ex): New macros.
* xlat.c (printxval_sized): Rename from printxval_searchn_ex,
add fn argument, call it instead of xlat_search.
(printxval_searchn_ex): Implement as a thin wrapper around
printxval_sized using xlat_search as a search function.
(xlat_idx): New function.
(printxval_indexn_ex): New function, a thin wrapper around
printxval_sized using xlat_idx as a search function.
* xlat/gen.sh: Add support for "#value_indexed" directive.
keyctl: use printxval_d for printing keyring serial number
* keyctl.c (print_keyring_serial_number): Use printxval_d instead of
looking up and printing xlat value manually.
* xlat/key_spec.in: Add "#val_type int" so the xlat values have sign
bit propagated.
ioprio: use sprintxval instead of xlookup and string/value printing
In order to respect current xlat style.
* ioprio.c (sprint_ioprio): Use sprintxval for producing string
representation of ioprio class, use the produced string representation
in resulting xsprintf.
tests/ioctl_evdev.c (TEST_NULL_ARG_EX): Rename from TEST_NULL_ARG, add
str argument, print it instead of #cmd.
(TEST_NULL_ARG): Implement as a TEST_NULL_ARG_EX wrapper.
(main): Add checks for EVIOCSABS and EVIOCGBIT ioctls.
* xlat/evdev_switch.in (SW_RADIO): Remove, as it was renamed to
SW_RFKILL_ALL and marked as deprecated by Linux commit v2.6.26-rc5~32^2.
(SW_PEN_INSERTED): New constant, was added by Linux commit v4.7~11^2~7.
* btrfs.c (btrfs_print_balance_args): Print devid field using
PRINT_FIELD_DEV.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_DEV_INFO,
case BTRFS_IOC_GET_DEV_STATS, case BTRFS_IOC_SCRUB,
case BTRFS_IOC_SCRUB_PROGRESS>: Likewise.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_DEV_REPLACE>: Print
start.srcdevid field using PRINT_FIELD_DEV.
* tests/btrfs.c: Update expected output.
btrfs: print cont_reading_from_srcdev_mode as xlat
* xlat/btrfs_cont_reading_from_srcdev_mode.in: New file.
* btrfs.c: Include "xlat/btrfs_cont_reading_from_srcdev_mode.h".
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_DEV_REPLACE>: Print
named values for the
struct btrfs_ioctl_dev_replace_args.start.cont_reading_from_srcdev_mode
field.
* tests/btrfs.c: Include "xlat/btrfs_cont_reading_from_srcdev_mode.h".
(btrfs_test_dev_replace_ioctl): Update expected output.
btrfs: make BTRFS_IOC_GET_DEV_STATS error statistics output more structured
* btrfs.c (MPERS_PRINTER_DECL(btrfs_ioctl)) <case
BTRFS_IOC_GET_DEV_STATS>: Print array index in square brackets before
the value in order to avoid confusion.
* tests/btrfs.c (btrfs_test_get_dev_stats_ioctl): Update expected output.
ioctl: print ioctl number in accordance with xlat verbosity setting
* ioctl.c (SYS_FUNC(ioctl)): Print ioctl command name in accordance
with the current xlat_verbosity setting.
* tests/btrfs.c (sprint_xlat_): New function.
(ioc): New macro, a wrapper for sprint_xlat_.
Update expected output.
file_ioctl: make abbreviated output more structured
* file_ioctl.c (file_ioctl): Print fm_extents field name only in case
of non-abbreviated output.
* tests/btrfs.c (btrfs_test_ino_path_ioctls): Update expected output.
* btrfs.c (print_u64, print_member_u64, print_key_value_internal,
print_key_value): Remove.
(btrfs_print_balance_args): Use PRINT_FIELD_U64 instead of
print_member_u64.
(btrfs_print_tree_search): Use PRINT_FIELD_U64 instead of
print_key_value.
(MPERS_PRINTER_DECL(btrfs_ioctl)): Use PRINT_FIELD_U64 instead of manual
UINT64_MAX printing.
* tests/btrfs.c: Update expected output in order to account fields that
are now affected by xlat_verbosity setting.
As it looks like there's no reason to skip their printing.
* btrfs.c (print_key_value_internal): Do not check value argument
for holding non-zero value.
* tests/btrfs.c (btrfs_print_search_key): Update expected output.
tests/btrfs.c: support volumes with mixed data/metadata in BTRFS_IOC_BALANCE_V2
For these volumes, pend/vend should be the same for data and meta.
* tests/btrfs.c (btrfs_test_balance_ioctls): Set args.meta.pend and
args.meta.vend to the same values as args.data.pend and args.data.vend,
respectively.
tests/btrfs.c: add pid suffix to the created directory, remove it on exit
If multiple tests are running simultaneously in the same directory,
conflicts (and test failures) may happen.
* tests/btrfs.c (path, dir_name_fmt, dir_name): New variables.
(btrfs_test_ino_path_ioctls): Use dir_name for printing directory name.
(rm_test_dir): New function.
(main): Generate dir_name, use it instead of fixed name, add rm_test_dir
as an atexit handler.
btrfs: print abbreviations and field names more consistently
* btrfs.c (btrfs_print_data_container_header): Do not print ", val=".
(btrfs_print_ino_path_container): Print val field name only in case
of non-abbreviated output.
(btrfs_print_qgroup_inherit): Print qgroups field name only in case
of non-abbreviated output.
(btrfs_print_tree_search): Print buf field name only in case
of non-abbreviated output.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_SEND>: Print
clone_sources field name only in case of non-abbreviated output.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_SPACE_INFO>: Print
spaces field name only in case of non-abbreviated output.
* tests/btrfs.c: Update expected output.
btrfs: convert btrfs_print_{objectid,key_type} to PRINT_FIELD_XVAL_U
* btrfs.c (btrfs_print_key_type, btrfs_print_objectid): Convert into
thin wrappers around PRINT_FIELD_XVAL_U.
(btrfs_print_data_container_header, btrfs_print_tree_search,
MPERS_PRINTER_DECL(btrfs_ioctl)): Update calls to btrfs_print_key_type
and btrfs_print_objectid in accordance with the new calling convention.
(print_objectid_callback): Use printxvals_ex directly instead of
btrfs_print_objectid call.
* tests/btrfs.c (btrfs_print_objectid, btrfs_print_key_type): Update
expected output.
bpf: print fields that interpreted as pointers using printaddr64
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_LOOKUP_ELEM),
BEGIN_BPF_CMD_DECODER(BPF_MAP_UPDATE_ELEM)): Print key and value
fields using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_MAP_DELETE_ELEM)): Print key field using
PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_MAP_GET_NEXT_KEY)): Print key and next_key
field using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)): Print insns and log_buf fields
using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_TEST_RUN)): Print data_in and data_out
fields using PRINT_FIELD_ADDR64.
* tests/bpf.c: Update expected output.
* Makefile.am (today): Consistently print the UTC date in C locale.
* configure.ac (RPM_CHANGELOGTIME, DEB_CHANGELOGTIME): Likewise.
* maint/update_copyright_years.sh: Likewise.
* copyright-year-gen: Likewise. When $SOURCE_DATE_EPOCH is non-empty,
use it as fallback date before the current system date.
* file-date-gen: Consistently print the UTC date in C locale.
When $SOURCE_DATE_EPOCH is non-empty, use it as fallback date
before the current system date.
Reported-by: Chris Lamb <lamby@debian.org> Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=896016 Closes: https://github.com/strace/strace/pull/68
bpf: add support for map_name and map_ifindex fields in BPF_MAP_CREATE
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_CREATE)): Decode map_name
and map_ifindex fields that were added in Linux commits
v4.15-rc1~84^2~605^2~3 and v4.16-rc1~123^2~145^2~5^2~8, respectively.
* bpf_attr.h (struct BPF_MAP_CREATE_struct): Add map_name
and map_ifindex fields.
* tests/bpf.c (init_BPF_MAP_CREATE_attr7): New function.
(BPF_MAP_CREATE_checks): Remove const qualifier, add two more checks.
bpf: improve handling of various sizes of BPF_MAP_CREATE attributes
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_CREATE)): Skip printing
the rest of the structure if len is less than the offset of the end
of max_entries, map_flags, or inner_map_fd field.
* tests/bpf.c (BPF_MAP_CREATE_checks): Add two more checks.
btrfs: use umove_or_printaddr_ignore_syserror instead of u_error mangling
* btrfs.c (MPERS_PRINTER_DECL(btrfs_ioctl)) <case
BTRFS_IOC_TREE_SEARCH_V2>: Use umove_or_printaddr_ignore_syserror
instead of tcp->u_error mangling around umove_or_printaddr call.
* defs.h (umove_or_printaddr64_ignore_syserror): New macro, a thin
wrapper around umoven_or_printaddr64_ignore_syserror.
(umove_or_printaddr_ignore_syserror): New macro, a thin wrapper around
umoven_or_printaddr_ignore_syserror.
As there are some possible users for it, apparently.
* defs.h (XLAT_STYLE_FORMAT_MASK): Update the value in order to
accommodate XLAT_STYLE_FMT_D.
(enum xlat_style) <XLAT_STYLE_FMT_D>: New enumeration entity.
(printxval64_d, printxval_d): New function, a shorthand for
printxvals_ex with a single xlat and XLAT_STYLE_FMT_D xlat style.
* xlat.c (sprint_xlat_val): Handle XLAT_STYLE_FMT_D.
Since xlat printing routines now have a notion of "style" that should be
used for printing xlat values, we can also employ this argument for
passing information about number printing format (unsigned decimal
or hexadecimal, so far).
* defs.h (XLAT_STYLE_FORMAT_SHIFT, XLAT_STYLE_FORMAT_MASK): New macro
constant.
(enum xlat_style) <XLAT_STYLE_FMT_X, XLAT_STYLE_FMT_U>: New enumeration
entities.
* xlat.c (xlat_verbose, xlat_format): New macro for checking specific
aspect of style argument.
(get_xlat_style): Use xlat_verbose for checking xlat verbosity style.
(sprint_xlat_val, print_xlat_val): New function, for easing printing
raw constant number with respect to printing format style.
(printxvals_ex, sprintxval_ex, printxval_searchn_ex,
printxval_searchn_ex, sprintflags_ex, printflags_ex, print_xlat_ex):
Use xlat_verbose macro for xlat verbosity style checks. Use
print_xlat_val instead of direct raw xlat value printing.
* futex.c [!FUTEX_OP_OPARG_SHIFT] (FUTEX_OP_OPARG_SHIFT): New macro
constant.
(SYS_FUNC(futex)): Use print_xlat for printing FUTEX_OP_OPARG_SHIFT
named constant.
print_xlat_ex prints a named constant in accordance with xlat style
provided, print_xlat is a thin wrapper around print_xlat_ex that passes
stringified constant name as a string and XLAT_STYLE_DEFAULT as a style.
* defs.h (print_xlat_ex): New function prototype.
(print_xlat): New macro, a thin wrapper around print_xlat_ex.
* xlat.c (print_xlat_ex): New function.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
This will be needed later, with the introduction of user-configurable
xlat style setting (stored in xlat_verbosity variable).
* defs.h (XLAT_STYLE_VERBOSITY_MASK): New macro constant.
(enum xlat_style) <XLAT_STYLE_DEFAULT>: New enumeration entity.
(xlat_verbosity): New external declaration.
(printxvals, printxval_searchn, printxval_search_ex, sprintxval,
sprintflags, printflags64): Use XLAT_STYLE_DEFAULT instead of
XLAT_STYLE_ABBREV.
* strace.c (xlat_verbosity): New variable.
* xlat.c (get_xlat_style): New function.
(printxvals_ex, sprintxval_ex, printxval_searchn_ex, sprintflags_ex,
printflags_ex): Use it.
* defs.h (printxvals_ex): Rename from printxvals, add style argument.
(enum xlat_style): New enumeration.
(printxvals): New macro, a wrapper for printxvals_ex.
(printxval_searchn_ex): Rename from printxval_searchn, add style
argument.
(printxval_searchn): New macro, a wrapper for printxval_searchn_ex.
(printxval_search_ex): New macro, a wrapper for printxval_searchn_ex.
(sprintxval_ex): Rename from sprintxval, add style argument.
(sprintxval): New macro, a wrapper for sprintxval_ex.
(printflags_ex): Add style argument.
(sprintflags_ex): Rename from sprintflags, add style argument.
(sprintflags): New macro, a wrapper for sprintflags_ex.
(printflags64): Pass XLAT_STYLE_ABBREV as a style in printflags_ex call.
* netlink.c (decode_nlmsg_flags): Pass XLAT_STYLE_ABBREV as a style in
printflags_ex call.
* xlat.c (printxvals_ex): Rename from printxvals, add style argument,
handle it.
(sprintxval_ex): Rename from sprintxval, add style argument, handle it.
(printxval_searchn_ex): Rename from printxval_searchn, add style
argument, handle it.
(sprintflags_ex): Rename from sprintflags, add style argument,
handle it.
(printflags_ex): Add style argument, handle it.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
References: https://github.com/strace/strace/issues/27
tests: robustify signal delivery test against kernel bugs
Recent kernel siginfo changes, namely, v4.14-rc1~60^2^2~1,
v4.16-rc1~159^2~37, and v4.16-rc1~159^2~39, introduced ABI regressions
that render the whole siginfo interface unreliable.
Looks like the kernel side is not eager to fix the breakage,
so here is a workaround.
* tests/signal_receive.c (s_sig, s_code, s_pid, s_uid): New volatile
variables.
(handler): Add siginfo_t parameter, save siginfo_t fields.
(sig_print): Remove.
(main): Rewrite. Use variables saved by handler to print expected
siginfo output. Print diagnostics in case of siginfo mismatch.
* strace.spec.in (%check): Extract the diagnostics.
* tests/strace-k.test: When actual strace -k output doesn't match the
expected output because of limited architecture support, skip the test
on architectures that are not currently supported by libdw.
tests: check corner cases of udev_monitor_netlink_header decoding
* tests/netlink_kobject_uevent.c (test_nlmsg_type_kernel): Create
a tail-allocated udev_monitor_netlink_header object and pass it
to sys_send.
(test_nlmsg_type_udev): Likewise. Check decoding of
udev_monitor_netlink_header object that ends in unmapped memory region.
tests: check decoding of udev_monitor_netlink_header
* tests/netlink_kobject_uevent.c: Include <string.h>, <arpa/inet.h>,
and "netlink_kobject_uevent.h".
(test_nlmsg_type_udev, test_nlmsg_type_kernel): New functions.
(main): Use them.
BPF_PROG_QUERY was introduced in Linux commit v4.15-rc1~84^2~558^2~6.
* xlat/bpf_commands.in (BPF_PROG_QUERY): New constant.
* xlat/bpf_query_flags.in: New file.
* bpf.c: Include it.
(DECL_BPF_CMD_DECODER): Add priv argument for passing tcb private data.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_QUERY)): New function.
(SYS_FUNC(bpf)) <bpf_cmd_decoders>: Add BPF_PROG_QUERY entry.
(SYS_FUNC(bpf)): Fetch buf on entering and exiting, pass buf on exiting,
retrieve private data on exiting, pass it to decoder as well, explicitly
rework rc handling logic for size argument printing.
* bpf_attr.h (struct BPF_PROG_QUERY_struct): New structure declaration.
(BPF_PROG_QUERY_struct_size, expected_BPF_PROG_QUERY_struct_size): New
macro.
* tests/bpf.c: Add checks for BPF_PROG_QUERY command.