]> granicus.if.org Git - strace/log
strace
8 years agoblock.c: remove BLKDAXGET support
Dmitry V. Levin [Tue, 12 Jul 2016 16:19:54 +0000 (16:19 +0000)]
block.c: remove BLKDAXGET support

BLKDAXGET was removed by linux kernel commit v4.7-rc1~78^2^2~4.

* block.c: Do not define BLKDAXGET.
(block_ioctl): Remove BLKDAXGET support.
* tests/ioctl_block.c (main): Remove BLKDAXGET test.

8 years agoFix printing of socklen argument of bind and sendto syscalls
Dmitry V. Levin [Tue, 12 Jul 2016 09:17:30 +0000 (09:17 +0000)]
Fix printing of socklen argument of bind and sendto syscalls

* net.c (SYS_FUNC(bind)): Print 3rd syscall argument using %d format.
(SYS_FUNC(sendto)): Print 6th syscall argument using %d format.

8 years agotests: check decoding of sockaddr related arguments of recvfrom syscall
Dmitry V. Levin [Tue, 12 Jul 2016 08:41:58 +0000 (08:41 +0000)]
tests: check decoding of sockaddr related arguments of recvfrom syscall

* configure.ac (AC_CHECK_FUNCS): Add recvfrom.
* tests/recvfrom.c: New file.
* tests/recvfrom.test: New test.
* tests/.gitignore: Add recvfrom.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add recvfrom.test.

8 years agoFix decoding of sockaddr related arguments of recvfrom syscall
Dmitry V. Levin [Tue, 12 Jul 2016 07:46:19 +0000 (07:46 +0000)]
Fix decoding of sockaddr related arguments of recvfrom syscall

* net.c (SYS_FUNC(recvfrom)): Use fetch_socklen.  Save the address
length passed to the kernel and print it on error.  Do not print more
bytes of the socket address than actually returned by the kernel.
Print both user and kernel address lengths when the returned address
is truncated.

8 years agotests: check decoding of accept4 syscall
Dmitry V. Levin [Mon, 11 Jul 2016 17:21:22 +0000 (17:21 +0000)]
tests: check decoding of accept4 syscall

* configure.ac (AC_CHECK_FUNCS): Add accept4.
* tests/accept4.c: New file.
* tests/accept4.test: New test.
* tests/.gitignore: Add accept4.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add accept4.test.

8 years agotests: check decoding of accept syscall
Dmitry V. Levin [Mon, 11 Jul 2016 17:21:10 +0000 (17:21 +0000)]
tests: check decoding of accept syscall

* tests/accept.c: New file.
* tests/accept.test: New test.
* tests/.gitignore: Add accept.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add accept.test.

8 years agotests: check decoding of getpeername syscall
Dmitry V. Levin [Sun, 10 Jul 2016 22:39:51 +0000 (22:39 +0000)]
tests: check decoding of getpeername syscall

* tests/getpeername.c: New file.
* tests/getpeername.test: New test.
* tests/.gitignore: Add getpeername.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add getpeername.test.

8 years agotests: check decoding of getsockname syscall
Dmitry V. Levin [Sun, 10 Jul 2016 22:39:51 +0000 (22:39 +0000)]
tests: check decoding of getsockname syscall

* tests/getsockname.c: New file.
* tests/getsockname.test: New test.
* tests/sockname.c: New file.
* tests/.gitignore: Add getsockname.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add getsockname.test.
(EXTRA_DIST): Add sockname.c.

8 years agoPrint both values of changing address length in sockname family syscalls
Dmitry V. Levin [Sat, 9 Jul 2016 21:52:58 +0000 (21:52 +0000)]
Print both values of changing address length in sockname family syscalls

* net.c (decode_sockname): Print both user and kernel address lengths
when the value changes.
* tests/net-y-unix.c (main): Update expected output.
* tests/net-yy-unix.c (main): Likewise.
* tests/net.expected: Likewise.

8 years agoEnhance diagnostics of address truncation in sockname family syscalls
Dmitry V. Levin [Sat, 9 Jul 2016 21:52:51 +0000 (21:52 +0000)]
Enhance diagnostics of address truncation in sockname family syscalls

* net.c (decode_sockname): Print both user and kernel address lengths
when the returned address is truncated.
* tests/sun_path.expected: Update expected output.

8 years agoFix decoding of getsockname, getpeername, accept, and accept4 syscalls
Dmitry V. Levin [Sat, 9 Jul 2016 21:52:43 +0000 (21:52 +0000)]
Fix decoding of getsockname, getpeername, accept, and accept4 syscalls

* net.c (fetch_socklen): New function.
(decode_sockname): Use it.  On entering syscall, decode early
and return RVAL_DECODED when possible.  On error, print the address
length passed to the kernel.  Do not print more bytes of the socket
address than actually returned by the kernel.

8 years agoPrepare parsers of sockname family syscalls for the upcoming fix
Dmitry V. Levin [Sat, 9 Jul 2016 21:52:34 +0000 (21:52 +0000)]
Prepare parsers of sockname family syscalls for the upcoming fix

* net.c (do_sockname): Rename to decode_sockname, drop second argument,
do not print sock_type_flags, return RVAL_DECODED on exiting.
(SYS_FUNC(accept), SYS_FUNC(getsockname)): Use decode_sockname instead
of do_sockname, take its return code into account.
(SYS_FUNC(accept4)): Likewise.  Print sock_type_flags when
decode_sockname returns RVAL_DECODED.

8 years agonetlink: handle multipart netlink messages
Dmitry V. Levin [Fri, 8 Jul 2016 16:01:49 +0000 (16:01 +0000)]
netlink: handle multipart netlink messages

Handle multipart netlink messages made of multiple struct nlmsghdr
headers with associated payload in one byte stream.

* netlink.c (fetch_nlmsghdr, print_nlmsghdr,
decode_nlmsghdr_with_payload): New functions.
(decode_netlink): Use them.
* tests/netlink_parsing.c (send_query): Check them.

