7238 Commits

Author SHA1 Message Date
Eugene Syromyatnikov
9ea764c377 syslog: fix argument printing
* syslog.c (SYS_FUNC(syslog)): Store conversion to int of tcp->u_arg[2]
in len; print address using printaddr64 (as syslog doesn't use compat
for x32), and third argument as int (as it has this type in the syscall
handler).
* tests/syslog.c: Add checks.
2018-09-27 07:15:30 +02:00
Eugene Syromyatnikov
a6e6d0aa1f syslog: do not print bufp and len for commands that ignore them
* syslog.c (SYS_FUNC(syslog)): Defer printing of comma after the first
argument to the specific command handlers, return RVAL_DECODED without
additional printing for SYSLOG_ACTION_CLOSE, SYSLOG_ACTION_OPEN,
SYSLOG_ACTION_CLEAR, SYSLOG_ACTION_CONSOLE_OFF,
SYSLOG_ACTION_CONSOLE_ON, SYSLOG_ACTION_SIZE_UNREAD,
SYSLOG_ACTION_SIZE_BUFFER.
* tests/syslog.c: Add checks.
2018-09-27 04:37:14 +02:00
Eugene Syromyatnikov
1324a28cc7 fixup! syslog: print syslog command with verbose style, as it is not in UAPI 2018-09-27 00:29:18 +02:00
Eugene Syromyatnikov
394ba90034 syslog: fix switch statement indentation
* syslog.c (SYS_FUNC(syslog)): Decrease indentation level of case
clauses in the switch statement.
2018-09-27 00:27:21 +02:00
Eugene Syromyatnikov
60b094103f syslog: print syslog command with verbose style, as it is not in UAPI
* syslog.c (SYS_FUNC(syslog)): Print syslog_action_type using
XLAT_STYLE_VERBOSE.
* tests/syslog.c: Update expected output.
2018-09-26 18:56:15 +02:00
Eugene Syromyatnikov
c35f9466a8 syslog: move constant definitions to xlat
* syslog.c (enmu): Remove
* xlat/syslog_action_type.in: Add fallback values.
2018-09-26 18:28:55 +02:00
Eugene Syromyatnikov
52981bfb48 fixup! futex: print uaddr value 2018-09-25 16:09:25 +02:00
Eugene Syromyatnikov
8015a74269 inotify: implement inotify fd I/O decoding support
* defs.h (decode_inotify_read): New declaration.
* inotify.c: Include "print_fields.h".
(decode_inotify_read): New function.
* io.c (decode_readbuf) <decoders>: Add decoder for anon_inode:inotify.
2018-09-25 12:18:23 +02:00
Eugene Syromyatnikov
78fd3aa2b8 fanotify: decode fanotify fd I/O
* xlat/fan_responses.in: New file.
* defs.h (decode_fanotify_read, decode_fanotify_write): New
declarations.
* fanotify.c: Include "print_fields.h".
[!FAN_AUDIT] (FAN_AUDIT): New macro definition.
Include "xlat/fan_responses.h".
(print_fanfd, decode_fanotify_read, decode_fanotify_write): New
functions.
* io.c (decode_readbuf): Add fanotify fd decoder using
decode_fanotify_read.
(decode_writebuf): Add fanotify fd decoder using decode_fanotify_write.
2018-09-25 03:17:33 +02:00
Eugene Syromyatnikov
4f72de66f4 io: add I/O buffer decoding infrastructure
* defs.h (enum fileops): New enumeration definition.
(filebuf_decoder_fn): New type definition.
* io.c: Include <fnmatch.h>
(struct filebuf_decoder_desc): New type definition.
(decode_filebuf, decode_readbuf, decode_writebuf): New functions.
(SYS_FUNC(read), SYS_FUNC(write), SYS_FUNC(pread), SYS_FUNC(pwrite)):
Call decode_readbuf/decode_writebuf instead of printing I/O buffer as a
string.
2018-09-25 01:57:22 +02:00
Eugene Syromyatnikov
ef330a84d9 msghdr: decode SO_RXQ_OVFL control packet
* xlat/scmvals.in (SO_RXQ_OVFL): New constant.
* msghdr.c (cmsg_socket_printers) <[SO_RXQ_OVFL]>: New socket option
decoder.
2018-09-24 20:53:16 +02:00
Eugene Syromyatnikov
1090f31204 xlat: use fallback definitions syntax in scmvals
* xlat/scmvals.in: Rewrite using fallback value definition syntax.
2018-09-24 20:51:15 +02:00
Eugene Syromyatnikov
1aca712d4a maint: add support for whitespace between # and define in gen_xlat_defs
* maint/gen_xlat_defs.sh: Change regular expressions for parsing common
and arch-specific files so they match macro definitions where whitespace
between "#" and "define" is present.
2018-09-24 20:39:01 +02:00
Eugene Syromyatnikov
bca69f9e39 linux/arm/syscallent.h: Add a comment that __ARM_NR_cmpxchg was removed in 4.4 2018-09-24 20:35:18 +02:00
Eugene Syromyatnikov
c3e1c57045 linux/arm/syscallents: replace empty definitions with comments
* linux/arm/syscallent.h ([222]): Remove definition, add a comment that
it was tux().
([223]): Remove definition, add comment that it was unused.
([254]): Remove definition, add comment that it was reserverd
for set_thread_area.
([255]): Remove definition, add comment that it was reserved
for get_thread_area.
2018-09-24 20:32:45 +02:00
Eugene Syromyatnikov
a4c8986bd7 net: use already existing array item printing function
* net.c (print_uint32): Remove.
(print_getsockopt): Use print_uint32_array_member instead of
print_uint32.
2018-09-24 20:30:27 +02:00
Eugene Syromyatnikov
c7436d45a8 fixup! socketutils: add fallback inode protocol cache 2018-09-24 20:29:43 +02:00
Eugene Syromyatnikov
f2f91dbe8b socketutils: dynamically request unknown genl families after init
This commits adds ability to request for unknown generic netlink
families after the initial xlat initialisation. It also changes
socketutils-level interface so it returns string and not xlat.

