]> granicus.if.org Git - strace/log
strace
8 years agoNEWS: Prepare for 4.13 release
Dmitry V. Levin [Sun, 24 Jul 2016 23:40:14 +0000 (23:40 +0000)]
NEWS: Prepare for 4.13 release

8 years agodebian: add gcc-multilib to Build-Depends for relevant architectures
Dmitry V. Levin [Sat, 23 Jul 2016 23:22:40 +0000 (23:22 +0000)]
debian: add gcc-multilib to Build-Depends for relevant architectures

* debian/control (Build-Depends) [amd64, ppc64, sparc64, x32]:
Add gcc-multilib to enable multiple personalities support.

8 years agotests: check decoding of ipc syscall
Dmitry V. Levin [Fri, 22 Jul 2016 14:25:28 +0000 (14:25 +0000)]
tests: check decoding of ipc syscall

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

8 years agoFix corner cases of ipc syscall decoding
Dmitry V. Levin [Fri, 22 Jul 2016 01:17:25 +0000 (01:17 +0000)]
Fix corner cases of ipc syscall decoding

* xlat/ipccalls.in: New file.
* ipc.c: New file.
* Makefile.am (libstrace_a_SOURCES): Add it.
* linux/dummy.h (sys_ipc): Remove stub alias.
* syscall.c (decode_ipc_subcall): Treat 1st argument of ipc syscall
as "unsigned int".
[S390 || S390X]: Skip ipc cubcalls that have non-zero version.
[SPARC64]: Likewise, for the native personality.
Save ipc cubcall version for later use by specific ipc parsers.
* ipc_msg.c (SYS_FUNC(msgrcv)): Handle non-zero ipc subcall version.
[SPARC64]: Handle non-ipc_kludge case for the native personality.
* linux/subcall.h (msgrcv): Change nargs from 4 to 5.
* linux/s390/syscallent.h (ipc): Change nargs from 6 to 5.
* linux/s390x/syscallent.h (ipc): Likewise.

8 years agotests: skip netlink_protocol.test on old systems
Dmitry V. Levin [Thu, 21 Jul 2016 18:18:40 +0000 (18:18 +0000)]
tests: skip netlink_protocol.test on old systems

* tests/netlink_protocol.c: Check that HAVE_SYS_XATTR_H is defined.
Include <stdlib.h> and <sys/xattr.h>.
(main): Check that system.sockprotoname attribute is supported.

8 years agoDo not print too many arguments of socketcall syscall
Dmitry V. Levin [Thu, 21 Jul 2016 11:47:20 +0000 (11:47 +0000)]
Do not print too many arguments of socketcall syscall

* socketcall.c (SYS_FUNC(socketcall)): Print just "call" and "args"
syscall arguments.
* tests/socketcall.c (test_socketcall): Update expected output.
* tests/socketcall.test: Likewise.

8 years agotests/nsyscalls.c: change the type of syscall arguments to kernel_ulong_t
Dmitry V. Levin [Wed, 20 Jul 2016 10:35:56 +0000 (13:35 +0300)]
tests/nsyscalls.c: change the type of syscall arguments to kernel_ulong_t

As most syscalls on x32 and mips n32 are actually 64-bit,
check that 64-bit syscall arguments are decoded properly.

This also workarounds x32 gcc sign extension bug
reported by Eugene Syromyatnikov at
https://sourceforge.net/p/strace/mailman/message/35150860/

* tests/nsyscalls.c: Include "kernel_types.h".
(main): Change the type of syscall arguments to kernel_ulong_t.

8 years agox32, mips n32: make printargs print full 64-bit syscall arguments
Dmitry V. Levin [Wed, 20 Jul 2016 10:35:24 +0000 (13:35 +0300)]
x32, mips n32: make printargs print full 64-bit syscall arguments

As most of x32 syscalls are regular x86_64 syscalls, they should be
printed by default as 64-bit syscalls, and syscall parsers at their
discretion might print syscalls differently.  This is already
implemented in 64-bit strace tracing x32 personality processes,
and now x32 strace will also behave this way.

Similar reasoning applies to mips n32.

* util.c (printargs) [HAVE_STRUCT_TCB_EXT_ARG]: Print syscall arguments
from ext_arg array using %llx format.

8 years agotests: check decoding of socketcall syscall
Dmitry V. Levin [Wed, 20 Jul 2016 02:28:25 +0000 (02:28 +0000)]
tests: check decoding of socketcall syscall

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

8 years agoFix corner cases of socketcall syscall
Dmitry V. Levin [Wed, 20 Jul 2016 01:49:25 +0000 (01:49 +0000)]
Fix corner cases of socketcall syscall

* xlat/socketcalls.in: New file.
* socketcall.c: New file.
* Makefile.am (libstrace_a_SOURCES): Add it.
* linux/dummy.h (sys_socketcall): Remove stub alias.
* syscall.c (decode_socket_subcall): Treat 1st argument of socketcall
as "int".  Do not substitute syscall until all socketcall arguments
have been fetched successfully.