8 years agotests: extend netlink protocol check
Dmitry V. Levin [Thu, 7 Jul 2016 09:49:26 +0000 (09:49 +0000)]
tests: extend netlink protocol check

* tests/netlink_protocol.c (send_query): Check that no part
of netlink message is fetched beyond the end of message.
Check decoding of zero address and zero length messages.
Check decoding of messages with nlmsg_len exceeding message length.

8 years agotests: check decoding of netlink protocol
Fabien Siron [Wed, 6 Jul 2016 15:49:23 +0000 (15:49 +0000)]
tests: check decoding of netlink protocol

* tests/netlink_protocol.test: New test.
* tests/netlink_protocol.c: New file.
* tests/.gitignore: Add netlink_protocol.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add netlink_protocol.test.

8 years agoAdd a general netlink socket parser
Fabien Siron [Wed, 6 Jul 2016 15:49:22 +0000 (15:49 +0000)]
Add a general netlink socket parser

Introduce a general socket netlink parser which prints the header and
a string for the remaining part of the buffer.  It doesn't handle all
the netlink flags and types yet because the parser needs more
information, this will be implemented later.

* net.c (decode_sockbuf): New function.
(SYS_FUNC(send), SYS_FUNC(sendto), SYS_FUNC(recv), SYS_FUNC(recvfrom)):
Use it instead of printstr.
* msghdr.c (print_msghdr): Pass IOV_DECODE_NETLINK to tprint_iov_upto()
for netlink sockets.
* netlink.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (decode_netlink, getfdproto): New prototypes.
(iov_decode): Add IOV_DECODER_NETLINK.
* io.c (print_iovec): Use decode_netlink().
* util.c (getfdproto): Remove static keyword.
* xlat/netlink_flags.in: New file.
* xlat/netlink_types.in: New file.

8 years agoUpdate sigaltstack SS_* constants
Dmitry V. Levin [Wed, 6 Jul 2016 22:32:22 +0000 (22:32 +0000)]
Update sigaltstack SS_* constants

* xlat/sigaltstack_flags.in: Add SS_AUTODISARM introduced
by linux kernel commit v4.7-rc1~195^2.

8 years agoUpdate fs *_MAGIC constants
Dmitry V. Levin [Wed, 6 Jul 2016 22:23:49 +0000 (22:23 +0000)]
Update fs *_MAGIC constants

* xlat/fsmagic.in: Add NSFS_MAGIC, TRACEFS_MAGIC, BPF_FS_MAGIC,
and UDF_SUPER_MAGIC introduced by linux kernel commits
v3.19-rc1~53^2~7^2~1, v4.1-rc1~147^2~4, v4.4-rc1~141^2~17^2~1,
and v4.7-rc1~161^2, respectively.

8 years agoUpdate KEYCTL_* constants
Dmitry V. Levin [Tue, 5 Jul 2016 22:39:09 +0000 (22:39 +0000)]
Update KEYCTL_* constants

* xlat/keyctl_commands.in: Add KEYCTL_DH_COMPUTE introduced
by linux kernel commit v4.7-rc1~124^2~2^2~2^2.

8 years agoUpdate input event constants
Dmitry V. Levin [Tue, 5 Jul 2016 21:59:36 +0000 (21:59 +0000)]
Update input event constants

* xlat/evdev_keycode.in: Add KEY_* constants introduced
by linux kernel commit v4.7-rc6~32^2~6^2.

8 years agoUpdate RWF_* constants
Dmitry V. Levin [Mon, 4 Jul 2016 22:37:38 +0000 (22:37 +0000)]
Update RWF_* constants

* xlat/rwf_flags.in: Add RWF_DSYNC and RWF_SYNC introduced
by linux kernel commit v4.7-rc1~158^2~1.

8 years agoUpdate BPF_MAP_TYPE_* constants
Dmitry V. Levin [Mon, 4 Jul 2016 22:31:19 +0000 (22:31 +0000)]
Update BPF_MAP_TYPE_* constants

* xlat/bpf_prog_types.in: Add BPF_PROG_TYPE_TRACEPOINT introduced
by linux kernel commit v4.7-rc1~154^2~332^2~6.

8 years agomsghdr.c: limit output when printing excessively large messages
Dmitry V. Levin [Sun, 3 Jul 2016 22:15:45 +0000 (22:15 +0000)]
msghdr.c: limit output when printing excessively large messages

Limit output of struct msghdr.msg_control when
struct msghdr.msg_controllen is greater than the maximum ancillary
buffer size specified in /proc/sys/net/core/optmem_max file.

* configure.ac (AC_CHECK_FUNCS): Add open64.
* defs.h (read_int_from_file): New prototype.
* util.c (read_int_from_file): New function.
* msghdr.c (get_optmem_max): New function based on read_int_from_file.
(decode_msg_control): Use it to check control_len argument.
* tests/msg_control.c (test_big_len): New function.
(main): Use it to test printing of excessively large messages.

8 years agotests: add read_int_from_file function to libtests
Dmitry V. Levin [Sun, 3 Jul 2016 22:15:38 +0000 (22:15 +0000)]
tests: add read_int_from_file function to libtests

* tests/overflowuid.c (read_int_from_file): New function.
(check_overflow_id): Use it.
* tests/tests.h (read_int_from_file): New prototype.

8 years agomsghdr.c: limit IP_RECVOPTS/IP_RETOPTS output in abbrev mode
Dmitry V. Levin [Sat, 2 Jul 2016 21:14:48 +0000 (21:14 +0000)]
msghdr.c: limit IP_RECVOPTS/IP_RETOPTS output in abbrev mode

* msghdr.c (print_cmsg_ip_opts): Do not print more than max_strlen
bytes of ip options in abbrev mode.
* tests/msg_control.c (print_ip_opts): Use DEFAULT_STRLEN.
(test_sol_ip): Test IP_RETOPTS output in abbrev mode.