* defs.h (genl_families_xlat): Remove.
(genl_get_family_name): New declaration.
* netlink.c (decode_nlmsg_type_generic): Use genl_get_family_name
instead of genl_families_xlat.
* socketutils.c (genl_query_families): Rename from
genl_send_dump_families, add "id" parameter, perform dump if id == -1,
request specific ID otherwise.
(genl_get_family_name): Rename from genl_families_xlat, add "id"
parameter, return const char *; request specific genetlink family name
if it is not found in the already initialised xlat.
2018-09-24 20:16:32 +02:00
Eugene Syromyatnikov
49443a8c8c Remove HAVE_LINUX_GENETLINK_H ifdefs
<linux/netlink.h> is available since Linux 2.6.15 (commit
v2.6.15-rc1~53^2).

* configure.ac (AC_CHECK_HEADERS): Remove linux/genetlink.h.
* socketutils.c [!HAVE_LINUX_GENETLINK_H]: Remove
* tests/netlink_generic.c [!HAVE_LINUX_GENETLINK_H]: Likewise.
2018-09-24 19:56:08 +02:00
Eugene Syromyatnikov
7f3519e4d8 fixup! xlat: add generation of flags-related fields 2018-09-24 08:08:16 +02:00
Eugene Syromyatnikov
caac21a22b xlat: sort futexops
* xlat/futexops.in: Reorder, add #sorted.
2018-09-24 08:07:15 +02:00
Eugene Syromyatnikov
1d5a776f63 xlat: add fallback values for ioctl_dirs
* xlat/ioctl_dirs.in: Add fallback values.
2018-09-24 08:06:42 +02:00
Eugene Syromyatnikov
771a786157 inotify: decode file descriptor returned by inotify_init
* inotify.c (SYS_FUNC(inotify_init)): New function.
* linux/dummy.h (sys_inotify_init): Remove macro definition.
* tests/.gitignore: Add inotify_init, inotify_init-y, inotify_init1-y.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (inotify_init, inotify_init-y, inotify_init1-y):
New tests.
* tests/inotify_init-y.c: New file.
* tests/inotify_init.c: Likewise.
* tests/inotify_init1-y.c: Likewise.
* tests/inotify_init1.c [PRINT_PATHS]: Print inotify fd path.
2018-09-24 08:02:38 +02:00
Eugene Syromyatnikov
6d4b688d38 futex: print futex(FUTEX_FD) return value as FD
Since it used to be it.

* futex.c (SYS_FUNC(futex)) <case FUTEX_FD>: Return
RVAL_DECODED|RVAL_FD.
2018-09-24 07:35:18 +02:00
Eugene Syromyatnikov
342801a9dc futex: print uaddr value
As it might be of interest. Since uaddr itself is as important as the
containing value, it's alwais printed as comment.

* xlat/futexpiflags.in: New file.
* futex.c [!FUTEX_TID_MASK] (FUTEX_TID_MASK): New macro constant.
Include "xlat/futexpiflags.h".
(printaddrnum, printaddrpival): New functions.
(SYS_FUNC(futex)): Use printaddrpival/printaddrnum for printing uaddr
and uaddr2 values where appropriate.
* tests/futex.c: Update expected output.
2018-09-24 07:32:11 +02:00
Eugene Syromyatnikov
56c64c0f85 netlink: always print genetlink family ID
As those are allocated dynamically.

