Commit Graph

4357 Commits

Author SHA1 Message Date
1c444a75d1 tests: check decoding of timeout argument of recvmmsg syscall
* tests/recvmmsg-timeout.c: New file.
* tests/recvmmsg-timeout.test: New test.
* tests/.gitignore: Add recvmmsg-timeout.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add recvmmsg-timeout.test.
2016-07-19 17:46:30 +00:00
3e3b7f6403 Fix printing of remaining timeout of recvmmsg syscall
* mmsghdr.c (SYS_FUNC(recvmmsg)): Do not print remaining timeout
when the 5th syscall argument is NULL.
* tests/mmsg.c (main): Update expected output.
2016-07-19 17:45:06 +00:00
70495eb3ef Remove configure checks for recvmmsg and sendmmsg
* configure.ac (AC_CHECK_FUNCS): Remove recvmmsg and sendmmsg.
2016-07-19 17:45:06 +00:00
aaf526ce32 tests: add recv_mmsg and send_mmsg functions to libtests
* tests/tests.h (recv_mmsg, send_mmsg): New prototype.
* tests/libmmsg.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
* tests/mmsg.c Do not check for __NR_sendmmsg, __NR_recvmmsg,
HAVE_SENDMMSG, and HAVE_RECVMMSG.  Do not include unused headers.
(recv_mmsg, send_mmsg): Remove.
2016-07-19 17:45:02 +00:00
736d8e4d3f tests: add socketcall function to libtests
* tests/tests.h (socketcall): New prototype.
* tests/libsocketcall.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
2016-07-19 15:15:17 +00:00
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
7f8ece11c8 Fix race condition in decoding timeout argument of recvmmsg syscall
As the value returned by sprint_timespec points to a static area and may
be overwritten by subsequent calls to sprint_timespec, it is not safe to
save this value on entering syscall and use it later on exiting.

* mmsghdr.c (SYS_FUNC(recvmmsg)): On entering syscall, copy the value
returned by sprint_timespec to a dynamically allocated memory, and save
the pointer using set_tcb_priv_data.  On exiting, restore it using
get_tcb_priv_data.
2016-07-18 22:12:45 +00:00
c5d69183af Fix race condition in decoding rt_sigtimedwait's timeout argument
As the value returned by sprint_timespec points to a static area and may
be overwritten by subsequent calls to sprint_timespec, it is not safe to
save this value on entering syscall and use it later on exiting.

* signal.c (SYS_FUNC(rt_sigtimedwait)): On entering syscall, copy the
value returned by sprint_timespec to a dynamically allocated memory,
and save the pointer using set_tcb_priv_data.  On exiting, restore it
using get_tcb_priv_data.
2016-07-18 22:12:44 +00:00
Patrik Jakobsson
a1546a9550 Add private data field to struct tcb
We need to be able to store private data in the struct tcb across it's
lifetime.  To ensure proper deallocation of this stored data a callback
must be provided along with the data.  The callback is executed
automatically on exiting syscall, and when the life of the tcb ends.

* defs.h (struct tcb): Add _priv_data and _free_priv_data fields.
(get_tcb_priv_data, set_tcb_priv_data, free_tcb_priv_data):
New prototypes.
(get_tcb_priv_ulong, set_tcb_priv_ulong): New static inline functions.
* strace.c (get_tcb_priv_data, set_tcb_priv_data, free_tcb_priv_data):
New functions.
(droptcb): Call free_tcb_priv_data.
* syscall.c (trace_syscall_exiting): Call free_tcb_priv_data
when clearing TCB_INSYSCALL flag.

Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2016-07-18 22:12:44 +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
4de8de50d2 net.c: move parsers of sendmmsg and recvmmsg syscalls to mmsghdr.c
* defs.h (decode_mmsgvec): Remove.
* net.c: Do not include "msghdr.h".
(SYS_FUNC(sendmmsg), SYS_FUNC(recvmmsg)): Move ...
* mmsghdr.c: ... here.
(decode_mmsgvec): 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
64a8a4ca3d tests: disable part of msg_name test on non-glibc systems
Sadly, musl recvmsg wrapper blindly dereferences 2nd argument,
so limit the affected part of the test to glibc that doesn't.