8 years agomsghdr.c: limit SCM_RIGHTS output in abbrev mode
Dmitry V. Levin [Sat, 2 Jul 2016 21:14:26 +0000 (21:14 +0000)]
msghdr.c: limit SCM_RIGHTS output in abbrev mode

* msghdr.c (print_scm_rights): Do not print more than max_strlen
descriptors in abbrev mode.
* tests/msg_control.c (DEFAULT_STRLEN): New macro.
(print_fds): Use it.
(test_scm_rights3): New function.
(main): Use it to test SCM_RIGHTS output in abbrev mode.
* tests/msg_control-v.c: New file.
* tests/msg_control-v.test: New test.
* tests/.gitignore: Add msg_control-v.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add msg_control-v.test.

8 years agotests: check decoding of struct msghdr ancillary data
Dmitry V. Levin [Fri, 1 Jul 2016 20:13:37 +0000 (20:13 +0000)]
tests: check decoding of struct msghdr ancillary data

* tests/msg_control.c: New file.
* tests/msg_control.test: New test.
* tests/.gitignore: Add msg_control.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add msg_control.test.

8 years agomsghdr.c: reorganize struct cmsghdr handler
Dmitry V. Levin [Thu, 30 Jun 2016 22:49:36 +0000 (22:49 +0000)]
msghdr.c: reorganize struct cmsghdr handler

* msghdr.c (sock_ee): New structure.
(print_scm_rights, print_scm_creds, print_scm_security,
print_cmsg_ip_pktinfo, print_cmsg_uint, print_cmsg_ip_opts,
print_cmsg_ip_recverr, print_cmsg_ip_origdstaddr): Remove data_len
argument validity check, don't print ", cmsg_data=" prefix here.
(print_cmsg_ip_tos): Likewise.  Rename to print_cmsg_uint8_t.
(cmsg_printer): New type.
(cmsg_socket_printers, cmsg_ip_printers): New arrays.
(print_cmsg_type_data): Use them to handle struct cmsghdr
and its cmsg_data.

8 years agomsghdr.c: merge print_cmsg_ip_ttl and print_cmsg_ip_checksum
Dmitry V. Levin [Thu, 30 Jun 2016 22:39:02 +0000 (22:39 +0000)]
msghdr.c: merge print_cmsg_ip_ttl and print_cmsg_ip_checksum

* msghdr.c (print_cmsg_ip_ttl): Rename to print_cmsg_uint.
(print_cmsg_ip_checksum): Remove.
(print_cmsg_type_data): Replace print_cmsg_ip_ttl
and print_cmsg_ip_checksum with print_cmsg_uint.

8 years agomsghdr.c: enhance representation of unprintable part of msg_control array
Dmitry V. Levin [Thu, 30 Jun 2016 22:34:27 +0000 (22:34 +0000)]
msghdr.c: enhance representation of unprintable part of msg_control array

* msghdr.c (decode_msg_control): When msg_control array has an
unprintable part, print its address.

8 years agomsghdr.c: apply a sane limit to the length of IP_ORIGDSTADDR address
Dmitry V. Levin [Thu, 30 Jun 2016 22:26:35 +0000 (22:26 +0000)]
msghdr.c: apply a sane limit to the length of IP_ORIGDSTADDR address

* msghdr.c (print_cmsg_ip_origdstaddr): Limit address length to the size
of struct sockaddr_storage.

8 years agomsghdr.c: fix printing SCM_RIGHTS array
Dmitry V. Levin [Thu, 30 Jun 2016 22:20:56 +0000 (22:20 +0000)]
msghdr.c: fix printing SCM_RIGHTS array

* msghdr.c (print_scm_rights): Do not print array elements outside
bounds defined by struct cmsghdr.cmsg_len.

8 years agomsghdr.c: print unrecognized struct cmsghdr.cmsg_type in hex
Dmitry V. Levin [Thu, 30 Jun 2016 22:14:51 +0000 (22:14 +0000)]
msghdr.c: print unrecognized struct cmsghdr.cmsg_type in hex

* msghdr.c (print_cmsg_type_data): Use %#x format when printing
struct cmsghdr.cmsg_type as an integer.

8 years agomsghdr.c: fix printing of struct in_pktinfo
Dmitry V. Levin [Wed, 29 Jun 2016 22:07:20 +0000 (22:07 +0000)]
msghdr.c: fix printing of struct in_pktinfo

* msghdr.c (print_cmsg_ip_pktinfo): Fix printing
of struct in_pktinfo.ipi_addr.

8 years agomsghdr.c: fix representation of struct cmsghdr.cmsg_data integer arrays
Dmitry V. Levin [Tue, 28 Jun 2016 22:25:10 +0000 (22:25 +0000)]
msghdr.c: fix representation of struct cmsghdr.cmsg_data integer arrays

* msghdr.c (print_cmsg_ip_opts): Print struct cmsghdr.cmsg_data
as an array of hexadecimal integers.
* tests/inet-cmsg.c (print_opts): Update expected output.

8 years agomsghdr.c: fix representation of integer struct cmsghdr.cmsg_data values
Dmitry V. Levin [Tue, 28 Jun 2016 22:25:10 +0000 (22:25 +0000)]
msghdr.c: fix representation of integer struct cmsghdr.cmsg_data values

* msghdr.c (print_cmsg_ip_ttl, print_cmsg_ip_tos,
print_cmsg_ip_checksum): Print struct cmsghdr.cmsg_data value as an
array element.
* tests/inet-cmsg.c (print_ttl, print_tos): Update expected output.

8 years agomsghdr.c: when printing struct struct cmsghdr.cmsg_data, also print its name
Dmitry V. Levin [Tue, 28 Jun 2016 22:25:10 +0000 (22:25 +0000)]
msghdr.c: when printing struct struct cmsghdr.cmsg_data, also print its name