* netlink.c (decode_nlmsg_type_generic): Use XLAT_STYLE_VERBOSE.
* tests/netlink_generic.c: Update expected output.
2018-09-24 05:06:41 +02:00
Eugene Syromyatnikov
452bb1c4b9 fixup! ioctl: decode ioctl type 2018-09-24 03:58:51 +02:00
Eugene Syromyatnikov
c8dc2208eb ioctl: print private SIOC* ioctl commands
* ioctl.c [!SIOCPROTOPRIVATE] (SIOCPROTOPRIVATE): New macro constant.
[!SIOCDEVPRIVATE] (SIOCDEVPRIVATE): Likewise.
[!SIOCIWFIRSTPRIV] (SIOCIWFIRSTPRIV): Likewise.
[!SIOCIWLASTPRIV] (SIOCIWLASTPRIV): Likewise.
(ioctl_decode_command_number) <SOCK_IOC_TYPE>: Handle protocol-private
and device-private ioctl command numbers.
<0x8B>: Handle device-private ioctl comamnd numbers.
* tests/ioctl.c: Add checks.
2018-09-24 03:55:01 +02:00
Eugene Syromyatnikov
d7beb8d758 fixup! ioctl: decode ioctl type 2018-09-24 03:54:15 +02:00
Eugene Syromyatnikov
b4e5977fee revert ioctl xlat 2018-09-24 03:38:52 +02:00
Eugene Syromyatnikov
72ecb7691a xlat: update kvm_cap
* xlat/kvm_cap.in (KVM_CAP_NESTED_STATE): New constant, introduced
by Linux commit v4.19-rc1~87^2~62.
(KVM_CAP_ARM_INJECT_SERROR_ESR): New constant, introduced by Linux
commit v4.19-rc1~55^2~12^2~14, merged with its final value
in v4.19-rc1~55^2~12.
(KVM_CAP_MSR_PLATFORM_INFO): New constant, introduced by Linux commit
v4.19-rc5~8^2~2.
2018-09-24 00:43:52 +02:00
Eugene Syromyatnikov
fc2d593d3d ioctl: decode ioctl type
* xlat/ioc_types.in: New file
* ioctl.c: Include "xlat/ioc_types.h"
(ioctl_type_str): New function.
(ioctl_print_code): Use ioctl_type_str for decoding _IOC_TYPE(code).
2018-09-24 00:26:01 +02:00
Eugene Syromyatnikov
8783cd8119 ioctl: print ioctl code in accordance with xlat verbosity
* ioctl.c (ioctl_print_code): Format in accrordance with xlat verbosity
setting.
2018-09-24 00:06:08 +02:00
Eugene Syromyatnikov
aeb343b726 Implement sysfs syscall decoding
* Makefile.am (strace_SOURCES): New file.
* linux/dummy.h (sys_sysfs): Remove macro definition.
* sysfs.c: New file.
* tests/gen_tests.in: Add sysfs test definition.
* tests/.gitignore: add sysfs.
* tests/pure_executables.list: Add sysfs.
* tests/sysfs.c: New file.
2018-09-23 12:35:53 +02:00
Eugene Syromyatnikov
8a7ba35d04 msghdr: decode IP_RECVFRAGSIZE control message
Added in v4.10-rc1~202^2~340^2~2.

* xlat/ip_cmsg_types.in (SCM_SECURITY): Provide fallback message,
reorder.
(IP_RECVFRAGSIZE): New constant.
* msghdr.c (print_cmsg_int): New function.
(cmsg_ip_printers) <IP_RECVFRAGSIZE>: New printer.
2018-09-19 23:00:30 +02:00
Eugene Syromyatnikov
156777f967 Fix old_getrlimit handling
On some historic 32-bit platforms (and 64-bit SuperH), __NR_getrlimit
corresponds to a non-SuS-compatible version that uses a hardcoded value
of 0x7fffffff as infinity. Moreover, in order to provide a backwards
compatibility with that behaviour, some architectures (mips, sparc, and
alpha, with latter being especially peculiar in its ways) just defined
RLIM_INFINITY to that value (with alpha defining RLIM_INFINITY to 2^63-1)
instead of employing sys_old_getrlimit syscall and providing
__NR_ugetrlimit with proper implementation, as other arches did.

Overall, that led to conclusion that printing "RLIM_INFINITY" is never
enough and the actial value should be printed as well.

