]> granicus.if.org Git - strace/log
strace
6 years agonlattr: add UID/GID netlink attribute decoders
Eugene Syromyatnikov [Fri, 18 May 2018 16:06:38 +0000 (18:06 +0200)]
nlattr: add UID/GID netlink attribute decoders

* nlattr.h (DECL_NLA(uid), DECL_NLA(gid)): New declarations.
* nlattr.c (decode_nla_uid, decode_nla_gid): New functions.

6 years agonlattr: add unsigned int decoders that print in hex form
Eugene Syromyatnikov [Fri, 18 May 2018 15:38:43 +0000 (17:38 +0200)]
nlattr: add unsigned int decoders that print in hex form

* nlattr.h (DECL_NLA(x8), DECL_NLA(x16), DECL_NLA(x32), DECL_NLA(x64)):
New declarations.
* nlattr.c (DECODE_NLA_INTEGER(x8, uint8_t, "%#" PRIx8),
DECODE_NLA_INTEGER(x16, uint16_t, "%#" PRIx16),
DECODE_NLA_INTEGER(x32, uint32_t, "%#" PRIx32),
DECODE_NLA_INTEGER(x64, uint64_t, "%#" PRIx64)): New decoders.

6 years agonlattr: add ethernet protocol decoder
Eugene Syromyatnikov [Fri, 18 May 2018 15:37:51 +0000 (17:37 +0200)]
nlattr: add ethernet protocol decoder

* nlattr.h (DECL_NLA(ether_proto)): New declaration.
* nlattr.c (process_host_order, decode_nla_ether_proto): New functions.

6 years agonlattr: add value processing support for xlat/flags nlattr decoders
Eugene Syromyatnikov [Fri, 18 May 2018 15:36:00 +0000 (17:36 +0200)]
nlattr: add value processing support for xlat/flags nlattr decoders

Needed for upcoming decoder of ethernet proto which is stored in the
host order and has to be converted to the network order before printing
as an xval constant.  This change also adds ability to provide
prefix/suffix in order to enclose the printed value in something that
describes the performed conversion.

* nlattr.h (struct decode_nla_xlat_opts): Add prefix, suffix, and
process_fn fields.
* nlattr.c (decode_nla_xval, decode_nla_flags): Handle process_fn,
prefix, snd uffix parameters.

6 years agonlattr: introduce decode_nla_flags
Eugene Syromyatnikov [Mon, 7 May 2018 06:40:02 +0000 (08:40 +0200)]
nlattr: introduce decode_nla_flags

Similar to decode_nla_xval.

* nlattr.c (decode_nla_flags): New function.
* nlattr.h: (DECL_NLA(flags)): New declaration.

6 years agonlattr: add ability to pass nla_type to decoder in decode_nlattr
Eugene Syromyatnikov [Mon, 7 May 2018 06:28:38 +0000 (08:28 +0200)]
nlattr: add ability to pass nla_type to decoder in decode_nlattr

As of now, it's impossible to introduce a dispatching nlattr decoder
that performs actions based on the type of the message, so let's use
a combination of zero decoder list size and non-zero decoder pointer
for this.

This is going to be used later in IFLA_AF_SPEC decoding.

* nlattr.c (decode_nlattr_with_data): Handle zero size and non-NULL
decoders in a special way.
(decode_nlattr): Add an error message about ignoring of opaque_data
argument when zero size and non-NULL decoders are provided.
* nlattr.h (decode_nlattr): Add a comment about the new special case.

6 years agotests: use STRINGIFY instead of _STR
Dmitry V. Levin [Wed, 6 Jun 2018 10:10:43 +0000 (10:10 +0000)]
tests: use STRINGIFY instead of _STR

Remove _STR which is essentially the same as STRINGIFY but from
the namespace where we should not introduce new identifiers.

* tests/tests.h (_STR): Remove.
* tests/add_key.c (main): Replace _STR with STRINGIFY.
* tests/keyctl.c (XARG_STR): Likewise.
* tests/request_key.c (main): Likewise.

6 years agotests: check decoding of IFLA_EVENT netlink attribute
Eugene Syromyatnikov [Fri, 25 May 2018 12:36:35 +0000 (14:36 +0200)]
tests: check decoding of IFLA_EVENT netlink attribute

* tests/nlattr_ifinfomsg.c (main): Add a check for IFLA_EVENT attribute
decoding.

6 years agoxlat: handle xlat constants that are not identifiers
Dmitry V. Levin [Tue, 5 Jun 2018 11:04:09 +0000 (11:04 +0000)]
xlat: handle xlat constants that are not identifiers

Extend xlat generator to support such input lines as
IPV4_DEVCONF_FORWARDING-1 0

This is going to be used later in IFLA_AF_SPEC decoding.

* xlat/gen.sh (cond_def): If the xlat value is not an identifier name,
extract an identifier name from the beginning of xlat value.

6 years agoxlat.c: handle NULL xlat in lookup routines as incremental search
Eugene Syromyatnikov [Mon, 7 May 2018 05:57:27 +0000 (07:57 +0200)]
xlat.c: handle NULL xlat in lookup routines as incremental search

