Commit Graph

21 Commits

Author SHA1 Message Date
8da9668b1b Use IOV_MAX instead of UIO_MAXIOV
IOV_MAX appears to be more portable than UIO_MAXIOV.

* msghdr.c: Include <limits.h>. Remove fallback defintion of UIO_MAXIOV.
(get_optmem_max): Replace UIO_MAXIOV with IOV_MAX.
* tests/msg_control.c: Likewise.
2016-07-18 22:12:45 +00:00
b759d276d5 Unabuse struct tcb.auxstr
As we've got a proper mechanism that parsers can use for storing private
data between entering and exiting stages, all cases of struct tcb.auxstr
abuse should go.

* btrfs.c (btrfs_ioctl): Use set_tcb_priv_ulong and get_tcb_priv_ulong
instead of abusing tcp->auxstr.
* file_handle.c (SYS_FUNC(name_to_handle_at)): Likewise.
* msghdr.c (SYS_FUNC(recvmsg)): Likewise.
* net.c (decode_sockname, SYS_FUNC(recvfrom)): Likewise.
* v4l2.c (print_v4l2_queryctrl): Likewise.
2016-07-18 22:12:45 +00:00
dc84fa3646 net.c: move parsers of sendmsg and recvmsg syscalls to msghdr.c
* defs.h (fetch_msghdr_namelen, decode_msghdr): Remove.
* net.c (SYS_FUNC(sendmsg), SYS_FUNC(recvmsg)): Move ...
* msghdr.c: ... here.
(fetch_msghdr_namelen, decode_msghdr): Add static qualifier.
2016-07-18 22:12:44 +00:00
7c37ce4055 msghdr.c: move all mmsghdr parsers to a separate file
* msghdr.h (print_struct_msghdr): New prototype.
* msghdr.c (print_msghdr): Rename to print_struct_msghdr, remove
static qualifier, all callers changed.
(decode_mmsghdr, decode_mmsgvec, dumpiov_in_mmsghdr): Move to ...
* mmsghdr.c: ... new file.
* Makefile.am (strace_SOURCES): Add it.
2016-07-18 22:12:19 +00:00
d8f77cdf42 Fix decoding of struct msghdr.msg_name* arguments of recvmsg syscall
As the msghdr.msg_namelen argument of recvmsg syscall has the same
read-write semantics as the address length argument of recvfrom syscall,
parser of recvmsg syscall needs a similar fix.

* defs.h (fetch_msghdr_namelen): New prototype.
(decode_msghdr): Add "int *" argument.
* msghdr.c (print_msghdr): Likewise.  Treat it as a pointer to struct
msghdr.msg_namelen passed to the kernel.  Pass to decode_sockaddr
the size of socket address actually returned by the kernel.
Print both user and kernel address lengths when the value changes.
(decode_msghdr, decode_mmsghdr): Add "int *" argument,
forward it to print_msghdr.
(decode_mmsgvec): Update decode_mmsghdr invocation.
(fetch_msghdr_namelen): New function.
* net.c (SYS_FUNC(sendmsg)): Update decode_msghdr invocation.
(SYS_FUNC(recvmsg)): Use fetch_msghdr_namelen on entering to save
struct msghdr.msg_namelen.  On exiting, pass the saved value
to decode_msghdr.
2016-07-13 21:56:16 +00:00
Fabien Siron
2850f745ca 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.
2016-07-07 09:46:51 +00:00
bf2698a6b8 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.
2016-07-03 22:15:45 +00:00
67135824fe 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.
2016-07-02 21:14:48 +00:00
d35d5ecc4d 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.
2016-07-02 21:14:26 +00:00
df57a9b108 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.
2016-06-30 22:49:36 +00:00
b7937bd72e 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.
2016-06-30 22:45:56 +00:00
1d53210514 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.
2016-06-30 22:34:27 +00:00
dfeea6958a 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.
2016-06-30 22:26:35 +00:00
029d979767 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.
2016-06-30 22:23:38 +00:00
6c30aecaf3 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.
2016-06-30 22:14:51 +00:00
db0e6e17b3 msghdr.c: fix printing of struct in_pktinfo
* msghdr.c (print_cmsg_ip_pktinfo): Fix printing
of struct in_pktinfo.ipi_addr.
2016-06-30 22:10:31 +00:00
2a897372db 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.
2016-06-30 22:10:31 +00:00
17e624cf96 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.
2016-06-30 22:10:28 +00:00
08c0960ad5 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.
2016-06-30 22:02:09 +00:00
a50ec34945 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.
2016-06-27 00:14:34 +00:00
95cce4f9a6 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.
2016-06-27 00:10:58 +00:00