* linux/i386/syscallent.h ([76]): Changing decoder to old_getrlimit.
* linux/m68k/syscallent.h ([76]): Likewise.
* linux/microblaze/syscallent.h ([76]): Likewise.
* linux/powerpc/syscallent.h ([76]): Likewise.
* linux/s390/syscallent.h ([76]): Likewise.
* linux/sh/syscallent.h ([76]): Likewise.
* linux/sh64/syscallent.h ([76]): Likewise.
* resource.c (sprint_rlim64, sprint_rlim32, print_rlimit64,
print_rlimit32): Remove.
(STRACE_RLIM_INFINITY, STRACE_M32_RLIM_INFINITY,
STRACE_RLIM64_INFINITY, OLD_GETLIMIT_INFINITY): New macro constants.
(enum rlimit_decode_mode): New enumeration.
(struct rlimit_64): Move type definition out of print_rlimit64.
(print_rlim_t): New function, printer of an rlimit value, in accordance
with rlimit decode mode and xlat verbosity mode.
(print_rlimit): Printer of a fetched rlimit_64 structure.
(decode_rlimit): Fetches struct rlimit/rlimit64 in accordance with
current mode and personality, uses print_rlimit for printing.
(do_getrlimit): New function, decodes old_getrlimit/getrlimit syscalls.
(SYS_FUNC(getrlimit)): Call do_getrlimit with RDM_NORMAL mode.
(SYS_FUNC(old_getrlimit)): New function, calls do_getrlimit with
RDM_OLD_GETRLIMIT mode.
(SYS_FUNC(setrlimit)): Call decode_rlimit with RDM_NORMAL mode.
(SYS_FUNC(prlimit64)): Call decode_rlimit with RDM_PRLIMIT64 mode
instead of print_rlimit64.
* tests/xgetrlimit.c (sprint_rlim): Rename to...
(print_rlim): ...this, print to terminal instead of string buffer in
accordance with the output format expected.
(main): Accomodate sprint_rlim -> print_rlim change, use sprintrc.
* tests/getrlimit.c (INFINITY, INFINITY_STR): New macros.
* tests/setrlimit.c: Likewise.
* tests/ugetrlimit.c: Likewise.
2018-09-17 20:12:02 +02:00
Eugene Syromyatnikov
719d1f8986 linux/ia64: use shuffle_scno, since syscallent table starts from 1024
* linux/ia64/shuffle_scno.c: New file
* Makefile.am (EXTRA_DIST): Add it.
* linux/ia64/arch_regs.h (IA64_SCNO_BASE): New macro.
* linux/ia64/syscallent.h: Decrease all indices by IA64_SCNO_BASE.
2018-09-17 02:59:15 +02:00
Eugene Syromyatnikov
2d89ff7096 xlat: add generation of flags-related fields
Generate known flags mask and maximum string length.

* xlat.h (struct xlat): Add fields flags_strsz and flags_mask.
* xlat/gen.sh (print_xlat, print_xlat_pair): Add generation of
XLAT_VAL_n and XLAT_STR_n macros.
(gen_header): Generate flags_strsz and flags_mask fields' values using
the generated XLAT_VAL_n and XLAT_STR_n macros, undefine them
afterwards.
2018-09-17 02:49:00 +02:00
Eugene Syromyatnikov
06bb2018c7 uname: decode olduname and oldolduname syscalls
* linux/dummy.h (sys_oldolduname, sys_olduname): Remove.
* tests/.gitignore: Add oldolduname, oldolduname-v, olduname,
olduname-v.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (oldolduname, oldolduname-v, olduname,
olduname-v): New tests.
* tests/oldolduname-v.c: New file.
* tests/oldolduname.c: Likewise.
* tests/olduname-v.c: Likewise.
* tests/olduname.c: Likewise.
* uname.c: Include <linux/uname.h> instead of <sys/uname.h>.
(DECODE_UTSNAME_COMMON): New macro.
(SYS_FUNC(oldolduname), SYS_FUNC(olduname)): New decoders.
(SYS_FUNC(uname)): Rewrite using DECODE_UTSNAME_COMMON.
2018-09-11 20:00:20 +02:00
Eugene Syromyatnikov
1abb9c7b21 get_rboust_list: update get_robust_list and set_robust_list decoders
Decode struct robust_list_head.