This is going to be used later in IFLA_AF_SPEC decoding.

* xlat.c (xlookup): Add static variable pos, store xlat there when it is
non-NULL, use pos for lookup.
(xlat_search, xlat_idx): Add static variables pos and memb_left, store
xlat and nmemb there when xlat is non-NULL, use them for lookup.
(printxvals_ex): Store the last non-NULL xlat in static variable "last".
If the first xlat argument is NULL, use "last" instead.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoxlat.c: cleanup printxvals_ex a bit
Eugene Syromyatnikov [Mon, 7 May 2018 06:51:06 +0000 (08:51 +0200)]
xlat.c: cleanup printxvals_ex a bit

* xlat.c (printxvals_ex): Change "str" variable visibility to the whole
function, jump to va_end instead of duplicating call and return, return
!!str.

6 years agoLeverage the fact that inet_protocols xlat is sorted
Eugene Syromyatnikov [Wed, 23 May 2018 16:48:26 +0000 (18:48 +0200)]
Leverage the fact that inet_protocols xlat is sorted

* defs.h (inet_protocols): Move up, add description.
(inet_protocols_size): New declaration.
* net.c (inet_protocols_size): New constant variable.
* nlattr.c (decode_nla_ip_proto): Specify xlat_size, set xt to XT_SORTED.

6 years agoPrint arp_hardware_types as a sorted xlat
Eugene Syromyatnikov [Wed, 30 May 2018 13:26:09 +0000 (15:26 +0200)]
Print arp_hardware_types as a sorted xlat

* rtnl_link.c (DECL_NETLINK_ROUTE_DECODER(decode_ifinfomsg)): Use
PRINT_FIELD_XVAL_SORTED_SIZED instead of PRINT_FIELD_XVAL for
arp_hardware_types.
* sock.c (print_ifreq): Likewise.

6 years agoProvide a value for arp_hardware_types_size array
Eugene Syromyatnikov [Mon, 7 May 2018 06:52:30 +0000 (08:52 +0200)]
Provide a value for arp_hardware_types_size array

* defs.h (arp_hardware_types_size): New declaration.
* sockaddr.c (arp_hardware_types_size): New variable.

6 years agoprint_fields.h: introduce PRINT_FIELD_XVAL_SORTED_SIZED
Eugene Syromyatnikov [Wed, 30 May 2018 13:23:37 +0000 (15:23 +0200)]
print_fields.h: introduce PRINT_FIELD_XVAL_SORTED_SIZED

For those cases when array definition is not readily available
and should be provided separately.

* print_fields.h (PRINT_FIELD_XVAL_SORTED_SIZED): New macro.

6 years agotests/opipe.test: remove unneeded run_prog call
Eugene Syromyatnikov [Sun, 3 Jun 2018 08:23:56 +0000 (10:23 +0200)]
tests/opipe.test: remove unneeded run_prog call

There is no need to invoke grep using run_prog.

* tests/opipe.test: Remove run_prog decoration for the grep invocation.

6 years agotests: check BPF_OBJ_GET_INFO_BY_FD decoding
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:55:21 +0000 (02:55 +0200)]
tests: check BPF_OBJ_GET_INFO_BY_FD decoding

* tests/bpf-obj_get_info_by_fd-prog-v.c: New file.
* tests/bpf-obj_get_info_by_fd-prog.c: Likewise.
* tests/bpf-obj_get_info_by_fd-v.c: Likewise.
* tests/bpf-obj_get_info_by_fd.c: Likewise.
* configure.ac (AC_CHECK_HEADERS): Check for struct bpf_insn,
struct bpf_map_info, and struct bpf_prog_info.
* tests/pure_executables.list: Add bpf-obj_get_info_by_fd,
bpf-obj_get_info_by_fd-v, bpf-obj_get_info_by_fd-prog, and
bpf-obj_get_info_by_fd-prog-v.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (bpf-obj_get_info_by_fd,
bpf-obj_get_info_by_fd-v, bpf-obj_get_info_by_fd-prog,
bpf-obj_get_info_by_fd-prog-v): New tests.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: enhance BPF_OBJ_GET_INFO_BY_FD decoder further
Dmitry V. Levin [Mon, 4 Jun 2018 01:11:05 +0000 (01:11 +0000)]
bpf: enhance BPF_OBJ_GET_INFO_BY_FD decoder further

* bpf.c (print_ebpf_prog): Remove "decode" argument, all users updated.
(print_bpf_prog_info): Use the minimum of xlated_prog_len values on
entering and exiting syscall as the size of xlated_prog_insns array
to be decoded.  Likewise, use the minimum of nr_map_ids values on entering
and exiting syscall as the size of map_ids array to be decoded.

6 years agobpf: enhance BPF_OBJ_GET_INFO_BY_FD decoder
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:53:00 +0000 (02:53 +0200)]
bpf: enhance BPF_OBJ_GET_INFO_BY_FD decoder