* msghdr.c (print_scm_rights, print_scm_creds, print_scm_security,
print_cmsg_ip_pktinfo, print_cmsg_ip_ttl, print_cmsg_ip_tos,
print_cmsg_ip_checksum, print_cmsg_ip_opts, print_cmsg_ip_recverr,
print_cmsg_ip_origdstaddr): Print "cmsg_data=" before its contents.
* tests/inet-cmsg.c (print_pktinfo, print_ttl, print_tos, print_opts,
print_origdstaddr): Update expected output.
* tests/scm_rights-fd.test: Likewise.

8 years agomsghdr.c: print struct mmsghdr as a regular structure
Dmitry V. Levin [Mon, 27 Jun 2016 00:14:34 +0000 (00:14 +0000)]
msghdr.c: print struct mmsghdr as a regular structure

* msghdr.c (decode_mmsghdr): Print names of msg_hdr and msg_len fields.
* tests/mmsg.c (main): Update expected output.

8 years agonet.c: move all msghdr and mmsghdr parsers to a separate file
Dmitry V. Levin [Mon, 27 Jun 2016 00:02:55 +0000 (00:02 +0000)]
net.c: move all msghdr and mmsghdr parsers to a separate file

* defs.h (msg_flags, socketlayers, decode_msghdr, decode_mmsg):
New prototypes.
* msghdr.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* net.c: Move all msghdr and mmsghdr parsers to msghdr.c.

8 years agoMpersify fetchers of struct msghdr and struct mmsghdr
Dmitry V. Levin [Mon, 27 Jun 2016 00:02:50 +0000 (00:02 +0000)]
Mpersify fetchers of struct msghdr and struct mmsghdr

* fetch_struct_msghdr.c: New file.
* fetch_struct_mmsghdr.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* net.c (struct msghdr32, struct mmsghdr32, copy_from_msghdr32,
fetch_msghdr, fetch_mmsghdr): Remove.
(decode_msghdr, dumpiov_in_msghdr): Use fetch_struct_msghdr instead
of fetch_msghdr.
(decode_mmsghdr): Change msg_len argument to use_msg_len.
Use fetch_struct_mmsghdr instead of fetch_mmsghdr.
Return fetch_struct_mmsghdr's return code.
(decode_mmsg): Rename to decode_mmsgvec.  Take addr and len arguments.
Do not print vlen and flags.  Check decode_mmsghdr's return code.
Print mmsghdr array using square brackets.
(dumpiov_in_mmsghdr): Use fetch_struct_mmsghdr instead of fetch_mmsghdr.
(SYS_FUNC(sendmmsg), SYS_FUNC(recvmmsg)): Use decode_mmsgvec instead
of decode_mmsg.  Print vlen and flags.
* tests/mmsg.c (main): Update expected output.

8 years agonet.c: move fallback definition of struct mmsghdr to a separate file.
Dmitry V. Levin [Mon, 27 Jun 2016 00:02:41 +0000 (00:02 +0000)]
net.c: move fallback definition of struct mmsghdr to a separate file.

* msghdr.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* net.c: Include it.  Move fallback definition of struct mmsghdr there.
* tests/mmsg.c: Include "msghdr.h".  Remove fallback definition
of struct mmsghdr.

8 years agonet.c: print struct msghdr as a regular structure
Dmitry V. Levin [Sun, 26 Jun 2016 23:57:39 +0000 (23:57 +0000)]
net.c: print struct msghdr as a regular structure

* net.c (print_msghdr): Print msg_name, msg_namelen, msg_iov,
and msg_iovlen fields like other regular fields.
* tests/inet-cmsg.c (main): Update expected output.
* tests/mmsg.c (main): Likewise.
* tests/recvmsg.c (main): Likewise.
* tests/scm_rights-fd.test: Likewise.

8 years agonet.c: rename some internal functions for consistency and readability
Dmitry V. Levin [Sun, 26 Jun 2016 23:57:29 +0000 (23:57 +0000)]
net.c: rename some internal functions for consistency and readability

* net.c (printcmsghdr): Rename to decode_msg_control.
(do_msghdr): Rename to print_msghdr.
(extractmsghdr): Rename to fetch_msghdr.
(extractmmsghdr): Rename to fetch_mmsghdr.
(printmsghdr): Rename to decode_msghdr.
(printmmsghdr): Rename to decode_mmsghdr.
All callers updated.

8 years agonet.c: when printing struct msghdr.msg_control, also print its name
Dmitry V. Levin [Sun, 26 Jun 2016 23:57:18 +0000 (23:57 +0000)]
net.c: when printing struct msghdr.msg_control, also print its name

* net.c (printcmsghdr): Skip control messages of zero length.
Always print "msg_control=" before the control message.
(do_msghdr): Print control message before its length, not after.
* tests/inet-cmsg.c (main): Update expected output.
* tests/scm_rights-fd.test: Likewise.

8 years agoAssume that libc provides struct msghdr.msg_control
Dmitry V. Levin [Sun, 26 Jun 2016 23:56:59 +0000 (23:56 +0000)]
Assume that libc provides struct msghdr.msg_control

* configure.ac (AC_CHECK_MEMBERS): Remove struct msghdr.msg_control.
* net.c (do_msghdr): Remove HAVE_STRUCT_MSGHDR_MSG_CONTROL check.

8 years agonet.c: move all sockaddr parsers to a separate file
Dmitry V. Levin [Sat, 25 Jun 2016 13:47:54 +0000 (13:47 +0000)]
net.c: move all sockaddr parsers to a separate file

* sockaddr_ll.c: Rename to sockaddr.c
(print_sockaddr_data_ll): Add static keyword.
* Makefile.am (strace_SOURCES): Likewise.
* defs.h (print_sockaddr_data_ll): Remove.
(addrfams): New prototype.
* net.c: Move all sockaddr parsers to sockaddr.c.

8 years agonet.c: rename printsock to decode_sockaddr
Dmitry V. Levin [Sat, 25 Jun 2016 11:31:48 +0000 (11:31 +0000)]
net.c: rename printsock to decode_sockaddr

* defs.h (printsock): Rename to decode_sockaddr.
* net.c (printsock): Likewise.
(do_msghdr, SYS_FUNC(bind), do_sockname, SYS_FUNC(sendto),
SYS_FUNC(recvfrom)): Replace printsock with decode_sockaddr.

