6758 Commits

Author SHA1 Message Date
Eugene Syromyatnikov
03b50140c7 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).
2018-05-23 23:27:43 +00:00
Eugene Syromyatnikov
9b2605de2d 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.
2018-05-23 23:27:43 +00:00
Eugene Syromyatnikov
0f1cf622ba 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.
2018-05-23 23:27:43 +00:00
Eugene Syromyatnikov
4245bdfe41 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.
2018-05-23 23:27:43 +00:00
Eugene Syromyatnikov
ddf97dcf74 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.
2018-05-23 23:27:43 +00:00
Eugene Syromyatnikov
8aa2908a4d defs.h: move print_uint64_array_member and print_array declarations down
In preparation for the forthcoming changes.
2018-05-23 23:27:43 +00:00
Eugene Syromyatnikov
acd3d3e992 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.
2018-05-23 23:27:43 +00:00
Eugene Syromyatnikov
7ff51ab3d8 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.
2018-05-23 23:27:43 +00:00
Eugene Syromyatnikov
a112d4a0fd 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.
2018-05-23 23:27:43 +00:00
df9ddd8632 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.
2018-05-22 01:08:31 +00:00
Eugene Syromyatnikov
0a5cc72a62 strace.1.in: mention -Xraw in -eraw description
* strace.1.in (\fB\-e\ raw\fR=\,\fIset\fR): Mention -X raw.
2018-05-21 11:02:54 +00:00
Eugene Syromyatnikov
e453f28934 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.
2018-05-21 11:02:54 +00:00
Eugene Syromyatnikov
4531bae51a 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.
2018-05-21 11:02:54 +00:00
Eugene Syromyatnikov
48af7b3c25 tests/qual_fault.test: add -efu arguments to the interpreter
* tests/qual_fault.test (#!/bin/sh): Add -efu arguments.
2018-05-21 11:02:54 +00:00
Eugene Syromyatnikov
fbfe5335e5 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.
2018-05-21 11:02:54 +00:00
25efe1822a 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.
2018-05-21 11:02:54 +00:00
Eugene Syromyatnikov
3869880887 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>
2018-05-21 11:02:54 +00:00
Eugene Syromyatnikov
947627ed15 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.
2018-05-21 11:02:54 +00:00
Eugene Syromyatnikov
095f97cab5 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.
2018-05-21 11:02:54 +00:00
Eugene Syromyatnikov
c6143f3e41 defs.h: introduce is_bigendian macro
This macro is going to be used in inline checks.

* defs.h (is_bigendian): New macro constant.
2018-05-21 11:02:54 +00:00
Eugene Syromyatnikov
0b578fd0ba 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>
2018-05-21 11:02:54 +00:00
Eugene Syromyatnikov
11eb621896 strace.1.in: fix -A description
* strace.1.in (.SS Output format) <-A>: Add missing .B.
2018-05-19 09:15:27 +00:00
Eugene Syromyatnikov
bca93b2a18 strace.1.in: document x32 64-bit syscall peculiarity
* strace.1.in (.SH NOTES): Document "#64" suffix for 64-bit syscalls on
x32.
2018-05-19 09:15:27 +00:00
Eugene Syromyatnikov
299fa3fcac linux/x32/syscallent.h: change 64-bit syscall designation
The current way of designation of 64-bit specific syscalls in x32
personality not only conflicts with fault injection specification
syntax, but also makes it impossible to specify such syscalls at all
(since everything that starts from a digit is considered a syscall
number specification).  So, let's change prefix to suffix and use
octothorpe instead of colon as a separator.

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

Closes: https://github.com/strace/strace/issues/36
2018-05-19 09:15:27 +00:00
Eugene Syromyatnikov
871a9107df xlat: add BPF_PROG_TYPE_SK_MSG
* xlat/bpf_prog_types.in (BPF_PROG_TYPE_SK_MSG): New constant,
introduced by Linux commit v4.17-rc1~148^2~156^2~1^2~13.
* tests/bpf.c (BPF_PROG_LOAD_checks): Update expected output.
2018-05-19 09:15:27 +00:00
Eugene Syromyatnikov
b532e92c6e xlat: update bpf_attach_type constants
* xlat/bpf_attach_type.in (BPF_SK_MSG_VERDICT): New constant,
introduced by Linux commit v4.17-rc1~148^2~156^2~1^2~13.
(BPF_CGROUP_INET4_BIND, BPF_CGROUP_INET6_BIND): New constants,
introduced by Linux commit v4.17-rc1~148^2~19^2^2~6.
(BPF_CGROUP_INET4_CONNECT, BPF_CGROUP_INET6_CONNECT): New constants,
introduced by Linux commit v4.17-rc1~148^2~19^2^2~3.
(BPF_CGROUP_INET4_POST_BIND, BPF_CGROUP_INET6_POST_BIND): New constants,
introduced by Linux commit v4.17-rc1~148^2~19^2^2~1.
* tests/bpf.c (BPF_PROG_QUERY_checks): Update expected output.
2018-05-19 09:15:27 +00:00
Eugene Syromyatnikov
2604ea997b xlat/sock_rds_options.in: make it sorted
Define SO_TIMESTAMP twice, for PA-RISC and all the other architectures.

* xlat/sock_rds_options.in [!__hppa__] (SO_TIMESTAMP): Define to 29.
[__hppa__] (SO_TIMESTAMP): Define to 0x4012.
* net.c (print_sockopt_fd_level_name) <case SOL_RDS>: Use
printxval_search instead of printxval.
2018-05-19 09:15:27 +00:00
Gleb Fotengauer-Malinovskiy
a94e301a9f Update ioctl entries from linux v4.17
* linux/32/ioctls_inc_align16.h: Update from linux v4.17-rc5
using ioctls_gen.sh.
* linux/32/ioctls_inc_align32.h: Likewise.
* linux/32/ioctls_inc_align64.h: Likewise.
* linux/64/ioctls_inc.h: Likewise.
* linux/x32/ioctls_inc0.h: Likewise.
* linux/i386/ioctls_arch0.h: Likewise.
* linux/x86_64/ioctls_arch0.h: Likewise.
* NEWS: Mention this.
2018-05-17 22:54:45 +03:00
Gleb Fotengauer-Malinovskiy
d29f44fd49 maint: update for linux 4.17-rc5
* maint/ioctls_sym.sh: (x86_list): Add KVM_HYPERV_EVENTFD.
2018-05-17 22:54:35 +03:00
cb3a15fe21 bpf: use indexed lookups where appropriate
* xlat/bpf_attach_type.in: Add "#value_indexed" directive.
* xlat/bpf_class.in: Likewise.
* xlat/bpf_map_types.in: Likewise.
* xlat/bpf_map_update_elem_flags.in: Likewise.
* xlat/bpf_prog_types.in: Likewise.
* xlat/ebpf_class.in: Likewise.
* bpf_filter.c (print_bpf_filter_code): Use printxval_index
instead of printxval for decoding bpf_class and ebpf_class.
* print_fields.h (PRINT_FIELD_XVAL_INDEX): New macro.
* bpf.c: Use it instead of PRINT_FIELD_XVAL for decoding bpf_attach_type,
bpf_map_types, bpf_map_update_elem_flags, and bpf_prog_types.
2018-05-16 10:58:32 +00:00
dbaa7ae9b4 bpf: use printxval_index lookup instead of printxval
* xlat/bpf_commands.in: Add "#value_indexed" directive.
* bpf.c (SYS_FUNC(bpf)): Use printxval_index instead of printxval.
2018-05-15 21:41:47 +00:00
4e0c0becf9 time: use indexed lookups
* defs.h (xlat_idx): New prototype.
* xlat.c (xlat_idx): Remove static qualifier.
* time.c (do_adjtimex): Use xlat_idx instead of xlookup.
(SYS_FUNC(getitimer), SYS_FUNC(setitimer)): Use printxval_index
instead of printxval.
[ALPHA] (SYS_FUNC(osf_getitimer), SYS_FUNC(osf_setitimer)): Likewise.
(printclockname) [CLOCKID_TO_FD]: Likewise.
* xlat/adjtimex_state.in: Add "#value_indexed" directive.
* xlat/clocknames.in: Likewise.
* xlat/cpuclocknames.in: Add "#value_indexed" directive, add default
values to constants.
* xlat/itimer_which.in: Likewise.
2018-05-15 21:41:47 +00:00
Andre McCurdy
0c75ebaad0 linux/arm/raw_syscall.h: avoid r7 specified register variables with Thumb
If Thumb code is being generated and frame pointers are enabled, the
Thumb frame pointer in r7 clashes with any local variable which may
need to be assigned to r7 (e.g. the syscall NR when making a raw
syscall).

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

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

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

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

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

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

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
2018-05-15 21:41:47 +00:00
3ab43e0228 sockaddr: use printxval_index lookup instead of printxval
* xlat/addrfams.in: Add "#value_indexed" directive.
* xlat/af_packet_types.in: Likewise.
* xlat/hci_channels.in: Likewise.
* sockaddr.c (print_sockaddr_data_bt, print_sockaddr,
* print_sockaddr_data_ll): Use printxval_index instead of printxval.
2018-05-15 21:41:47 +00:00
Eugene Syromyatnikov
c89c8faa63 sockaddr: use printxval_search for ARPHRD_* constants
This xlat table is quite big.

* sockaddr.c (print_sockaddr_data_ll): Replace printxval call with
printxval_search for printing of struct sockaddr_ll.sll_hatype field.
2018-05-15 21:41:47 +00:00
Eugene Syromyatnikov
dc7901f5c3 Add a common MAC address printing routine
* print_mac.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (sprint_mac_addr): New declaration.
(print_mac_addr): New function, a thin wrapper around sprint_mac_addr.
* print_fields.h (PRINT_FIELD_MAC, PRINT_FIELD_MAC_SZ): New macros.
* rtnl_link.c (decode_ifla_bridge_id): Use PRINT_FIELD_MAC for bridge
address printing.
* sock.c (print_ifreq) <case SIOCGIFHWADDR>: Use print_mac_addr for
ifr_hwaddr printing.
* sockaddr.c (print_sockaddr_data_bt): Use print_mac_addr for
{sco,rc,l2}_bdaddr field printing.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-15 21:41:47 +00:00
Eugene Syromyatnikov
2d82c2c50a sockaddr: decode Bluetooth L2 CID values
* xlat/bluetooth_l2_cid.in: New file.
* sockaddr.c: Include xlat/bluetooth_l2_cid.h.
(print_bluetooth_l2_cid): New function.
(print_sockaddr_data_bt): Use it to decode struct sockaddr_l2.l2_cid
field.
* tests/net-sockaddr.c (check_l2): Update expected output.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-15 21:41:47 +00:00
Eugene Syromyatnikov
0e72230ef3 sockaddr: decode Bluetooth L2 PSM values
* xlat/bluetooth_l2_psm.in: New file.
* sockaddr.c: Include xlat/bluetooth_l2_psm.h.
(print_bluetooth_l2_psm): New function.
(print_sockaddr_data_bt): Use it to decode struct sockaddr_l2.l2_psm
field.
* tests/net-sockaddr.c (check_l2): Update expected output.
2018-05-15 21:41:47 +00:00
Eugene Syromyatnikov
9da6cfcc46 sockaddr: decode bluetooth address type names
* xlat/bdaddr_types.in: New file.
* sockaddr.c: Include xlat/bdaddr_types.h.
(print_sockaddr_data_bt): Decode struct sockaddr_l2.l2_bdaddr_type field
using constants from bdaddr_types xlat.
* tests/net-sockaddr.c (check_l2): Check decoding
of struct sockaddr_l2.l2_bdaddr_type field.
2018-05-15 21:41:47 +00:00
Eugene Syromyatnikov
17dbd04e65 sockaddr: decode Bluetooth socket address unconditionally
* sockaddr.c [HAVE_BLUETOOTH_BLUETOOTH_H]: Do not include
bluetooth/bluetooth.h, bluetooth/hci.h, bluetooth/l2cap.h,
bluetooth/rfcomm.h, and bluetooth/sco.h.
[!HAVE_BLUETOOTH_BLUETOOTH_H]: Include xlat/hci_channels.h.
(btohs): New function.
(print_sockaddr_data_bt): Define unconditionally, add definitions
of struct sockaddr_hci, struct bdaddr, struct sockaddr_sco,
struct sockaddr_rc, and struct sockaddr_l2.
(sa_printers) <AF_BLUETOOTH>: Define unconditionally.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-15 21:41:47 +00:00
Eugene Syromyatnikov
6e0abf45e4 Avoid using print_array as a local variable name
We have a function with the same name.

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

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-15 13:30:16 +00:00
Eugene Syromyatnikov
27f2d621ee xlat: update MSG_* constants
Sync them with kernel's include/linux/socket.h, since syscalls perform
almost no checks for incorrect flags.

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

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-15 13:30:16 +00:00
4e4ac87b03 socketutils: use exact match of unix domain sockets on fresh kernels
* socketutils.c (unix_send_query): Do not add NLM_F_DUMP to nlmsg_flags
when kernel version is 4.4.4 or later, initialize udiag_cookie
unconditionally.

Complements: v4.12~536 ("Change unix_diag requests back to use full dump instead of exact match")
2018-05-14 22:54:33 +00:00
Eugene Syromyatnikov
95ce60d1da socketutils: do not request NDIAG_SHOW_MEMINFO
This information is not used and it looks like it negatively affects
ability to find the socket under high load.

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

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-14 17:20:21 +00:00
Eugene Syromyatnikov
346e8002b0 tests: introduce midtail_alloc and use it in netlink tests
netlink tests happen to access memory located before the tail_malloc'ed
pointers, a practice that doesn't go well with the latest compilers
because tail_malloc is marked with ATTRIBUTE_MALLOC.
For example, glibc in -D_FORTIFY_SOURCE=2 mode and gcc 8 with
-Warray-bounds enabled complain about negative offsets out of bounds.
Fix this issue by introducing midtail_alloc.

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

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-09 22:01:45 +00:00
Eugene Syromyatnikov
afc49df0b0 Use MIN where appropriate
* netlink.c (decode_nlmsghdr_with_payload): Use MIN.
* netlink_packet_diag.c (print_packet_diag_mclist): Likewise.
* nlattr.c (decode_nlattr_with_data): Likewise.
* rtnl_route.c (decode_rta_multipath): Likewise.
2018-05-09 22:01:45 +00:00
Eugene Syromyatnikov
3f59353ab3 xlat: add fallback definitions to {msg,sem,shm}ctl command constants
* xlat/msgctl_flags.in: Add default values to all constants, reorder
to make them sorted by value.
* xlat/semctl_flags.in: Likewise.
* xlat/shmctl_flags.in: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-09 22:01:45 +00:00
Eugene Syromyatnikov
22f04a6c69 xlat: add MSG_STAT_ANY
* xlat/msgctl_flags.in (MSG_STAT_ANY): New constant, introduced
by Linux commit v4.17-rc1~52^2~21.
* tests/ipc_msg.c: Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-09 22:01:45 +00:00
Eugene Syromyatnikov
4fb8970101 xlat: add SEM_STAT_ANY
* xlat/semctl_flags.in (SEM_STAT_ANY): New constant, introduced
by Linux commit v4.17-rc1~52^2~22.
* tests/ipc_sem.c: Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-09 22:01:45 +00:00
Eugene Syromyatnikov
fe6e9eaa99 xlat: add SHM_STAT_ANY
* xlat/shmctl_flags.in (SHM_STAT_ANY): New constant, introduced
by Linux commit v4.17-rc1~52^2~23.
* tests/ipc_shm.c: Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-09 22:01:45 +00:00