* bpf.c (print_bpf_map_info): Print only those fields that are
present in the structure, as it has been growing over time.
(print_bpf_prog_info): Likewise.  Print map_ids field as an array
of uint32_t instead of uint64_t; print "name" field.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: move handling of the saved state to BPF_OBJ_GET_INFO_BY_FD decoder
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:49:09 +0000 (02:49 +0200)]
bpf: move handling of the saved state to BPF_OBJ_GET_INFO_BY_FD decoder

As it is needed for proper info_len printing on exiting.

* bpf.c (print_bpf_obj_info_fn): Change return type to void, add "saved"
argument.
(struct obj_get_info_saved): New type definition.
(print_bpf_map_info, print_bpf_prog_info): Change return type to void,
add "saved" argument, do not handle private tcb data allocation and
obtainment.
(print_bpf_obj_info_addr): Change return type to void, add tcb argument,
print the address only on exiting.
(print_bpf_obj_info): Change return type to void, add "saved" argument.
(BEGIN_BPF_CMD_DECODER(BPF_OBJ_GET_INFO_BY_FD)): Handle private data
allocation/saving/restoring, use it for storing/printing info_len field.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: print log_buf field as a string
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:38:35 +0000 (02:38 +0200)]
bpf: print log_buf field as a string

* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)): Print log_buf field
as a string.
* tests/bpf.c: Update expected output.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: print xlated_prog_insns only when xlated_prog_len had not been 0
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:44:04 +0000 (02:44 +0200)]
bpf: print xlated_prog_insns only when xlated_prog_len had not been 0

If xlated_prog_len is zero on entering syscall and non-zero on exiting,
the program itself is not written into xlated_prog_insns.

* bpf.c (print_ebpf_prog): Add decode argument, print the address only
if decode is false.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)): Specify decode == true argument
to print_ebpf_prog.
(print_bpf_prog_info): Specify saved xlated_prog_len as decode argument
to print_ebpf_prog.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: move print_big_u64_addr inside print_ebpf_prog
Eugene Syromyatnikov [Fri, 1 Jun 2018 00:36:59 +0000 (02:36 +0200)]
bpf: move print_big_u64_addr inside print_ebpf_prog

* bpf.c (print_ebpf_prog): Add static qualifier.  Change the type
of "addr" argument from kernel_ulong_t to uint64_t, print it using
print_big_u64_addr.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD), print_bpf_prog_info): Do not call
print_big_u64_addr before print_ebpf_prog.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf_attr.h: add ATTRIBUTE_ALIGNED(8) to all fields of type uint64_t
Dmitry V. Levin [Fri, 1 Jun 2018 19:43:35 +0000 (19:43 +0000)]
bpf_attr.h: add ATTRIBUTE_ALIGNED(8) to all fields of type uint64_t

Our policy is that all fields of type uint64_t in this header file
must have this attribute.

This shouldn't cause any contradictions with <linux/bpf.h>
unless the latter is buggy.

By word "buggy" I mean containing such changes as Linux kernel commit
v4.16-rc1~123^2~109^2~5^2~4.

* bpf_attr.h (struct BPF_MAP_UPDATE_ELEM_struct): Add
ATTRIBUTE_ALIGNED(8) to "flags" field.
(struct bpf_prog_info_struct): Add ATTRIBUTE_ALIGNED(8) to "load_time"
field.

6 years agotests: cast printf arguments to short when %h format qualifier is used
Eugene Syromyatnikov [Sat, 2 Jun 2018 16:25:56 +0000 (18:25 +0200)]
tests: cast printf arguments to short when %h format qualifier is used

Reported by clang.

* tests/mknod.c (main): Cast printf argument for %#03ho format to short.
* tests/mknodat.c (main): Likewise.
* tests/net-sockaddr.c (main): Cast printf argument for %hu format
to short.
* tests/semop.c (main): Likewise.

6 years agoxlat/evdev_keycode.in: remove constants with duplicating values
Eugene Syromyatnikov [Sat, 2 Jun 2018 08:37:01 +0000 (10:37 +0200)]
xlat/evdev_keycode.in: remove constants with duplicating values

Those are used for describing input device category and not specific
button.

Reported by clang.

* xlat/evdev_keycode.in (BTN_MOUSE, BTN_JOYSTICK, BTN_GAMEPAD, BTN_DIGI,
BTN_WHEEL, BTN_TRIGGER_HAPPY): Remove.

6 years agoconfigure.ac: include <sys/socket.h> before <linux/rtnetlink.h>
Eugene Syromyatnikov [Fri, 1 Jun 2018 13:29:25 +0000 (15:29 +0200)]
configure.ac: include <sys/socket.h> before <linux/rtnetlink.h>

This is needed for old Linux UAPI headers that do no contain commit
v3.1-rc2~19^2~29.

* configure.ac: Include <sys/socket.h> before <linux/rtnetlink.h>
in AC_CHECK_* invocations.

6 years agoconfigure.ac: check for linux/rtnetlink.h instead of linux/if_link.h for declarations
Eugene Syromyatnikov [Fri, 1 Jun 2018 10:13:52 +0000 (12:13 +0200)]
configure.ac: check for linux/rtnetlink.h instead of linux/if_link.h for declarations