8 years agotests: check decoding and dumping of send and recv syscalls
Dmitry V. Levin [Tue, 19 Jul 2016 00:24:25 +0000 (00:24 +0000)]
tests: check decoding and dumping of send and recv syscalls

* tests/unix-pair-send-recv.c: New file.
* tests/unix-pair-send-recv.expected: Likewise.
* tests/unix-pair-send-recv.test: New test.
* tests/.gitignore: Add unix-pair-send-recv.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add unix-pair-send-recv.test.
(EXTRA_DIST): Add unix-pair-send-recv.expected.

8 years agotests: rename unix-pair-send-recv to unix-pair-sendto-recvfrom
Dmitry V. Levin [Tue, 19 Jul 2016 00:00:10 +0000 (00:00 +0000)]
tests: rename unix-pair-send-recv to unix-pair-sendto-recvfrom

* dumpio.expected: Rename to unix-pair-sendto-recvfrom.expected.
* dumpio.test: Rename to unix-pair-sendto-recvfrom.test.
* unix-pair-send-recv.c: Rename to unix-pair-sendto-recvfrom.c
* .gitignore: Rename unix-pair-send-recv to unix-pair-sendto-recvfrom.
* Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add unix-pair-sendto-recvfrom.test.
(MISC_TESTS): Remove dumpio.test.
(EXTRA_DIST): Rename dumpio.expected
to unix-pair-sendto-recvfrom.expected.

8 years agotests: check decoding of shutdown syscall
Dmitry V. Levin [Mon, 18 Jul 2016 23:39:18 +0000 (23:39 +0000)]
tests: check decoding of shutdown syscall

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

8 years agoxlat/shutdown_modes.in: convert to modern syntax
Dmitry V. Levin [Mon, 18 Jul 2016 23:29:40 +0000 (23:29 +0000)]
xlat/shutdown_modes.in: convert to modern syntax

* xlat/shutdown_modes.in: Replace open-coded xlat table with a list
of constants.

8 years agotests: check silent decoding of sendmmsg and recvmmsg syscalls
Dmitry V. Levin [Mon, 18 Jul 2016 23:19:51 +0000 (23:19 +0000)]
tests: check silent decoding of sendmmsg and recvmmsg syscalls

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

8 years agoPrint unsent messages of failed sendmmsg syscall
Dmitry V. Levin [Mon, 18 Jul 2016 17:48:44 +0000 (17:48 +0000)]
Print unsent messages of failed sendmmsg syscall

* mmsghdr.c (decode_mmsgvec): Clear syserror for the time of printing
struct mmsghdr array in !use_msg_len case.
(SYS_FUNC(sendmmsg)): As failed sendmmsg syscall does not
set msg_len fields, tell this to decode_mmsgvec.
* tests/mmsg_name.c (test_mmsg_name): Check it.

8 years agoPrint unsent messages of sendmmsg syscall
Dmitry V. Levin [Mon, 18 Jul 2016 16:25:25 +0000 (16:25 +0000)]
Print unsent messages of sendmmsg syscall

* defs.h (decode_mmsgvec): Add int argument.
* mmsghdr.c (print_struct_mmsghdr_config): Add msg_len_vlen field.
(print_struct_mmsghdr): Print struct mmsghdr.msg_len only for
msg_len_vlen first elements of struct mmsghdr array.
(decode_mmsgvec): Add msg_len_vlen argument.
(SYS_FUNC(sendmmsg), SYS_FUNC(recvmmsg)): Pass to decode_mmsgvec
the number of elements of struct mmsghdr array that contain meaningful
struct mmsghdr.msg_len.
* tests/mmsg_name.c (test_mmsg_name): Check it.

8 years agotests: check verbose decoding of msg_name* fields of struct mmsghdr array
Dmitry V. Levin [Mon, 18 Jul 2016 10:21:42 +0000 (10:21 +0000)]
tests: check verbose decoding of msg_name* fields of struct mmsghdr array

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

8 years agotests: check decoding of msg_name* fields of struct mmsghdr array
Dmitry V. Levin [Mon, 18 Jul 2016 10:20:06 +0000 (10:20 +0000)]
tests: check decoding of msg_name* fields of struct mmsghdr array

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

8 years agoFix decoding of msg_name* fields of recvmmsg syscall's msghdr array argument
Dmitry V. Levin [Sun, 17 Jul 2016 23:51:39 +0000 (23:51 +0000)]
Fix decoding of msg_name* fields of recvmmsg syscall's msghdr array argument

As msg_namelen fields of recvmmsg syscall's struct msghdr array have
the same read-write semantics as struct msghdr argument of recvmsg
syscall, parser of recvmmsg syscall needs a similar fix.

* mmsghdr.c (print_struct_mmsghdr): Increment p_user_msg_namelen field.
(mmsgvec_data): New structure.
(free_mmsgvec_data, save_mmsgvec_namelen): New functions.
(decode_mmsgvec): Take into account the data saved
by save_mmsgvec_namelen function.
(SYS_FUNC(recvmmsg)): Use save_mmsgvec_namelen.