8 years agodefs.h: remove unused prototype
Dmitry V. Levin [Sat, 25 Jun 2016 11:36:12 +0000 (11:36 +0000)]
defs.h: remove unused prototype

* defs.h (print_sock_optmgmt): Remove.

8 years agotests: check decoding of sockaddr structures
Dmitry V. Levin [Sat, 25 Jun 2016 00:24:23 +0000 (00:24 +0000)]
tests: check decoding of sockaddr structures

* tests/net-sockaddr.c: New file.
* tests/net-sockaddr.test: New test.
* tests/.gitignore: Add net-sockaddr.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add net-sockaddr.test.

8 years agonet.c: fix printing AF_PACKET socket addresses
Dmitry V. Levin [Thu, 23 Jun 2016 17:38:18 +0000 (17:38 +0000)]
net.c: fix printing AF_PACKET socket addresses

* defs.h (print_ifindex, print_sockaddr_data_ll): New prototypes.
* net.c: Stop including "xlat/af_packet_types.h".
(print_ifindex): Remove static keyword.
(print_sockaddr_data_l): Remove.
* sockaddr_ll.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/arp_hardware_types.in: New file.
* xlat/ethernet_protocols.in: Likewise.

8 years agonet.c: skip details of too short socket addresses, part 2
Dmitry V. Levin [Thu, 23 Jun 2016 15:15:22 +0000 (15:15 +0000)]
net.c: skip details of too short socket addresses, part 2

* net.c (sa_printers): Add minimal address length for each socket family.
(print_sockaddr): Call socket family specific sockaddr printer
only when socket address length is greater or equal
the minimal address length for the socket family.

8 years agonet.c: fix printing AF_BLUETOOTH socket addresses
Dmitry V. Levin [Thu, 23 Jun 2016 21:06:54 +0000 (21:06 +0000)]
net.c: fix printing AF_BLUETOOTH socket addresses

* xlat/hci_channels.in: New file.
* net.c (print_sockaddr_data_raw): New function.
(print_sockaddr): Use it.
[HAVE_BLUETOOTH_BLUETOOTH_H]: Include "xlat/hci_channels.h".
[HAVE_BLUETOOTH_BLUETOOTH_H] (print_sockaddr_data_bt): Fix printing
sockaddr_hci, sockaddr_sco, sockaddr_rc, and sockaddr_l2 structures.

8 years agonet.c: fix printing AF_IPX sockets addresses, part 2
Dmitry V. Levin [Fri, 24 Jun 2016 11:15:51 +0000 (11:15 +0000)]
net.c: fix printing AF_IPX sockets addresses, part 2

* net.c (print_sockaddr_data_ipx): Print sockaddr_ipx.sipx_network
using %#08x format.  Print elements of sockaddr_ipx.sipx_node array
and sockaddr_ipx.sipx_type using %#02x format.

8 years agonet.c: fix printing AF_UNIX abstract socket addresses
Dmitry V. Levin [Fri, 24 Jun 2016 00:07:44 +0000 (00:07 +0000)]
net.c: fix printing AF_UNIX abstract socket addresses

AF_UNIX abstract socket address specified by sockaddr_un.sun_path
is not a NUL-terminated string.

* net.c (SIZEOF_SA_FAMILY): New macro.
(print_sockaddr_data_un): Use it.  Specify actual address length
in print_quoted_string calls.  Do not set QUOTE_0_TERMINATED flag
when printing an abstract socket address.

8 years agonet.c: fix printing field names of struct sockaddr_nl
Dmitry V. Levin [Fri, 24 Jun 2016 01:30:25 +0000 (01:30 +0000)]
net.c: fix printing field names of struct sockaddr_nl

* net.c (print_sockaddr_data_nl): Change "pid" to "nl_pid", "groups"
to "nl_groups".  Print sockaddr_nl.nl_groups using %#08x format.
* tests/net-yy-netlink.c (main): Update.

8 years agonet.c: fix printing struct sockaddr_in6.sin6_flowinfo
Dmitry V. Levin [Fri, 24 Jun 2016 00:59:28 +0000 (00:59 +0000)]
net.c: fix printing struct sockaddr_in6.sin6_flowinfo

* net.c (print_sockaddr_data_in6): Convert sockaddr_in6.sin6_flowinfo
from network order to host order before printing.

8 years agonet.c: do not print sockaddr_in6.sin6_scope_id unnecessarily
Dmitry V. Levin [Thu, 23 Jun 2016 09:32:24 +0000 (09:32 +0000)]
net.c: do not print sockaddr_in6.sin6_scope_id unnecessarily

Prior to RFC2553, struct sockaddr_in6 had no sin6_scope_id field.
As the kernel still accepts RFC2133 editions of struct sockaddr_in6,
print sockaddr_in6.sin6_scope_id only when it is specified.

* net.c (SIN6_MIN_LEN): New macro.
(print_sockaddr_data_in6): Print sockaddr_in6.sin6_scope_id only when
socket address length exceeds SIN6_MIN_LEN.

8 years agonet.c: fix printing raw data of socket addresses
Dmitry V. Levin [Wed, 22 Jun 2016 23:56:24 +0000 (23:56 +0000)]
net.c: fix printing raw data of socket addresses

* net.c (print_sockaddr): When printing socket address raw data, read
exactly the number of data bytes specified for the socket addess.

8 years agonet.c: skip details of too short socket addresses
Dmitry V. Levin [Wed, 22 Jun 2016 23:40:56 +0000 (23:40 +0000)]
net.c: skip details of too short socket addresses

* net.c (print_sockaddr): Print socket address details only when
the address size is greater than sizeof(struct sockaddr.sa_family).
(print_sockaddr_data_un): Remove handling of addrlen == 2.
* tests/net-y-unix.c (main): Update expected pattern.
* tests/net-yy-unix.c (main): Likewise.
* tests/net.expected: Likewise.