Historically, type definitions and declarations related to netlink route
interface attributes were in linux/rtnetlink.h, later they were moved
elsewhere (first linux/if.h, then linux/if_link.h) with the inclusion
of the corresponding header file in linux/rtnetlink.h.

* configure.ac: Use <linux/rtnetlink.h> instead of <linux/if_link.h>
in checks for interface netlink attributes-related declarations
and definitions.

6 years agom4: move the gawk script from m4/gen_bpf_attr_m4.sh into a separate file
Eugene Syromyatnikov [Fri, 1 Jun 2018 12:05:48 +0000 (14:05 +0200)]
m4: move the gawk script from m4/gen_bpf_attr_m4.sh into a separate file

As it turns out, old versions of gawk do not support -e option.

* m4/gen_bpf_attr_m4.sh: Move the gawk script ...
* m4/gen_bpf_attr_m4.awk: ... here.

6 years agos390: wire up kexec_file_load syscall
Eugene Syromyatnikov [Fri, 1 Jun 2018 01:20:18 +0000 (03:20 +0200)]
s390: wire up kexec_file_load syscall

* linux/s390/syscallent.h ([381]): Add kexec_file_load syscall.
* linux/s390/syscallent.h ([381]): Likewise.

6 years agotests: check short read of struct flock/flock64
Zhibin Li [Wed, 30 May 2018 11:21:59 +0000 (19:21 +0800)]
tests: check short read of struct flock/flock64

* tests/fcntl-common.c (test_flock_einval): Check short read
of struct flock.
(test_flock64_einval): Check short read of struct flock64.

6 years agotests: extend struct flock/flock64 decoding checks
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests: extend struct flock/flock64 decoding checks

* tests/fcntl-common.c (test_flock_einval, test_flock): Create
struct_kernel_flock object using tail_alloc.
(test_flock64_einval): Create struct_kernel_flock64 object using
tail_alloc.
* tests/fcntl64.c (test_flock64_lk64): Likewise.

6 years agotests: extend F_OFD_* decoding checks
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests: extend F_OFD_* decoding checks

Check that non-faulty F_OFD_* fcntl operations are decoded properly.

* tests/fcntl-common.c: Include <string.h>.
(test_flock64_ofd): New function.
(test_flock64): Invoke it, remove [F_OFD_SETLK].

6 years agotests/fcntl-common.c: define and initialize errstr
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests/fcntl-common.c: define and initialize errstr

Initialize errstr inside invoke_test_syscall so that its users
won't have to go into trouble of caring about clobbering errno.

* tests/fcntl-common.c (errstr): New variable.
(invoke_test_syscall): Initialize it.
(test_flock_einval, test_flock64_einval, test_flock,
test_f_owner_ex_type_pid): Use it.
* tests/fcntl.c (test_flock64_undecoded): Likewise.
* tests/fcntl64.c (test_flock64_lk64): Likewise.

6 years agotests/fcntl-common.c: add fd argument to invoke_test_syscall
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests/fcntl-common.c: add fd argument to invoke_test_syscall

Extend invoke_test_syscall for later use with different file
descriptors.

* tests/fcntl-common.c (invoke_test_syscall): Add fd argument, pass it
to TEST_SYSCALL_NR syscall.  All users updated.

6 years agotests: move F_OFD_SETLK* checks from fcntl64.c to fcntl-common.c
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests: move F_OFD_SETLK* checks from fcntl64.c to fcntl-common.c

This change enables F_OFD_SETLK* tests for fcntl as well.

* tests/fcntl64.c (test_flock64): Rename to test_flock64_lk64.
[F_OFD_SETLK]: Remove.
(test_flock64_einval): Move ...
* tests/fcntl-common.c: ... here.
(test_flock64_lk64): New protype.
(test_flock64_einval, test_flock64): New functions.
* tests/fcntl.c (test_flock64_einval): Rename to test_flock64_undecoded.
(TEST_FLOCK64_UNDECODED): New macro.
(test_flock64): Rename to test_flock64_lk64, replace TEST_FLOCK64_EINVAL
with TEST_FLOCK64_UNDECODED.

6 years agotests: move F_OWNER_* tests to fcntl-common.c
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests: move F_OWNER_* tests to fcntl-common.c

This change enables F_OWNER_* tests for fcntl64 as well.

* tests/fcntl.c: Move main, [TEST_FLOCK64_EINVAL],
and [TEST_F_OWNER_EX] ...
* tests/fcntl-common.c: ... here.
(test_flock64): New prototype.
* tests/fcntl64.c (main): Remove.

6 years agotests: rename struct_flock.c to fcntl-common.c
Dmitry V. Levin [Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)]
tests: rename struct_flock.c to fcntl-common.c

It is not limited to struct flock, more fcntl tests are going to land
in this file.

* tests/struct_flock.c: Rename to fcntl-common.c.
* tests/Makefile.am (EXTRA_DIST): Rename struct_flock.c
to fcntl-common.c.
* tests/fcntl.c: Likewise.
* tests/fcntl64.c: Likewise.