8 years agommsghdr.c: rewrite decode_mmsgvec using print_array
Dmitry V. Levin [Sat, 16 Jul 2016 22:04:24 +0000 (22:04 +0000)]
mmsghdr.c: rewrite decode_mmsgvec using print_array

* fetch_struct_mmsghdr.c (sizeof_struct_mmsghdr): New mpers printer.
* mmsghdr.c: Include <limits.h>.
(print_struct_mmsghdr_config): New structure.
(fetch_struct_mmsghdr_or_printaddr, print_struct_mmsghdr): New functions.
(decode_mmsgvec): Rewrite using them and print_array.

8 years agotests: check decoding of timeout argument of recvmmsg syscall
Dmitry V. Levin [Mon, 18 Jul 2016 11:22:06 +0000 (11:22 +0000)]
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.

8 years agoFix printing of remaining timeout of recvmmsg syscall
Dmitry V. Levin [Mon, 18 Jul 2016 10:34:41 +0000 (10:34 +0000)]
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.

8 years agoRemove configure checks for recvmmsg and sendmmsg
Dmitry V. Levin [Tue, 19 Jul 2016 15:00:11 +0000 (15:00 +0000)]
Remove configure checks for recvmmsg and sendmmsg

* configure.ac (AC_CHECK_FUNCS): Remove recvmmsg and sendmmsg.

8 years agotests: add recv_mmsg and send_mmsg functions to libtests
Dmitry V. Levin [Tue, 19 Jul 2016 15:09:05 +0000 (15:09 +0000)]
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.

8 years agotests: add socketcall function to libtests
Dmitry V. Levin [Tue, 19 Jul 2016 11:18:25 +0000 (11:18 +0000)]
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.

8 years agoUse IOV_MAX instead of UIO_MAXIOV
Dmitry V. Levin [Fri, 15 Jul 2016 22:58:48 +0000 (22:58 +0000)]
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.

8 years agoUnabuse struct tcb.auxstr
Dmitry V. Levin [Fri, 15 Jul 2016 16:08:19 +0000 (16:08 +0000)]
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.

8 years agoFix race condition in decoding timeout argument of recvmmsg syscall
Dmitry V. Levin [Fri, 15 Jul 2016 17:46:07 +0000 (17:46 +0000)]
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.

8 years agoFix race condition in decoding rt_sigtimedwait's timeout argument
Dmitry V. Levin [Fri, 15 Jul 2016 17:33:26 +0000 (17:33 +0000)]
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.

8 years agoAdd private data field to struct tcb
Patrik Jakobsson [Mon, 24 Aug 2015 12:42:47 +0000 (14:42 +0200)]
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>
8 years agonet.c: move parsers of sendmsg and recvmsg syscalls to msghdr.c
Dmitry V. Levin [Thu, 14 Jul 2016 22:26:28 +0000 (22:26 +0000)]
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.

8 years agonet.c: move parsers of sendmmsg and recvmmsg syscalls to mmsghdr.c
Dmitry V. Levin [Thu, 14 Jul 2016 22:20:04 +0000 (22:20 +0000)]
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.

8 years agomsghdr.c: move all mmsghdr parsers to a separate file
Dmitry V. Levin [Thu, 14 Jul 2016 22:13:58 +0000 (22:13 +0000)]
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.

8 years agotests: disable part of msg_name test on non-glibc systems
Dmitry V. Levin [Thu, 14 Jul 2016 09:37:09 +0000 (09:37 +0000)]
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.

8 years agoPrint struct iovec as a regular structure
Dmitry V. Levin [Wed, 13 Jul 2016 22:54:55 +0000 (22:54 +0000)]
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.

8 years agotests: check decoding of msghdr.msg_name* arguments of recvmsg syscall
Dmitry V. Levin [Wed, 13 Jul 2016 21:56:40 +0000 (21:56 +0000)]
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.

8 years agoFix decoding of struct msghdr.msg_name* arguments of recvmsg syscall
Dmitry V. Levin [Wed, 13 Jul 2016 21:56:16 +0000 (21:56 +0000)]
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.

8 years agoUpdate generic ioctl entries from linux 4.7
Dmitry V. Levin [Tue, 12 Jul 2016 15:57:49 +0000 (15:57 +0000)]
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.

8 years agox32: update ioctl entries from linux 4.7
Gleb Fotengauer-Malinovskiy [Tue, 12 Jul 2016 15:45:33 +0000 (18:45 +0300)]
x32: update ioctl entries from linux 4.7

* linux/x32/ioctls_inc0.h: Update from linux v4.7 using ioctls_gen.sh.

8 years agomaint: update for linux 4.7
Gleb Fotengauer-Malinovskiy [Tue, 12 Jul 2016 15:43:10 +0000 (18:43 +0300)]
maint: update for linux 4.7

* maint/ioctls_sym.sh: Drop obsolete workarounds for linux/btrfs.h.

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.