8 years agoAssume that libc provides struct sockaddr_in6.sin6_scope_id
Dmitry V. Levin [Wed, 22 Jun 2016 23:15:54 +0000 (23:15 +0000)]
Assume that libc provides struct sockaddr_in6.sin6_scope_id

* configure.ac (AC_CHECK_MEMBERS): Remove
struct sockaddr_in6.sin6_scope_id.
* net.c (print_sockaddr_data_in6): Remove
HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID check.

8 years agoSplit print_sockaddr
Dmitry V. Levin [Wed, 22 Jun 2016 15:58:00 +0000 (15:58 +0000)]
Split print_sockaddr

* net.c (sockaddr_buf_t): Remove.
(sockaddr_printer): New type.
(sa_printers): New array of sockaddr_printer.
(print_sockaddr): Use it.  Move printers of family specific
sockaddr data to separate funcions.

8 years agoAdd a enum for decoding to tprint_iov() and tprint_iov_upto()
Fabien Siron [Wed, 22 Jun 2016 13:27:03 +0000 (13:27 +0000)]
Add a enum for decoding to tprint_iov() and tprint_iov_upto()

Introduce a new type iov_decode which will be used instead of the integer
"decode" as a parameter.

* defs.h (iov_decode): New enum.
(tprint_iov, tprint_iov_upto): Change type of "decode_iov" to enum iov_decode.
* aio.c (print_iocb): Change type of "decode_iov" to enum iov_decode in
tprint_iov() call.
* keyctl.c (keyctl_instantiate_key_iov): Likewise.
* process.c (ptrace): Likewise.
* process_vm.c (process_vm_readv, process_vm_writev): Likewise.
* io.c (writev, do_pwritev, vmsplice): Likewise.
(print_iovec): Replace the condition with a switch.
(tprint_iov_upto): Change type of "decode_iov" to enum iov_decode.
(readv, do_preadv): Change type of "decode_iov" to enum iov_decode in
tprint_iov_upto() call.
* scsi.c (print_sg_io_v3_req, print_sg_io_v3_res, print_sg_io_v4_req,
print_sg_io_v4_res): Likewise.
* net.c (do_msghdr): Adapt call of tprint_iov_upto().

8 years agoprintsock: fix zero padding of sockaddr buffer
Dmitry V. Levin [Wed, 22 Jun 2016 00:21:47 +0000 (00:21 +0000)]
printsock: fix zero padding of sockaddr buffer

Before this change printsock used to erroneously clear the last byte
of sockaddr buffer.

* net.c (printsock): Use struct sockaddr_storage as a sockaddr buffer.
Reserve additional byte after the sockaddr buffer for zero padding.
Do not clear memory that is going to be overwritten by umoven.
Clear the tail of sockaddr buffer that was not overwritten by umoven.

8 years agoChange printsock to return socket family
Fabien Siron [Tue, 21 Jun 2016 14:42:44 +0000 (14:42 +0000)]
Change printsock to return socket family

* defs.h (printsock): Change return type to int.
* net.c (printsock): Likewise.  Return socket family on success
and -1 in case of an error.

8 years agoUnexport addrfams
Dmitry V. Levin [Tue, 21 Jun 2016 16:45:59 +0000 (16:45 +0000)]
Unexport addrfams

* defs.h (addrfams): Remove.

8 years agosock.c: use print_sockaddr
Dmitry V. Levin [Tue, 21 Jun 2016 16:45:49 +0000 (16:45 +0000)]
sock.c: use print_sockaddr

* sock.c (print_ifreq_addr): Remove.
(PRINT_IFREQ_ADDR): New macro.
(print_ifreq, decode_ifconf): Use it instead of print_ifreq_addr.

8 years agoExport print_sockaddr function
Dmitry V. Levin [Tue, 21 Jun 2016 16:45:40 +0000 (16:45 +0000)]
Export print_sockaddr function

* defs.h (print_sockaddr): New prototype.
* net.c (print_sockaddr): Remove static keyword.
Change type of address pointer to "const void *".
(print_cmsg_ip_recverr, print_group_req): Remove redundant casts
in print_sockaddr invocations.

8 years agoxlat/addrfams.in: provide fallback definitions
Dmitry V. Levin [Tue, 21 Jun 2016 16:45:29 +0000 (16:45 +0000)]
xlat/addrfams.in: provide fallback definitions

* xlat/addrfams.in: add fallback definitions for constants.

8 years agoUpdate AF_* constants
Dmitry V. Levin [Tue, 21 Jun 2016 16:45:22 +0000 (16:45 +0000)]
Update AF_* constants

* xlat/addrfams.in: Add AF_QIPCRTR.

8 years agoAssume that libc provides inet_ntop and inet_pton
Dmitry V. Levin [Tue, 21 Jun 2016 16:44:50 +0000 (16:44 +0000)]
Assume that libc provides inet_ntop and inet_pton

* configure.ac (AC_CHECK_FUNCS): Remove inet_ntop and inet_pton.
* net.c (sockaddr_buf_t, print_sockaddr, print_mreq6): Remove
HAVE_INET_NTOP checks.
* tests/ip_mreq.c: Remove HAVE_INET_PTON check.

8 years agonet.c: use SO_LINGER unconditionally
Dmitry V. Levin [Tue, 21 Jun 2016 16:44:15 +0000 (16:44 +0000)]
net.c: use SO_LINGER unconditionally

* net.c (print_linger, print_getsockopt, print_setsockopt): Do not check
for SO_LINGER availability.

8 years agonet.c: use AF_BLUETOOTH unconditionally
Dmitry V. Levin [Tue, 21 Jun 2016 16:43:30 +0000 (16:43 +0000)]
net.c: use AF_BLUETOOTH unconditionally

* net.c (print_sockaddr, SYS_FUNC(socket)): Do not check
for AF_BLUETOOTH availability.

8 years agoConsistently use AF_UNIX over AF_LOCAL
Dmitry V. Levin [Mon, 20 Jun 2016 22:52:49 +0000 (22:52 +0000)]
Consistently use AF_UNIX over AF_LOCAL