6 years agotests: check decoding of new FRA_* netlink attributes
Eugene Syromyatnikov [Wed, 23 May 2018 16:56:32 +0000 (18:56 +0200)]
tests: check decoding of new FRA_* netlink attributes

* configure.ac (AC_CHECK_TYPES): Check for struct fib_rule_port_range
in <linux/fib_rules.h>.
* tests/nlattr_fib_rule_hdr.c: Include <linux/in.h>.
(FRA_PROTOCOL, FRA_IP_PROTO, FRA_SPORT_RANGE, FRA_DPORT_RANGE): New
macro constants.
[!HAVE_STRUCT_FIB_RULE_PORT_RANGE] (struct fib_rule_port_range): New
type.
(main): Check decoding of new FRA_* netlink attributes.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agortnl_rule: decode new FRA_* attributes
Eugene Syromyatnikov [Mon, 16 Apr 2018 00:02:18 +0000 (02:02 +0200)]
rtnl_rule: decode new FRA_* attributes

* nlattr.h (DECL_NLA(ip_proto), DECL_NLA(rt_proto)): New declarations.
* nlattr.c (decode_nla_ip_proto): New function.
* rtnl_route.c (decode_nla_rt_proto): Likewise.
* rtnl_rule.c (decode_rule_port_rang): Likewise.
(fib_rule_hdr_nla_decoders) <[FRA_PROTOCOL]>: New attribute, introduced
by Linux commit v4.17-rc1~148^2~371.
(fib_rule_hdr_nla_decoders) <[FRA_IP_PROTO], [FRA_SPORT_RANGE],
[FRA_DPORT_RANGE]>: New attributes, introduced by Linux commit
v4.17-rc1~148^2~328^2~4.
* xlat/rtnl_rule_attrs.in (FRA_PROTOCOL, FRA_IP_PROTO, FRA_SPORT_RANGE,
FRA_DPORT_RANGE): New constants.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agonlattr: introduce decode_nla_xval helper
Eugene Syromyatnikov [Mon, 7 May 2018 06:40:02 +0000 (08:40 +0200)]
nlattr: introduce decode_nla_xval helper

* nlattr.c (decode_nla_xval): New function.
* nlattr.h: Include "xlat.h".
(struct decode_nla_xlat_opts): New type.
(DECL_NLA(xval)): New declaration.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoMove definitions of xlat_type and xlat_style from defs.h to xlat.h
Dmitry V. Levin [Wed, 30 May 2018 20:50:29 +0000 (20:50 +0000)]
Move definitions of xlat_type and xlat_style from defs.h to xlat.h

* defs.h (enum xlat_type, enum xlat_style, XLAT_STYLE_FORMAT_SHIFT,
XLAT_STYLE_VERBOSITY_MASK, XLAT_STYLE_FORMAT_MASK, XLAT_STYLE_SPEC_BITS,
XLAT_STYLE_MASK): Move ...
* xlat.h: ... here.

6 years agotravis: switch from gcc-7 to gcc-8
Dmitry V. Levin [Wed, 30 May 2018 10:54:34 +0000 (10:54 +0000)]
travis: switch from gcc-7 to gcc-8

* .travis.yml (matrix): Change gcc-7 to gcc-8.

6 years agotests: use syscall() for ioctl() calls with oversized arguments
Eugene Syromyatnikov [Wed, 30 May 2018 14:44:55 +0000 (16:44 +0200)]
tests: use syscall() for ioctl() calls with oversized arguments

* tests/ioctl_inotify.c (sys_ioctl): New function.
(main): Use sys_ioctl for ioctl calls with oversized arguments.
* tests/ioctl_loop.c: Likewise.
* tests/ioctl_perf.c: Likewise.

6 years agoprint_ifindex: respect xlat style settings
Eugene Syromyatnikov [Mon, 7 May 2018 06:42:24 +0000 (08:42 +0200)]
print_ifindex: respect xlat style settings

Print interface indices according to the preferred xlat style settings.

* print_ifindex.c (INI_PFX, INI_SFX): New helper macros.
[HAVE_IF_INDEXTONAME] (get_ifname): New function.
[HAVE_IF_INDEXTONAME] (print_ifindex): Implement as a wrapper around
get_ifname and print_xlat_ex.

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

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

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

6 years agonlattr: print index names in netlink meminfo array
Eugene Syromyatnikov [Thu, 10 May 2018 16:29:39 +0000 (18:29 +0200)]
nlattr: print index names in netlink meminfo array

* xlat/netlink_sk_meminfo_indices.in: New file.
* nlattr.c: Include xlat/netlink_sk_meminfo_indices.h.
(decode_nla_meminfo): Use print_array_ex, pass
netlink_sk_meminfo_indices as index xlat table.
* tests/nlattr_inet_diag_msg.c: Update expected output.

6 years agoIntroduce ARRSZ_PAIR macro
Eugene Syromyatnikov [Mon, 7 May 2018 06:24:56 +0000 (08:24 +0200)]
Introduce ARRSZ_PAIR macro