* tests/msg_name.c (test_msg_name) [!__GLIBC__]: Do not test
with inaccessible 2nd argument.
2016-07-14 09:37:09 +00:00
4ddbfcfb3c Print struct iovec as a regular structure
* io.c (print_iovec): Print names of iov_base and iov_len fields.
* tests/aio.c (main): Update expected output.
* tests/inet-cmsg.c (main): Likewise.
* tests/mmsg.c (main): Likewise.
* tests/msg_name.c (test_msg_name): Likewise.
* tests/preadv-pwritev.c (main): Likewise.
* tests/preadv2-pwritev2.c (main): Likewise.
* tests/preadv.c (main): Likewise.
* tests/pwritev.c (main): Likewise.
* tests/readv.c (main): Likewise.
* tests/recvmsg.c (main): Likewise.
* tests/vmsplice.c (main): Likewise.
* tests/scm_rights-fd.test: Likewise.
* tests/uio.expected: Likewise.
2016-07-13 23:45:20 +00:00
0b2cf813d7 tests: check decoding of msghdr.msg_name* arguments of recvmsg syscall
* tests/msg_name.c: New file.
* tests/msg_name.test: New test.
* tests/.gitignore: Add msg_name.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add msg_name.test.
2016-07-13 22:45:04 +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
766e1d9928 Update generic ioctl entries from linux 4.7
* linux/64/ioctls_inc.h: Update from linux v4.7 using ioctls_gen.sh.
* linux/32/ioctls_inc_align32.h: Likewise.
* linux/32/ioctls_inc_align64.h: Likewise.
2016-07-12 16:22:23 +00:00
Gleb Fotengauer-Malinovskiy
7577bbf035 x32: update ioctl entries from linux 4.7
* linux/x32/ioctls_inc0.h: Update from linux v4.7 using ioctls_gen.sh.
2016-07-12 16:22:23 +00:00
Gleb Fotengauer-Malinovskiy
4d670d512d maint: update for linux 4.7
* maint/ioctls_sym.sh: Drop obsolete workarounds for linux/btrfs.h.
2016-07-12 16:22:22 +00:00
7fa29bbf35 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.
2016-07-12 16:22:22 +00:00
7acde9e994 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.
2016-07-12 14:42:31 +00:00
416e880a91 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.
2016-07-12 14:42:30 +00:00
802f264643 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.
2016-07-12 14:42:30 +00:00
891855edd9 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.
2016-07-12 14:42:30 +00:00
fe811f7ed7 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.
2016-07-12 14:42:30 +00:00
524045c1ee 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.
2016-07-12 14:42:30 +00:00
587cba262e 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.
2016-07-12 14:42:29 +00:00
eca8b5b26a 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.
2016-07-12 10:54:25 +00:00
36df8223a1 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.
2016-07-12 07:40:31 +00:00
d07eac3ac4 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.
2016-07-12 07:39:26 +00:00
d1cedf0fdb 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.
2016-07-11 22:43:47 +00:00
deb0c18871 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.
2016-07-08 16:01:49 +00:00
73362a23fd 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.
2016-07-07 10:01:25 +00:00
Fabien Siron
1b1baea407 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.
2016-07-07 09:48:32 +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
7499ce0244 Update sigaltstack SS_* constants
* xlat/sigaltstack_flags.in: Add SS_AUTODISARM introduced
by linux kernel commit v4.7-rc1~195^2.
2016-07-07 09:39:49 +00:00
fdedff6e7e 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.
2016-07-07 09:39:37 +00:00
ccd915a7ee 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.
2016-07-05 22:39:09 +00:00
c77c43406f Update input event constants
* xlat/evdev_keycode.in: Add KEY_* constants introduced
by linux kernel commit v4.7-rc6~32^2~6^2.
2016-07-05 21:59:36 +00:00
5e2437567c Update RWF_* constants
* xlat/rwf_flags.in: Add RWF_DSYNC and RWF_SYNC introduced
by linux kernel commit v4.7-rc1~158^2~1.
2016-07-04 22:37:38 +00:00
021f2f365f 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.
2016-07-07 09:01:29 +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
ea7002822f 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.
2016-07-03 22:15:38 +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
7555ffc390 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.
2016-07-01 20:13:37 +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