As these constants have the same value 1, let's use and print only one
of them, e.g. AF_UNIX.

* xlat/addrfams.in (AF_LOCAL): Remove.
* tests/net-accept-connect.c (main): Replace AF_LOCAL with AF_UNIX.
* tests/net-y-unix.c: Likewise.
* tests/net-yy-unix.c: Likewise.
* tests/netlink_unix_diag.c: Likewise.

8 years agonet.c: fix printing AF_IPX sockets
Dmitry V. Levin [Sun, 19 Jun 2016 22:02:45 +0000 (22:02 +0000)]
net.c: fix printing AF_IPX sockets

* net.c (print_sockaddr): Print sockaddr_ipx as a regular structure.
(SYS_FUNC(socket)): Remove special handling of AF_IPX.

8 years agonet.c: use AF_IPX unconditionally
Dmitry V. Levin [Sun, 19 Jun 2016 22:02:45 +0000 (22:02 +0000)]
net.c: use AF_IPX unconditionally

* net.c (sockaddr_buf_t, print_sockaddr, SYS_FUNC(socket)): Do not check
for AF_IPX availability.

8 years agoCleanup netipx/ipx.h availability check
Dmitry V. Levin [Sun, 19 Jun 2016 22:02:45 +0000 (22:02 +0000)]
Cleanup netipx/ipx.h availability check

* configure.ac (AC_CHECK_HEADERS): Add netipx/ipx.h.
* net.c: Check for HAVE_NETIPX_IPX_H instead of __GLIBC__.

8 years agoMake getfdproto return enum instead of string
Fabien Siron [Fri, 17 Jun 2016 16:29:53 +0000 (16:29 +0000)]
Make getfdproto return enum instead of string

Introduce a new enum type sock_proto and use it instead of strings for socket
protocols identification.

* defs.h (sock_proto): New enum.
(get_proto_by_name): New function.
* socketutils.c (protocols): New static table.
(print_sockaddr_by_inode): Use it.  Change type of "proto" argument
to sock_proto.
(get_proto_by_name): New function.
* util.c (getfdproto): Use it.  Change return type to sock_proto.
(printfd): Update.

8 years agoSplit travis-ci.sh
Dmitry V. Levin [Sat, 18 Jun 2016 22:53:25 +0000 (22:53 +0000)]
Split travis-ci.sh

* travis-ci.sh: Split into travis-build.sh, travis-install.sh,
and travis-success.sh files.
* .travis.yml (before_install, after_success, git): New mappings.
(script): Change to travis-build.sh.
(addons, install): Remove.
(env): Remove matrix.
(matrix): Replace exclude list with include list.

8 years agoIntroduce HAVE_STRUCT_TCB_EXT_ARG macro
Dmitry V. Levin [Fri, 17 Jun 2016 16:12:13 +0000 (16:12 +0000)]
Introduce HAVE_STRUCT_TCB_EXT_ARG macro

Check for "if HAVE_STRUCT_TCB_EXT_ARG" instead of
"if defined LINUX_MIPSN32 || defined X32".

* defs.h (HAVE_STRUCT_TCB_EXT_ARG): Define for LINUX_MIPSN32 || X32.
(struct tcb): Check it instead of LINUX_MIPSN32 || X32.
(RVAL_LUDECIMAL): Likewise.
* io.c (print_lld_from_low_high_val): Likewise.
* lseek.c (SYS_FUNC(lseek)): Likewise.
* mem.c (SYS_FUNC(mmap)): Likewise.
* syscall.c (trace_syscall_exiting): Likewise.
* util.c (getllval): Likewise.

8 years agobtrfs: fix build with fresh linux/btrfs.h
Dmitry V. Levin [Fri, 17 Jun 2016 00:44:44 +0000 (00:44 +0000)]
btrfs: fix build with fresh linux/btrfs.h

Fix build with fresh <linux/btrfs.h> that provides a slightly different
definition of struct btrfs_ioctl_defrag_range_args.

* btrfs.c (btrfs_ioctl): Cast "len" member of
struct btrfs_ioctl_defrag_range_args to uint64_t.
* tests/btrfs.c (btrfs_print_defrag_range_args): Cast "start" and "len"
members of struct btrfs_ioctl_defrag_range_args to uint64_t.

8 years agobtrfs: provide fallback definitions for BTRFS_IOC_QUOTA_RESCAN*
Dmitry V. Levin [Fri, 17 Jun 2016 00:02:46 +0000 (03:02 +0300)]
btrfs: provide fallback definitions for BTRFS_IOC_QUOTA_RESCAN*

<linux/btrfs.h> was introduced in linux v3.9-rc1 while some
of btrfs ioctls were added later, e.g. BTRFS_IOC_QUOTA_RESCAN
and BTRFS_IOC_QUOTA_RESCAN_STATUS in v3.10-rc2,
or BTRFS_IOC_QUOTA_RESCAN_WAIT in v3.11-rc1.

* btrfs.c [!BTRFS_IOC_QUOTA_RESCAN]
(struct btrfs_ioctl_quota_rescan_args): New structure.
(BTRFS_IOC_QUOTA_RESCAN, BTRFS_IOC_QUOTA_RESCAN_STATUS): New macros.
[!BTRFS_IOC_QUOTA_RESCAN_WAIT] (BTRFS_IOC_QUOTA_RESCAN_WAIT): New macro.
* tests/btrfs.c: Likewise.

Reported-by: Li Er <phoooyb@gmail.com>
8 years agoconfigure.ac: fix checks for btrfs specific structures
Dmitry V. Levin [Thu, 16 Jun 2016 23:21:57 +0000 (23:21 +0000)]
configure.ac: fix checks for btrfs specific structures

* configure.ac (AC_CHECK_MEMBERS): Fix typo in the check for
struct btrfs_ioctl_defrag_range_args.start and
struct btrfs_ioctl_search_args_v2.buf_size.