A shorthand similar to ARG_STR in its purpose: it provides and ability
to pass an array an its size without variable name duplication.

* macros.h (ARRSZ_PAIR): New macro.

6 years agoprint_array: add support for printing array indices
Eugene Syromyatnikov [Mon, 7 May 2018 06:06:14 +0000 (08:06 +0200)]
print_array: add support for printing array indices

* defs.h (XLAT_STYLE_SPEC_BITS, XLAT_STYLE_MASK): New macro constants.
(tfetch_mem_fn, print_fn): New typedefs.
(enum print_array_flag_bits, enum print_array_flags): New enumerations.
(print_array_ex): Rename from print_array, add flags, index_xlat,
index_xlat_size, and index_dflt arguments.
(print_array): New static inline function, a thin wrapper around
print_array_ex.
util.c: Include "xlat.h".
(print_array): Rename to print_array_ex, add flags, index_xlat,
index_xlat_size, and index_dflt arguments.  Print array indices
according to the style settings specified by flags if PAF_PRINT_INDICES
is set.

6 years agoEnhance printing of unfetchable object addresses in sequences and arrays
Dmitry V. Levin [Tue, 29 May 2018 09:58:10 +0000 (09:58 +0000)]
Enhance printing of unfetchable object addresses in sequences and arrays

* btrfs.c (btrfs_print_tree_search): Print the address of unfetchable
object inside the sequence using printaddr_comment.
* msghdr.c (decode_msg_control): Likewise.
* execve.c (printargv): Print the address of unfetchable object inside
the array using printaddr_comment.
* netlink.c (fetch_nlmsghdr): Add in_array argument.  When in_array
is true, print the address of unfetchable object using
printaddr_comment.
* nlattr.c (fetch_nlattr): Likewise.
* tests/execve.c (main): Update expected output.
* tests/execveat.c (main): Likewise.
* tests/msg_control.c (test_scm_rights1, test_scm_rights2,
test_scm_security): Likewise.
* tests/netlink_protocol.c (send_query): Likewise.
* tests/nlattr.c (test_nlattr): Likewise.

6 years agoprint_array: enhance printing of unfetchable object addresses
Dmitry V. Levin [Tue, 29 May 2018 01:15:19 +0000 (01:15 +0000)]
print_array: enhance printing of unfetchable object addresses

When umoven_func invocation fails to fetch data, it prints the faulty
address.  If this happens to a subsequent umoven_func invocation,
the printed address may be undistinguishable from a valid data printed
by print_func, e.g. when the data is printed in a numeric form like
[0x1, 0x2, 0x3, 0xdefaced].

Fix this source of confusion by moving the printing of the faulty
address from umoven_func to print_array itself.  This change renames
umoven_func to tfetch_mem_func and changes its semantics, so that
 - tfetch_mem_func never prints anything;
 - tfetch_mem_func returns true if the fetch succeeded,
   and false otherwise.