* linux/dummy.h (sys_set_robust_list): Remove.
* get_robust_list.c (DEF_MPERS_TYPE(struct_robust_list_head)): Add mpers
type definition.
Include <linux/futex.h>.
(struct_robust_list_head): New type definition.
Include MPERS_DEFS, "print_fields.h".
(decode_robust_list): New function.
(SYS_FUNC(set_robust_list)): New decoder.
(SYS_FUNC(get_robust_list)): Decode second argument.
* tests/xet_robust_list.c: Include <string.h>, <linux/futex.h>.
(sprintaddr): Remove.
(print_rlh): New function.
(main): Add get_robust_list/set_robust_list checks.
2018-09-11 19:45:10 +02:00
Eugene Syromyatnikov
9f7da75206 Print signal name strace killed with
As of now, there's no visible indication that strace itself
has been signalled: it exits with exit code 0 and without any messages.
Let's add a message, at least.

* gcc_compat.h (CMPXCHG): New macro
* strace.c (interrupt): set interrupted signal only once.
(print_signalled): Add support for calling with tcp == NULL.
(terminate): Call print_signalled is qflag is not set and strace
has been interrupted.
2018-09-11 16:52:52 +02:00
Eugene Syromyatnikov
895a68db41 socketutils: add fallback inode protocol cache
For the cases when we hit a race between sock_diag request for a socket
and its addition to the socket list. It collects information about
sockets that created via socket(2) syscall and is used when not protocol
information data is available via normal means.

* defs.h (set_netlink_family_cache_entry,
get_netlink_family_cache_entry, invalidate_netlink_family_cache_entry):
New delcarations.
* desc.c (SYS_FUNC(call)): Call invalidate_netlink_family_cache_entry
for inode being closed.
* net.c (SYS_FUNC(socket)): Call set_netlink_family_cache_entry for
AF_NETLINK sockets, do not return RVAL_DECODED on entering for them.
* socketutils.c: New enumeration for cache-related constants.
(NLF_CACHE_KEY_MASK): Cache key mask constant.
(netlink_cache): Fallback cache for netlink protocol numbers.
(set_netlink_family_cache_entry, get_netlink_family_cache_entry,
invalidate_netlink_family_cache_entry): New functions.
(netlink_get): Request protocol via get_netlink_family_cache_entry if
not information has been obtained.
2018-09-11 07:51:46 +02:00
Eugene Syromyatnikov
399a2d8849 userfaultfd: enhance UFFDIO_API ioctl decoder
It may return API and features even with errno set to EINVAL.

* userfaultfd.c (print_uffdio_api_start): New function.
(uffdio_ioctl): Decode api and features fields on exiting if errno
is EINVAL.
2018-09-11 06:05:08 +02:00
Eugene Syromyatnikov
22ec7c5edb ioctl: sort entries in ioctl_decode switch statement
* ioctl.c (ioctl_decode): Sort case branches in the switch statement.
2018-09-11 02:01:21 +02:00
Eugene Syromyatnikov
1ef81b4b74 fixup! Avoid mixing error messages and trace output 2018-09-11 01:46:49 +02:00
Eugene Syromyatnikov
b7d8794dbf xlat: add FAN_ENABLE_AUDIT to fan_init_flags xlat
* xlat/fan_init_flags.in (FAN_ENABLE_AUDIT): New constant, introduced by
Linux commit v4.15-rc1~130^2^2~11.
* tests/fanotify_init.c: Update expected output.
2018-09-11 01:45:30 +02:00
Eugene Syromyatnikov
4544b3f554 Avoid mixing error messages and trace output
Handle error_msg output similarly to the output from another tcb.

* Makefile.am (strace_CPPFLAGS): Add -DHAVE_DEFS_H.
* error_prints.c [HAVE_DEFS_H]: Include "defs.h" instead of "config.h".
(verror_msg): Call finish_line before fflush().
* error_prints.h (finish_line): New declaration.
* strace.c (finish_line): New function.
2018-09-11 01:32:52 +02:00
Eugene Syromyatnikov
2df7898efb Makefile.am: provide MPERS_WORDSIZE and MPERS_KLONGSIZE definitions
* Makefile.am (strace_CFLAGS, $(mpers_m32_targets): mpers_CC_FLAGS,
$(mpers_mx32_targets): mpers_CC_FLAGS): Add -DMPERS_WORDSIZE and
-DMPERS_KLONGSIZE.
2018-09-10 21:38:06 +02:00
Eugene Syromyatnikov
00c56292a1 Makefile.am: quote mpers_CC_FLAGS in mpers.sh call
Otherwise additional flags are recognised as file names.

* Makefile.am (mpers-m%.stamp): Quote mpers.sh arguments.
2018-09-10 21:37:42 +02:00
Eugene Syromyatnikov
25f71c5488 ioctl: fix indentation in switch clauses
* ioctl.c: Fix indentation in switch clauses, no code changes.
2018-09-06 20:00:00 +02:00