8 years agoREADME: add system requirements and beautify the file
Elvira Khabirova [Thu, 16 Jun 2016 17:17:59 +0000 (20:17 +0300)]
README: add system requirements and beautify the file

8 years agotests: add signal_receive.test
Fei Jie [Thu, 16 Jun 2016 02:42:14 +0000 (10:42 +0800)]
tests: add signal_receive.test

* tests/signal_receive.c: New file.
* tests/signal_receive.test: New test.
* tests/.gitignore: Add signal_receive.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add signal_receive.test.

8 years agotests: add signal2name function to libtests
Fei Jie [Thu, 16 Jun 2016 02:42:13 +0000 (10:42 +0800)]
tests: add signal2name function to libtests

* tests/tests.h (signal2name): New prototype.
* tests/signal2name.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.

8 years agonet.c: use AF_INET6 unconditionally
Dmitry V. Levin [Wed, 15 Jun 2016 21:56:58 +0000 (21:56 +0000)]
net.c: use AF_INET6 unconditionally

* net.c (SYS_FUNC(socket)): Do not check for AF_INET6 availability.

8 years agoconfigure.ac: do not check for linux/in6.h
Dmitry V. Levin [Wed, 15 Jun 2016 21:49:27 +0000 (21:49 +0000)]
configure.ac: do not check for linux/in6.h

The last user of <linux/in6.h> was removed by commit v4.9-252-gf362a33.

* configure.ac (AC_CHECK_HEADERS): Remove linux/in6.h.

8 years agonet.c: use AF_PACKET unconditionally
Dmitry V. Levin [Wed, 15 Jun 2016 21:42:30 +0000 (21:42 +0000)]
net.c: use AF_PACKET unconditionally

* net.c: Do not check for AF_PACKET availability.

8 years agonet.c: include <linux/if_packet.h> unconditionally
Dmitry V. Levin [Wed, 15 Jun 2016 21:35:48 +0000 (21:35 +0000)]
net.c: include <linux/if_packet.h> unconditionally

* configure.ac (AC_CHECK_HEADERS): Remove linux/if_packet.h.
* net.c: Include <linux/if_packet.h> unconditionally.

8 years agonet.c: use ICMP_FILTER unconditionally
Dmitry V. Levin [Wed, 15 Jun 2016 21:29:07 +0000 (21:29 +0000)]
net.c: use ICMP_FILTER unconditionally

* net.c: Do not check for ICMP_FILTER availability.

8 years agonet.c: include <linux/icmp.h> unconditionally
Dmitry V. Levin [Wed, 15 Jun 2016 21:27:41 +0000 (21:27 +0000)]
net.c: include <linux/icmp.h> unconditionally

* configure.ac (AC_CHECK_HEADERS): Remove linux/icmp.h.
* net.c: Follow the example of tests/net-icmp_filter.c and include
<linux/icmp.h> unconditionally.

8 years agonet.c: use AF_NETLINK unconditionally
Dmitry V. Levin [Tue, 14 Jun 2016 13:53:47 +0000 (13:53 +0000)]
net.c: use AF_NETLINK unconditionally

* net.c: Do not check for AF_NETLINK availability.

8 years agonet.c: include <linux/netlink.h> unconditionally
Dmitry V. Levin [Tue, 14 Jun 2016 13:53:47 +0000 (13:53 +0000)]
net.c: include <linux/netlink.h> unconditionally

* configure.ac (AC_CHECK_HEADERS): Remove linux/netlink.h.
* net.c: Follow the example of socketutils.c and include
<linux/netlink.h> unconditionally.

8 years agoRemove UNDEFINED_SCNO
Elvira Khabirova [Sun, 12 Jun 2016 16:11:43 +0000 (19:11 +0300)]
Remove UNDEFINED_SCNO

Since UNDEFINED_SCNO is set if and only if !SCNO_IS_VALID
and since tcp->s_ent can only be set to &sysent[tcp->scno]
(or to &unknown, but only when !SCNO_IS_VALID), there is no need
to check for UNDEFINED_SCNO before calling syscall_name(tcp->scno).

* defs.h (UNDEFINED_SCNO): Remove.
* syscall.c (get_scno, trace_syscall_entering, trace_syscall_exiting):
Remove checks for UNDEFINED_SCNO.

8 years agotests/attach-f-p.c: fix typo in comment
Dmitry V. Levin [Mon, 13 Jun 2016 22:15:49 +0000 (22:15 +0000)]
tests/attach-f-p.c: fix typo in comment

8 years agostrace.c: fix style in function definition
Elvira Khabirova [Sun, 12 Jun 2016 22:43:15 +0000 (01:43 +0300)]
strace.c: fix style in function definition

* strace.c (kill_save_errno): Move the type of return value
to another line.

8 years agoTurn on more compiler warnings
Elvira Khabirova [Sun, 12 Jun 2016 22:41:02 +0000 (01:41 +0300)]
Turn on more compiler warnings

* configure.ac (gl_WARN_ADD): Add -Wempty-body, -Wformat-security,
-Wignored-qualifiers, -Winit-self, -Wlogical-op,
-Wmissing-parameter-type, -Wnested-externs, -Wold-style-declaration,
-Wold-style-definition, -Wtype-limits.

8 years agostrace.c: fix a warning reported by -Wold-style-definition
Elvira Khabirova [Sun, 12 Jun 2016 22:41:33 +0000 (01:41 +0300)]
strace.c: fix a warning reported by -Wold-style-definition

* strace.c (usage): Add void to the list of function argments.

8 years agotests/ioctl_evdev.c: fix typo in comment
Dmitry V. Levin [Sun, 12 Jun 2016 22:12:33 +0000 (22:12 +0000)]
tests/ioctl_evdev.c: fix typo in comment

8 years agoMove printargs* functions to util.c
Elvira Khabirova [Sun, 12 Jun 2016 13:39:02 +0000 (16:39 +0300)]
Move printargs* functions to util.c

* syscall.c (printargs, printargs_u, printargs_d): Move ...
* util.c: ... here.