* defs.h (print_array): Replace umoven_func argument with
tfetch_mem_func.
* util.c (print_array): Replace umoven_func argument with
tfetch_mem_func, document expected tfetch_mem_func return value
semantics.  When tfetch_mem_func returns false, print either addr
or "... /* addr */" depending on the context (inside the array or not).
* bpf.c (print_ebpf_prog, print_bpf_prog_info,
BEGIN_BPF_CMD_DECODER(BPF_PROG_QUERY)): Replace umoven_or_printaddr
argument of print_array with tfetch_mem.
* bpf_filter.c (print_bpf_fprog): Likewise.
* btrfs.c (btrfs_print_logical_ino_container,
btrfs_print_ino_path_container, btrfs_print_qgroup_inherit,
btrfs_ioctl): Likewise.
* dm.c (dm_decode_dm_target_deps): Likewise.
* epoll.c (epoll_wait_common): Likewise.
* file_ioctl.c (file_ioctl): Likewise.
* ipc_sem.c (tprint_sembuf_array): Likewise.
* kexec.c (print_kexec_segments): Likewise.
* mem.c (SYS_FUNC(subpage_prot)): Likewise.
* net.c (print_getsockopt): Likewise.
* netlink.c (decode_nlmsgerr_attr_cookie): Likewise.
* netlink_netlink_diag.c (decode_netlink_diag_groups): Likewise.
* netlink_packet_diag.c (decode_packet_diag_mclist): Likewise.
* netlink_unix_diag.c (decode_unix_diag_inode): Likewise.
* nlattr.c (decode_nla_meminfo): Likewise.
* numa.c (print_nodemask, SYS_FUNC(move_pages),
* perf_ioctl.c (perf_ioctl_query_bpf): Likewise.
* poll.c (decode_poll_entering): Likewise.
* printsiginfo.c (print_siginfo_array): Likewise.
* rtnl_tc.c (decode_tca_stab_data): Likewise.
* sock.c (decode_ifconf): Likewise.
* uid.c (print_groups): Likewise.
* io.c (SYS_FUNC(io_submit), SYS_FUNC(io_getevents)): Replace
umoven_or_printaddr argument of print_array with tfetch_mem.
(tprint_iov_upto): Replace umoven_or_printaddr_ignore_syserror
with tfetch_mem_ignore_syserror.
* v4l2.c (print_v4l2_format_fmt): Replace umoven_or_printaddr argument
of print_array with tfetch_mem.
(print_v4l2_ext_controls): Replace umoven_or_printaddr_ignore_syserror
with tfetch_mem_ignore_syserror.
* mmsghdr.c (fetch_struct_mmsghdr_or_printaddr): Rename
to fetch_struct_mmsghdr_for_print, do not print address, return bool.
(decode_mmsgvec): Replace fetch_struct_mmsghdr_or_printaddr
with fetch_struct_mmsghdr_for_print.
* tests/aio.c (main): Update expected output.
* tests/bpf.c (print_BPF_PROG_QUERY_attr5): Likewise.
* tests/ioctl_perf-success.c (main): Likewise.
* tests/ioctl_v4l2.c (main): Update expected output.
* tests/kexec_load.c (main): Likewise.
* tests/mmsg_name.c (test_mmsg_name): Update expected output.
* tests/move_pages.c (print_page_array, print_node_array): Likewise.
* tests/poll.c (print_pollfd_array_entering): Likewise.
* tests/preadv-pwritev.c (main): Likewise.
* tests/preadv2-pwritev2.c (dumpio): Likewise.
* tests/process_vm_readv_writev.c (print_iov): Likewise.
* tests/pwritev.c (print_iovec): Likewise.
* tests/readv.c (main): Likewise.
* tests/seccomp-filter-v.c
* tests/semop.c (main): Likewise.
* tests/set_mempolicy.c (print_nodes): Likewise.
* tests/setgroups.c (main): Likewise.
* tests/test_nlattr.h (print_nlattr) Likewise.

Co-Authored-by: Eugene Syromyatnikov <evgsyr@gmail.com>
6 years agoIntroduce tfetch_* family of functions and macros
Dmitry V. Levin [Mon, 28 May 2018 11:32:03 +0000 (11:32 +0000)]
Introduce tfetch_* family of functions and macros

These new functions are going to be used instead of umove_or_printaddr*
as umoven_func argument of print_array.

* defs.h (tfetch_mem64, tfetch_mem64_ignore_syserror): New
function prototypes.
(tfetch_mem, tfetch_mem_ignore_syserror): New static inline
wrappers.
(tfetch_obj): New macro wrapper around tfetch_mem.
* util.c (tfetch_mem64, tfetch_mem64_ignore_syserror): New
functions.
(umoven_or_printaddr64, umoven_or_printaddr64_ignore_syserror): Use
them.

6 years agoIntroduce printaddr_comment
Dmitry V. Levin [Tue, 29 May 2018 09:58:10 +0000 (09:58 +0000)]
Introduce printaddr_comment

* defs.h (printaddr_comment): New static inline wrapper around
tprintf_comment.

6 years agoTurn printaddr into a thin wrapper around printaddr64
Dmitry V. Levin [Tue, 29 May 2018 09:58:10 +0000 (09:58 +0000)]
Turn printaddr into a thin wrapper around printaddr64

* util.c (printaddr): Move ...
* defs.h: ... here, add "static inline" qualifiers.

6 years agodefs.h: add comments about umove* return values
Eugene Syromyatnikov [Sun, 20 May 2018 15:47:04 +0000 (17:47 +0200)]
defs.h: add comments about umove* return values

* defs.h (umoven, umoven_or_printaddr64,
umoven_or_printaddr64_ignore_syserror, umovestr): Add comments about
return values.

6 years agotests: use TAIL_ALLOC_OBJECT_CONST_PTR where appropriate
Dmitry V. Levin [Mon, 28 May 2018 17:34:50 +0000 (17:34 +0000)]
tests: use TAIL_ALLOC_OBJECT_CONST_PTR where appropriate

* tests/kcmp.c (main): Use TAIL_ALLOC_OBJECT_CONST_PTR.
* tests/modify_ldt.c (main): Likewise.
* tests/netlink_protocol.c (send_query): Likewise.
* tests/ptrace.c (test_peeksiginfo, main): Likewise.
* tests/s390_guarded_storage.c (main): Likewise.
* tests/s390_sthyi.c (main): Likewise.
* tests/xet_thread_area_x86.c (main): Likewise.

6 years agobpf: decode bpf_attr.info field used by BPF_OBJ_GET_INFO_BY_FD command
Eugene Syromyatnikov [Mon, 5 Mar 2018 14:56:35 +0000 (15:56 +0100)]
bpf: decode bpf_attr.info field used by BPF_OBJ_GET_INFO_BY_FD command

* bpf_attr.h [!BPF_TAG_SIZE] (BPF_TAG_SIZE): Define.
[BPF_TAG_SIZE]: Check that BPF_TAG_SIZE is 8.
(struct bpf_map_info_struct, struct bpf_prog_info_struct): New
structures.
(bpf_map_info_struct_size, expected_bpf_map_info_struct_size,
bpf_prog_info_struct_size, expected_bpf_prog_info_struct_size): New
macro constants.
* bpf.c (print_bpf_obj_info_fn): New type.
(print_bpf_map_info, print_bpf_prog_info, fetch_bpf_obj_info,
print_bpf_obj_info_addr, print_bpf_obj_info): New functions.
(BEGIN_BPF_CMD_DECODER(BPF_OBJ_GET_INFO_BY_FD)): Print bpf_fd and info_len
fields only on entering, call print_bpf_obj_info for printing info field.
* tests/bpf.c (BPF_OBJ_GET_INFO_BY_FD_checks): Print info field
as a pointer.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: add support for checking structures outside union bpf_attr
Eugene Syromyatnikov [Sun, 20 May 2018 23:24:08 +0000 (01:24 +0200)]
bpf: add support for checking structures outside union bpf_attr

struct bpf_prog_info and bpf_map_info need essentially the same handling
as union bpf_attr.

* gen_bpf_attr_check.sh: Derive type_name from $struct if it doesn't
start with "BPF_", derive TYPE_NAME from type_name, use them in code
generation.
* m4/gen_bpf_attr_m4.sh: Rewrite parsing/generation code into awk,
add support for structures outside union bpf_attr.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: remove bpf_priv_data
Dmitry V. Levin [Sat, 26 May 2018 10:32:54 +0000 (10:32 +0000)]
bpf: remove bpf_priv_data

As various bpf commands need different data to save between entering
and exiting of the syscall, do not emulate union bpf_attr approach.

* bpf.c (struct bpf_priv_data): Remove.
(DECL_BPF_CMD_DECODER): Remove "struct bpf_priv_data *" argument.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_QUERY)): Use set_tcb_priv_ulong
and get_tcb_priv_ulong to keep bpf_attr.query.prog_cnt field.
(SYS_FUNC(bpf)): Remove priv variable, do not initialize it,
and do not pass it to bpf_cmd_decoders.

6 years agotests: add union bpf_attr.query.prog_ids field decoding checks
Eugene Syromyatnikov [Sun, 20 May 2018 16:00:12 +0000 (18:00 +0200)]
tests: add union bpf_attr.query.prog_ids field decoding checks

* tests/bpf-success-v.c: New file.
* tests/bpf-success.c: Likewise.
* tests/bpf-success-v.test: New test.
* tests/bpf-success.test: Likewise.
* tests/.gitignore: Add bpf-success and bpf-success-v.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add bpf-success.test and bpf-success-v.test.
* tests/bpf.c [INJECT_RETVAL] (sys_bpf): Check that retuned value
is equivalent to the injected one; append "(INJECTED)" string to errstr.
(prog_load_ids, prog_load_ids_ptr): New variables.
(init_BPF_PROG_QUERY_attr4, print_BPF_PROG_QUERY_attr4,
init_BPF_PROG_QUERY_attr5, print_BPF_PROG_QUERY_attr5): New functions.
(BPF_PROG_QUERY_checks): Drop "const" qualifier, add new checks.

6 years agobpf: BPF_PROG_QUERY bpf_attr.query.prog_ids printing fixes
Eugene Syromyatnikov [Sun, 20 May 2018 15:57:02 +0000 (17:57 +0200)]
bpf: BPF_PROG_QUERY bpf_attr.query.prog_ids printing fixes

* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_PROG_QUERY)): Use
print_uint32_array_member instead of print_uint64_array_member for
printing prog_ids elements (and change the type of prog_id_buf from
uint64_t to uint32_t), as they are 32-bit; use common trick with
print_big_u64_addr for handling possible ambiguity with prog_ids
address.
* tests/bpf.c (BIG_ADDR_MAYBE): New macro.
(BPF_PROG_QUERY_checks): Update expected output.

6 years agobpf: add support for instruction decoding
Eugene Syromyatnikov [Thu, 22 Feb 2018 06:58:30 +0000 (07:58 +0100)]
bpf: add support for instruction decoding

* xlat/ebpf_regs.in: New file.
* bpf.c (struct ebpf_insn, struct ebpf_insns_data): New type definitions.
(print_ebpf_insn, print_ebpf_prog): New functions.
(DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)): Use them.

6 years agotests: check decoding of successful PERF_EVENT_IOC_{ID,QUERY_BPF} ioctls
Eugene Syromyatnikov [Mon, 28 May 2018 17:34:50 +0000 (19:34 +0200)]
tests: check decoding of successful PERF_EVENT_IOC_{ID,QUERY_BPF} ioctls

As these have some argument output on the exit path.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Replace BIG_ADDR_IS_64BIT and BIG_ADDR_IS_32BIT with BIG_ADDR().

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

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

Introduce BIG_ADDR_IS_64BIT and BIG_ADDR_IS_32BIT to reduce redundancy.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

In preparation for the forthcoming changes.

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

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

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

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

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

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

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

And make the output more structured.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This reverts commit cc52da10c6f13feba577a83088f34916c6350165
in preparation for printxval_dispatch generalisation.

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

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

This macro is going to be used in inline checks.

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

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

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

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

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

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