]> granicus.if.org Git - strace/log
strace
8 years agofile_ioctl.c: fix indentation
Dmitry V. Levin [Tue, 24 May 2016 00:19:53 +0000 (00:19 +0000)]
file_ioctl.c: fix indentation

* file_ioctl.c: Fix indentation of preprocessor directives
and print formats.

8 years agofile_ioctl.c: include <linux/ioctl.h> instead of <sys/ioctl.h>
Dmitry V. Levin [Tue, 24 May 2016 00:19:40 +0000 (00:19 +0000)]
file_ioctl.c: include <linux/ioctl.h> instead of <sys/ioctl.h>

Being a wrapper around <linux/ioctl.h>, <sys/ioctl.h> brings
no benefits for this parser.

* file_ioctl.c: Include <linux/ioctl.h> instead of <sys/ioctl.h>.

8 years agofile_ioctl.c: fix build on systems without <linux/fiemap.h>
Dmitry V. Levin [Tue, 24 May 2016 00:19:17 +0000 (00:19 +0000)]
file_ioctl.c: fix build on systems without <linux/fiemap.h>

* configure.ac (AC_CHECK_HEADERS): Add linux/fiemap.h.
* file_ioctl.c: Do not include <linux/fiemap.h> and xlat/fiemap_*.h
if [!HAVE_LINUX_FIEMAP_H].
(file_ioctl): Do not parse FS_IOC_FIEMAP if [!HAVE_LINUX_FIEMAP_H].

8 years agoioctl.c: fix build
Dmitry V. Levin [Tue, 24 May 2016 00:19:03 +0000 (00:19 +0000)]
ioctl.c: fix build

* ioctl.c (ioctl_decode): Move definition of "ret" variable
to [ALPHA || POWERPC] case.
[ALPHA || POWERPC]: Fix syntax error.

8 years agoioctl: add decoding for FS_IOC_FIEMAP
Jeff Mahoney [Wed, 18 May 2016 22:09:40 +0000 (18:09 -0400)]
ioctl: add decoding for FS_IOC_FIEMAP

* file_ioctl.c: Include <linux/fiemap.h>, "xlat/fiemap_flags.h",
and "xlat/fiemap_extent_flags.h".
(file_ioctl): Handle FS_IOC_FIEMAP.
* ioctl.c (ioctl_decode): Use file_ioctl for decoding 'f' code ioctls.

8 years agoAdd xlat/fiemap_flags.in and xlat/fiemap_extent_flags.in
Dmitry V. Levin [Tue, 24 May 2016 00:18:39 +0000 (00:18 +0000)]
Add xlat/fiemap_flags.in and xlat/fiemap_extent_flags.in

* xlat/fiemap_flags.in: New file.
* xlat/fiemap_extent_flags.in: Likewise.

8 years agoioctl: add decoding support for btrfs ioctls
Jeff Mahoney [Wed, 18 May 2016 22:09:39 +0000 (18:09 -0400)]
ioctl: add decoding support for btrfs ioctls

* btrfs.c: New file.
* file_ioctl.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* configure.ac (AC_CHECK_HEADERS): Add linux/btrfs.h.
(AC_CHECK_MEMBERS): Add struct btrfs_ioctl_feature_flags.compat_flags,
struct btrfs_ioctl_fs_info_args.nodesize,
struct btrfs_ioctl_defrag_range_args.start,
and struct btrfs_ioctl_search_args_v2.buf_size.
(AC_CHECK_DECLS): Add BTRFS_COMPRESS_* enums.
* defs.h (btrfs_ioctl, file_ioctl): New prototypes.
* ioctl.c (ioctl_decode) [HAVE_LINUX_BTRFS_H]: Use btrfs_ioctl.
* xlat/btrfs_balance_args.in: New file.
* xlat/btrfs_balance_ctl_cmds.in: Likewise.
* xlat/btrfs_balance_flags.in: Likewise.
* xlat/btrfs_balance_state.in: Likewise.
* xlat/btrfs_compress_types.in: Likewise.
* xlat/btrfs_defrag_flags.in: Likewise.
* xlat/btrfs_dev_replace_cmds.in: Likewise.
* xlat/btrfs_dev_replace_results.in: Likewise.
* xlat/btrfs_dev_replace_state.in: Likewise.
* xlat/btrfs_dev_stats_flags.in: Likewise.
* xlat/btrfs_dev_stats_values.in: Likewise.
* xlat/btrfs_features_compat.in: Likewise.
* xlat/btrfs_features_compat_ro.in: Likewise.
* xlat/btrfs_features_incompat.in: Likewise.
* xlat/btrfs_key_types.in: Likewise.
* xlat/btrfs_qgroup_ctl_cmds.in: Likewise.
* xlat/btrfs_qgroup_inherit_flags.in: Likewise.
* xlat/btrfs_qgroup_limit_flags.in: Likewise.
* xlat/btrfs_qgroup_status_flags.in: Likewise.
* xlat/btrfs_scrub_flags.in: Likewise.
* xlat/btrfs_send_flags.in: Likewise.
* xlat/btrfs_snap_flags_v2.in: Likewise.
* xlat/btrfs_space_info_flags.in: Likewise.
* xlat/btrfs_tree_objectids.in: Likewise.

8 years agox32: update ioctl entries from linux 4.6
Gleb Fotengauer-Malinovskiy [Tue, 24 May 2016 14:49:46 +0000 (17:49 +0300)]
x32: update ioctl entries from linux 4.6

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

8 years agotests/attach-f-p.c: sleep a bit more to let the tracer catch up
Dmitry V. Levin [Tue, 24 May 2016 11:10:22 +0000 (11:10 +0000)]
tests/attach-f-p.c: sleep a bit more to let the tracer catch up

On noticeably lagging systems, the parent process may invoke its chdir
call before the tracer gets notified about completion of its last child
process.  Add extra sleep in the parent process to win the race.

* tests/attach-f-p.c (main): Change timerid into a static array.
Arm a timer in the parent process and wait for it.

8 years agotests/attach-p-cmd-cmd.c: fix potential errno clobbering
Dmitry V. Levin [Mon, 23 May 2016 16:39:23 +0000 (16:39 +0000)]
tests/attach-p-cmd-cmd.c: fix potential errno clobbering

* tests/attach-p-cmd-cmd.c (main): Call getpid before chdir.

8 years agotests/net-yy-netlink.c: robustify against libc specific issues
Dmitry V. Levin [Mon, 23 May 2016 10:26:46 +0000 (10:26 +0000)]
tests/net-yy-netlink.c: robustify against libc specific issues

* tests/net-yy-netlink.c (main): Use getsockname instead of recvmsg
as the latter has notible implementation differences that make
the test unreliable.

8 years agotests/net-yy-netlink.c: robustify against os specific issues
Dmitry V. Levin [Mon, 23 May 2016 10:26:46 +0000 (10:26 +0000)]
tests/net-yy-netlink.c: robustify against os specific issues

* tests/net-yy-netlink.c (main): Pass a pointer to a real struct msghdr
as NULL doesn't work well on some systems.

8 years agotests/net-yy-{inet,netlink}.test: cleanup
Dmitry V. Levin [Mon, 23 May 2016 10:12:48 +0000 (10:12 +0000)]
tests/net-yy-{inet,netlink}.test: cleanup

* tests/net-yy-inet.test: Do not pass arguments to net-yy-inet
as the latter does not accept them.
* tests/net-yy-netlink.test: Do not pass arguments to net-yy-netlink
as the latter does not accept them.

8 years agotests: define PRI__[dux]64 macros to print __s64 and __u64 values
Jeff Mahoney [Wed, 18 May 2016 22:09:41 +0000 (18:09 -0400)]
tests: define PRI__[dux]64 macros to print __s64 and __u64 values

Rather than cast every __u64 or __s64 before printing,
define printing helpers for those types directly.

This complements commit 1f3482bedad505a41caf1d61b3a4e7e09a2f4330.

* tests/tests.h (PRI__d64, PRI__u64, PRI__x64): New macros.

8 years agotests: remove manual creation of memory mapping holes
Dmitry V. Levin [Sun, 22 May 2016 22:29:33 +0000 (22:29 +0000)]
tests: remove manual creation of memory mapping holes

We used to call tail_alloc(1) to create memory mapping holes around
regular tail_alloc allocations.  This is no longer needed since regular
tail_alloc allocations create additional memory mapping holes.

* tests/clock_adjtime.c (main): Remove creation of memory mapping holes
using tail_alloc(1).
* tests/futimesat.c (main): Likewise.
* tests/get_mempolicy.c (print_nodes, main): Likewise.
* tests/getgroups.c (main): Likewise.
* tests/getresugid.c (main): Likewise.
* tests/ioctl_uffdio.c (main): Likewise.
* tests/ioctl_v4l2.c (main): Likewise.
* tests/move_pages.c (main): Likewise.
* tests/net-icmp_filter.c (main): Likewise.
* tests/ptrace.c (test_peeksiginfo, main): Likewise.
* tests/pwritev.c (main): Likewise.
* tests/set_mempolicy.c (print_nodes): Likewise.
* tests/setgroups.c (main): Likewise.
* tests/umovestr3.c (main): Likewise.
* tests/utimes.c (main): Likewise.
* tests/xattr.c (main): Likewise.

8 years agotests: make tail_alloc create additional memory mapping holes
Dmitry V. Levin [Sun, 22 May 2016 22:21:48 +0000 (22:21 +0000)]
tests: make tail_alloc create additional memory mapping holes

* tests/tail_alloc.c (tail_alloc): Create additional memory mapping
holes before and after the allocated memory.

8 years agompers: add support of conditionally compiled printers
Dmitry V. Levin [Sat, 21 May 2016 22:53:06 +0000 (22:53 +0000)]
mpers: add support of conditionally compiled printers

We used to declare and define all printers marked with
MPERS_PRINTER_DECL, including ifdef'ed ones.  That approach left us
no way to conditionally compile mpersified printers, which was not
a problem until btrfs ioctls appeared on the horizon.

With this change, those mpersified printers that are not going
to be compiled are also won't be declared and won't be added to
struct_printers.

This is implemented by filtering all source files containing
MPERS_PRINTER_DECL markers through CPP.  As a nice side effect, this
also lifts an ugly requirement of writing all MPERS_PRINTER_DECL
declarations in a single line.

* README-mpers: Update description of MPERS_PRINTER_DECL syntax.
* defs.h [IN_MPERS_BOOTSTRAP] (MPERS_PRINTER_DECL): Turn into
a recursive variadic macro.
[!IN_MPERS_BOOTSTRAP] (MPERS_PRINTER_DECL): Turn into a variadic macro.
All callers changed.
* Makefile.am (mpers_preproc_files, mpers_printer_decl_pattern):
New variables.
(CLEANFILES): Add $(mpers_preproc_files).
(%.c.mpers.i): New rule.
(printers.h, %_printer_decls.h, %_printer_defs.h): Use
mpers_preproc_files instead of srcdir_mpers_source_files,
use mpers_printer_decl_pattern.
* .gitignore: Add /*.mpers.i.

8 years agoRemove redundant declaration of v4l2_ioctl
Dmitry V. Levin [Fri, 20 May 2016 22:47:39 +0000 (22:47 +0000)]
Remove redundant declaration of v4l2_ioctl

There is no need to declare mpers printers in defs.h because
they are already declared in printers.h or native_printer_decls.h.

This complements commit 1e56814f77594a22a74ddee629639eb0bb7edf3a.

* defs.h (v4l2_ioctl): Remove.

8 years agoFix one more code pattern that might break gcc strict aliasing rules
Dmitry V. Levin [Thu, 19 May 2016 01:23:40 +0000 (01:23 +0000)]
Fix one more code pattern that might break gcc strict aliasing rules

* socketutils.c (receive_responses): Turn static buffer into a union
to avoid breaking of gcc strict aliasing rules.
* tests/netlink_inet_diag.c (check_responses): Likewise.
* tests/netlink_netlink_diag.c (check_responses): Likewise.
* tests/netlink_unix_diag.c (check_responses): Likewise.

8 years agotests: add check for netlink protocol decoding with -yy option
Fabien Siron [Sat, 21 May 2016 07:49:00 +0000 (07:49 +0000)]
tests: add check for netlink protocol decoding with -yy option

* tests/netlink_netlink_diag.c: New file.
* tests/net-yy-netlink.c: New file.
* tests/net-yy-netlink.test: New test.
* tests/.gitignore: Add net-yy-netlink and netlink_netlink_diag
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add net-yy-netlink.test.

8 years agoAdd netlink domain sockets support to socketutils
Fabien Siron [Tue, 17 May 2016 10:08:47 +0000 (10:08 +0000)]
Add netlink domain sockets support to socketutils

* linux/netlink_diag.h: New file.
* Makefile.am (EXTRA_DIST): Add it.
* socketutils.c: Include it and "xlat/netlink_protocols.h".
(netlink_send_query, netlink_parse_response, netlink_print): New
functions.
(print_sockaddr_by_inode): Hook up netlink_print.

8 years agotests/pread64-pwrite64.c: robustify against os specific issues
Dmitry V. Levin [Wed, 18 May 2016 09:21:54 +0000 (09:21 +0000)]
tests/pread64-pwrite64.c: robustify against os specific issues

Do not assume that pwrite64 syscall fails when only part of the
specified memory buffer is accessible.  With some kernels, one
accessible byte at the end of page is enough for pwrite64 syscall
to return 1.

* tests/pread64-pwrite64.c (main): Tweak the test that can lead
to a partial write.

8 years agotests/read-write.c: robustify against os specific issues
Dmitry V. Levin [Wed, 18 May 2016 09:14:12 +0000 (09:14 +0000)]
tests/read-write.c: robustify against os specific issues

Do not assume that write syscall fails when only part of the specified
memory buffer is accessible.  With some kernels, one accessible byte
at the end of page is enough for write syscall to return 1.

* tests/read-write.c (main): Tweak the test that can lead to a partial
write.

8 years agoumovestr3.test: extend test coverage
Dmitry V. Levin [Tue, 17 May 2016 17:53:40 +0000 (17:53 +0000)]
umovestr3.test: extend test coverage

* tests/umovestr3.c: Include <sys/param.h>.
(main): Test with each number between PATH_MAX-1 and 0.

8 years agotests/timer_create.c: robustify against os specific issues
Dmitry V. Levin [Tue, 17 May 2016 17:18:48 +0000 (17:18 +0000)]
tests/timer_create.c: robustify against os specific issues

* tests/timer_create.c (main): Do not assume any specific error code
returned by timer_create, print whatever it is.

8 years agoFix some compilation warnings on older systems
Dmitry V. Levin [Tue, 17 May 2016 17:17:13 +0000 (20:17 +0300)]
Fix some compilation warnings on older systems

* print_statfs.c (print_statfs_flags): Define only
for [HAVE_STRUCT_STATFS_F_FLAGS || HAVE_STRUCT_STATFS64_F_FLAGS].
* tests/inet-cmsg.c (print_origdstaddr): Define only
for [IP_ORIGDSTADDR].

8 years agoUpdate generic ioctl entries from linux 4.6
Dmitry V. Levin [Tue, 17 May 2016 16:19:48 +0000 (16:19 +0000)]
Update generic ioctl entries from linux 4.6

* linux/64/ioctls_inc.h: Update from linux v4.6 using ioctls_gen.sh.
* linux/32/ioctls_inc_align32.h: Likewise.
* linux/32/ioctls_inc_align64.h: Likewise.
* NEWS: Mention this.

8 years agomaint: update for linux 4.6
Dmitry V. Levin [Tue, 17 May 2016 15:57:28 +0000 (15:57 +0000)]
maint: update for linux 4.6

* maint/ioctls_sym.sh: Update workarounds for linux/kvm.h.

8 years agoUpdate SOL_* constants
Dmitry V. Levin [Tue, 17 May 2016 10:58:21 +0000 (10:58 +0000)]
Update SOL_* constants

* xlat/socketlayers.in: Add SOL_KCM.

8 years agoUpdate MSG_* constants
Dmitry V. Levin [Tue, 17 May 2016 10:57:32 +0000 (10:57 +0000)]
Update MSG_* constants

* xlat/msg_flags.in: Add MSG_BATCH.

8 years agoUpdate AF_* constants
Dmitry V. Levin [Tue, 17 May 2016 10:55:57 +0000 (10:55 +0000)]
Update AF_* constants

* xlat/addrfams.in: Add AF_KCM.

8 years agotests: add brk.test
Fei Jie [Tue, 17 May 2016 09:59:45 +0000 (17:59 +0800)]
tests: add brk.test

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

8 years agoFix printing of invalid arguments of term ioctls
Dmitry V. Levin [Mon, 16 May 2016 23:36:14 +0000 (23:36 +0000)]
Fix printing of invalid arguments of term ioctls

* term.c (term_ioctl): Print arguments of TCXONC and TCFLSH ioctls
using printxval_long.

8 years agomips: fix printing of invalid operations argument of sysmips syscall
Dmitry V. Levin [Mon, 16 May 2016 23:34:01 +0000 (23:34 +0000)]
mips: fix printing of invalid operations argument of sysmips syscall

* sysmips.c (SYS_FUNC(sysmips)): Print 1st argument of syscall using
printxval_long.

8 years agobfin: fix printing of invalid flags argument of sram_alloc syscall
Dmitry V. Levin [Mon, 16 May 2016 23:31:59 +0000 (23:31 +0000)]
bfin: fix printing of invalid flags argument of sram_alloc syscall

* sram_alloc.c (SYS_FUNC(sram_alloc)): Print 2nd argument using
printflags_long.

8 years agoFix printing of invalid arguments of prctl syscall
Dmitry V. Levin [Mon, 16 May 2016 23:22:11 +0000 (23:22 +0000)]
Fix printing of invalid arguments of prctl syscall

* prctl.c (SYS_FUNC(prctl)): Print 2nd syscall argument
of PR_CAPBSET_DROP, PR_CAPBSET_READ, PR_CAP_AMBIENT, PR_MCE_KILL,
and PR_SET_SECCOMP using printxval_long.
Print 2nd syscall argument of PR_SET_SECUREBITS using printflags_long.
Print 3rd syscall argument of PR_CAP_AMBIENT and PR_MCE_KILL using
printxval_long.
* tests/prctl-seccomp-strict.c (main): Update.

8 years agoFix printing of invalid flags argument of perf_event_open syscall
Dmitry V. Levin [Mon, 16 May 2016 23:19:23 +0000 (23:19 +0000)]
Fix printing of invalid flags argument of perf_event_open syscall

* numa.c (SYS_FUNC(perf_event_open)): Print 5th argument of syscall
using printflags_long.

8 years agoor1k: fix printing of invalid 1st argument of or1k_atomic syscall
Dmitry V. Levin [Mon, 16 May 2016 23:17:19 +0000 (23:17 +0000)]
or1k: fix printing of invalid 1st argument of or1k_atomic syscall

* or1k_atomic.c (SYS_FUNC(or1k_atomic)): Print 1st argument using
printxval_long.

8 years agoFix printing of invalid flags argument of get_mempolicy syscall
Dmitry V. Levin [Mon, 16 May 2016 23:15:06 +0000 (23:15 +0000)]
Fix printing of invalid flags argument of get_mempolicy syscall

* numa.c (SYS_FUNC(get_mempolicy)): Print 5th argument of syscall
using printxval_long.

8 years agoFix printing of invalid mode argument of mbind syscall
Dmitry V. Levin [Mon, 16 May 2016 23:13:04 +0000 (23:13 +0000)]
Fix printing of invalid mode argument of mbind syscall

* numa.c (SYS_FUNC(mbind)): Print 3rd argument of syscall
using printxval_long.
* tests/mbind.c (main): Update.

8 years agoFix printing of invalid argument of MTDFILEMODE ioctl
Dmitry V. Levin [Mon, 16 May 2016 23:06:17 +0000 (23:06 +0000)]
Fix printing of invalid argument of MTDFILEMODE ioctl

* mtd.c (mtd_ioctl): Print 3rd argument of MTDFILEMODE ioctl
using printflags_long.

8 years agoFix printing of invalid flags argument of mount syscall
Dmitry V. Levin [Mon, 16 May 2016 23:04:54 +0000 (23:04 +0000)]
Fix printing of invalid flags argument of mount syscall

* mount.c (SYS_FUNC(mount)): Print 1st argument using printflags_long.

8 years agoFix printing of invalid arguments of memory mapping related syscalls
Dmitry V. Levin [Mon, 16 May 2016 22:58:45 +0000 (22:58 +0000)]
Fix printing of invalid arguments of memory mapping related syscalls

* mem.c (print_mmap): Print 3rd and 4th arguments of syscall
using printflags_long.
(SYS_FUNC(mprotect)): Print 3rd argument of syscall using
printflags_long.
(SYS_FUNC(mremap)): Print 4th argument of syscall using printflags_long.
(SYS_FUNC(remap_file_pages)): Print 3rd and 4th arguments of syscall
using printflags_long.
* tests/remap_file_pages.c (main): Update.

8 years agoFix printing of invalid flags argument of kexec_load and kexec_file_load
Dmitry V. Levin [Mon, 16 May 2016 22:54:41 +0000 (22:54 +0000)]
Fix printing of invalid flags argument of kexec_load and kexec_file_load

* kexec.c (SYS_FUNC(kexec_load), SYS_FUNC(kexec_file_load)): Print
flags argument using printflags_long.

8 years agoFix printing of invalid 3rd argument of fcntl/fcntl64 syscall
Dmitry V. Levin [Mon, 16 May 2016 22:52:04 +0000 (22:52 +0000)]
Fix printing of invalid 3rd argument of fcntl/fcntl64 syscall

* fcntl.c (print_fcntl): Print 3rd argument of F_NOTIFY, F_SETLEASE, and
F_ADD_SEALS operations using printflags_long.

8 years agoFix printing of invalid flags argument of unshare syscall
Dmitry V. Levin [Mon, 16 May 2016 22:49:54 +0000 (22:49 +0000)]
Fix printing of invalid flags argument of unshare syscall

* clone.c (SYS_FUNC(unshare)): Print 1st argument using printflags_long.

8 years agoIntroduce printflags_long and printxval_long
Dmitry V. Levin [Mon, 16 May 2016 22:44:50 +0000 (22:44 +0000)]
Introduce printflags_long and printxval_long

* defs.h (printflags_long, printxval_long): New static inline functions.

8 years agoFix printing of invalid struct xfs_dqblk.d_flags
Dmitry V. Levin [Mon, 16 May 2016 22:28:31 +0000 (22:28 +0000)]
Fix printing of invalid struct xfs_dqblk.d_flags

* quota.c (decode_cmd_data): Explicitly cast struct xfs_dqblk.d_flags
to uint8_t to avoid potential sign-extension bug when printing
invalid struct xfs_dqblk.d_flags.

8 years agoFix printing of invalid struct ubi_mkvol_req.vol_type
Dmitry V. Levin [Mon, 16 May 2016 22:25:46 +0000 (22:25 +0000)]
Fix printing of invalid struct ubi_mkvol_req.vol_type

* mtd.c (ubi_ioctl): Explicitly cast struct ubi_mkvol_req.vol_type
to unsigned short to avoid potential sign-extension bug when printing
invalid struct ubi_mkvol_req.vol_type.

8 years agoFix decoding of prctl/arch_prctl operation argument
Dmitry V. Levin [Mon, 16 May 2016 22:19:31 +0000 (22:19 +0000)]
Fix decoding of prctl/arch_prctl operation argument

Consistently treat operation argument of prctl/arch_prctl syscalls
as int to match the kernel behaviour.

* prctl.c (SYS_FUNC(prctl), SYS_FUNC(arch_prctl)): Assign 1st argument
of syscalls to a variable of type unsigned int and use it in all
subsequent checks and lookups.

8 years agoFix printing of struct sched_attr.sched_flags
Dmitry V. Levin [Mon, 16 May 2016 22:16:17 +0000 (22:16 +0000)]
Fix printing of struct sched_attr.sched_flags

* sched.c (print_sched_attr): Print sched_flags using printflags64.

8 years agoFix printing of struct statfs.f_flags
Dmitry V. Levin [Mon, 16 May 2016 22:09:44 +0000 (22:09 +0000)]
Fix printing of struct statfs.f_flags

* print_statfs.c (print_statfs_flags): Print flags using printflags64.

8 years agoFix printing of invalid struct ifreq.ifr_flags
Dmitry V. Levin [Mon, 16 May 2016 22:05:06 +0000 (22:05 +0000)]
Fix printing of invalid struct ifreq.ifr_flags

* sock.c (print_ifreq): Explicitly cast struct ifreq.ifr_flags
to unsigned short to avoid potential sign-extension bug when printing
invalid struct ifreq.ifr_flags.

8 years agoFix printing of invalid struct pollfd.events
Dmitry V. Levin [Mon, 16 May 2016 22:03:51 +0000 (22:03 +0000)]
Fix printing of invalid struct pollfd.events

* poll.c (print_pollfd): Explicitly cast struct pollfd.events
to unsigned short to avoid potential sign-extension bug when printing
invalid struct pollfd.events.

8 years agoFix printing of invalid struct sembuf.sem_flg
Dmitry V. Levin [Mon, 16 May 2016 22:00:46 +0000 (22:00 +0000)]
Fix printing of invalid struct sembuf.sem_flg

* ipc_sem.c (print_sembuf): Explicitly cast struct sembuf.sem_flg
to unsigned short to avoid potential sign-extension bug when printing
invalid struct sembuf.sem_flg.

8 years agoFix printing of invalid l_type and l_whence in fcntl/fcntl64 syscalls
Dmitry V. Levin [Mon, 16 May 2016 21:57:08 +0000 (21:57 +0000)]
Fix printing of invalid l_type and l_whence in fcntl/fcntl64 syscalls

* fcntl.c (print_struct_flock64): Explicitly cast l_type and l_whence
fields to unsigned short to avoid potential sign-extension bug when
printing invalid l_type or l_whence fields.

8 years agoFix printing of fanotify_mark mask argument
Dmitry V. Levin [Mon, 16 May 2016 21:54:03 +0000 (21:54 +0000)]
Fix printing of fanotify_mark mask argument

* fanotify.c (SYS_FUNC(fanotify_mark)): Print mask using printflags64.

8 years agoFix decoding of epoll_ctl operation argument
Dmitry V. Levin [Mon, 16 May 2016 21:43:35 +0000 (21:43 +0000)]
Fix decoding of epoll_ctl operation argument

Consistently treat operation argument of epoll_ctl syscall as int
to match the kernel behaviour.

* epoll.c (SYS_FUNC(epoll_ctl)): Assign 2nd argument of syscall
to a variable of type unsigned int and use it in all subsequent
checks and lookups.
* tests/epoll_ctl.c (invoke_syscall): New function.
(main): Use it.

8 years agoFix printing of invalid d_type in getdents syscall
Dmitry V. Levin [Mon, 16 May 2016 21:35:07 +0000 (21:35 +0000)]
Fix printing of invalid d_type in getdents syscall

* dirent.c (SYS_FUNC(getdents)): Treat d_type as unsigned char to avoid
potential sign-extension bug when printing invalid d_type.

8 years agobfin: fix decoding of cacheflush syscall
Dmitry V. Levin [Mon, 16 May 2016 21:31:54 +0000 (21:31 +0000)]
bfin: fix decoding of cacheflush syscall

* cacheflush.c (SYS_FUNC(cacheflush)): Print 2nd argument
using %lu format.  Print 3rd argument as flags.

8 years agoFix decoding of BPF_MAP_UPDATE_ELEM flags
Dmitry V. Levin [Mon, 16 May 2016 21:27:30 +0000 (21:27 +0000)]
Fix decoding of BPF_MAP_UPDATE_ELEM flags

* bpf.c (bpf_map_update_elem): Print attr.flags using printxval64.

8 years agoFix decoding of fcntl/fcntl64 operation argument
Dmitry V. Levin [Mon, 16 May 2016 21:01:43 +0000 (21:01 +0000)]
Fix decoding of fcntl/fcntl64 operation argument

Consistently treat operation argument of fcntl/fcntl64 syscalls as int
to match the kernel behaviour.

* fcntl.c (print_fcntl, SYS_FUNC(fcntl), SYS_FUNC(fcntl64)): Assign
2nd argument of syscall to a variable of type unsigned int
and use it in all subsequent checks and lookups.
* tests/struct_flock.c (invoke_test_syscall): New function.
(test_flock_einval, test_flock): Use it.
* tests/fcntl.c (test_flock64_einval): Use it.
* tests/fcntl64.c (test_flock64_einval, test_flock64): Use it.

8 years agoRename sprintflags64 to sprintflags.
Dmitry V. Levin [Sun, 15 May 2016 14:26:03 +0000 (14:26 +0000)]
Rename sprintflags64 to sprintflags.

* defs.h (sprintflags): Remove.
(sprintflags64): Rename to sprintflags.
* util.c (sprintflags64): Rename to sprintflags.

8 years agoPrepare for transition from sprintflags64 to sprintflags
Dmitry V. Levin [Sun, 15 May 2016 14:23:06 +0000 (14:23 +0000)]
Prepare for transition from sprintflags64 to sprintflags

* fcntl.c (print_fcntl): Cast 3rd argument of sprintflags
to unsigned long.
* membarrier.c (SYS_FUNC(membarrier)): Likewise.
* prctl.c (SYS_FUNC(prctl)): Likewise.
* poll.c (decode_poll_exiting): Cast 3rd argument of sprintflags
to unsigned short.

8 years agoRename xlookup64 to xlookup
Dmitry V. Levin [Sat, 14 May 2016 21:55:35 +0000 (21:55 +0000)]
Rename xlookup64 to xlookup

* defs.h (xlookup): Remove.
(xlookup64): Rename to xlookup.
* util.c (xlookup64): Rename to xlookup.

8 years agoPrepare for transition from xlookup64 to xlookup
Dmitry V. Levin [Sat, 14 May 2016 21:46:05 +0000 (21:46 +0000)]
Prepare for transition from xlookup64 to xlookup

* fcntl.c (print_fcntl, SYS_FUNC(fcntl), SYS_FUNC(fcntl64)):
Cast 2nd argument of xlookup to unsigned long.
* prctl.c (SYS_FUNC(prctl)): Likewise.
* sched.c (SYS_FUNC(sched_getscheduler)): Likewise.
* time.c (do_adjtimex): Likewise.
* ioprio.c (sprint_ioprio): Change type of the argument
and local variables from int to unsigned int.
* keyctl.c (print_keyring_serial_number): Cast 2nd argument
of xlookup to unsigned int.
* net.c (tprint_sock_type): Change type of the argument to unsigned int.
* printmode.c (sprintmode): Likewise.
* printsiginfo.c (printsigval):  Change type of si_code argument
to unsigned int.

8 years agov4l2: fix build with old kernel headers
Dmitry V. Levin [Sat, 14 May 2016 00:36:27 +0000 (00:36 +0000)]
v4l2: fix build with old kernel headers

Prior to v2.6.25-rc3, <linux/videodev2.h> didn't include all
required headers, resulting to omission of V4L2_* constants.

This issue doesn't arise in v4l2.c and tests/ioctl_v4l2.c files
because they already include all necessary headers themselves.

* configure.ac (AC_CHECK_DECLS): Include <sys/time.h>, <linux/ioctl.h>,
and <linux/types.h> before <linux/videodev2.h>.

8 years agoconfigure.ac: do not check for sys/ioctl.h and ioctls.h
Dmitry V. Levin [Fri, 13 May 2016 20:26:11 +0000 (20:26 +0000)]
configure.ac: do not check for sys/ioctl.h and ioctls.h

Since sys/ioctl.h is included unconditionally when needed
and ioctls.h doesn't exist, these checks are redundant.

* configure.ac (AC_CHECK_HEADERS): Remove ioctls.h and sys/ioctl.h.

8 years agosock.c: include <linux/ioctl.h> instead of <sys/ioctl.h> or <ioctls.h>
Dmitry V. Levin [Fri, 13 May 2016 20:22:18 +0000 (20:22 +0000)]
sock.c: include <linux/ioctl.h> instead of <sys/ioctl.h> or <ioctls.h>

Include <linux/ioctl.h> for <linux/sockios.h> on alpha, sh, and sh64
architectures because their <asm/sockios.h> use _IOR and _IOW macros
but don't include anything that would define these macros.

Being a wrapper around <linux/ioctl.h>, <sys/ioctl.h> brings
no benefits in this case.  <ioctls.h> simply doesn't exist.

* sock.c [ALPHA || SH || SH64]: Include <linux/ioctl.h>
instead of <sys/ioctl.h> or <ioctls.h>.

8 years agov4l2: include <linux/ioctl.h> instead of <sys/ioctl.h>
Dmitry V. Levin [Fri, 13 May 2016 20:15:12 +0000 (20:15 +0000)]
v4l2: include <linux/ioctl.h> instead of <sys/ioctl.h>

Being a wrapper around <linux/ioctl.h>, <sys/ioctl.h> brings
no benefits for parser of VIDIOC_* ioctls.

* v4l2.c: Include <linux/ioctl.h> instead of <sys/ioctl.h>.

8 years agoprintsiginfo: remove "verbose" argument
Dmitry V. Levin [Fri, 13 May 2016 14:16:12 +0000 (14:16 +0000)]
printsiginfo: remove "verbose" argument

Remove erroneous use of verbose(tcp) as a printing limit
for already fetched members of siginfo_t structure.

* printsiginfo.h (printsiginfo): Remove boolean argument.
* printsiginfo.c (printsigval): Remove boolean argument, print
si_int and si_ptr members unconditionally.  All callers changed.
(print_si_info): Remove boolean argument, print si_utime and si_stime
members unconditionally.  All callers changed.
(printsiginfo): Remove boolean argument.  All callers changed.

8 years agotests/ptrace.c: tweak magic constants to make the test more reliable
Dmitry V. Levin [Fri, 13 May 2016 09:37:10 +0000 (09:37 +0000)]
tests/ptrace.c: tweak magic constants to make the test more reliable

* tests/ptrace.c (main): Change bad_request and bad_data to make they
lower 32-bit parts closer to -1U.

8 years agotests/ioctl_v4l2.c: fix build on older systems
Dmitry V. Levin [Fri, 13 May 2016 04:04:08 +0000 (04:04 +0000)]
tests/ioctl_v4l2.c: fix build on older systems

Fix build on systems without HAVE_DECL_V4L2_CTRL_TYPE_STRING or
V4L2_CTRL_CLASS_CAMERA.

* tests/ioctl_v4l2.c (main) [VIDIOC_S_EXT_CTRLS]: Disable part of the
test if [!HAVE_DECL_V4L2_CTRL_TYPE_STRING].
Replace V4L2_CTRL_CLASS_CAMERA with V4L2_CTRL_CLASS_USER.

8 years agoDo not use htole32 function
Dmitry V. Levin [Fri, 13 May 2016 03:51:43 +0000 (03:51 +0000)]
Do not use htole32 function

htole32 function is not portable enough.

* v4l2.c (print_pixelformat): Rewrite initialization of pixel format
union without using of htole32.
* tests/ioctl_v4l2.c (main): Likewise.

8 years agotests/ioctl_v4l2.c: fix typo
Dmitry V. Levin [Fri, 13 May 2016 03:20:58 +0000 (03:20 +0000)]
tests/ioctl_v4l2.c: fix typo

* tests/ioctl_v4l2.c (main)
[!HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE]: Fix typo in expected
output string.

8 years agotests: check decoding of ptrace syscall
Dmitry V. Levin [Thu, 12 May 2016 16:59:59 +0000 (16:59 +0000)]
tests: check decoding of ptrace syscall

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

8 years agoptrace: decode data argument of PTRACE_PEEKSIGINFO request
Dmitry V. Levin [Fri, 13 May 2016 02:33:33 +0000 (02:33 +0000)]
ptrace: decode data argument of PTRACE_PEEKSIGINFO request

The data argument of PTRACE_PEEKSIGINFO request is a pointer
to siginfo_t array.

* printsiginfo.c (print_siginfo_t): New function.
(print_siginfo_array): New mpers printer.
* process.c (SYS_FUNC(ptrace)): Print data argument of
PTRACE_PEEKSIGINFO request using print_siginfo_array.

8 years agoptrace: decode data argument of PTRACE_SECCOMP_GET_FILTER request
Dmitry V. Levin [Thu, 12 May 2016 16:58:38 +0000 (16:58 +0000)]
ptrace: decode data argument of PTRACE_SECCOMP_GET_FILTER request

* process.c (SYS_FUNC(ptrace)): Print data argument of
PTRACE_SECCOMP_GET_FILTER request on exiting using print_seccomp_fprog.

8 years agoptrace: decode argument of PTRACE_GETEVENTMSG request
Dmitry V. Levin [Thu, 12 May 2016 16:56:30 +0000 (16:56 +0000)]
ptrace: decode argument of PTRACE_GETEVENTMSG request

* process.c (SYS_FUNC(ptrace)): Print data argument of
PTRACE_GETEVENTMSG request on exiting using printnum_ulong.

8 years agoptrace: decode arguments of PTRACE_[GS]ETSIGMASK requests
Dmitry V. Levin [Thu, 12 May 2016 16:52:49 +0000 (16:52 +0000)]
ptrace: decode arguments of PTRACE_[GS]ETSIGMASK requests

* process.c (SYS_FUNC(ptrace)): Print arguments of PTRACE_GETSIGMASK
and PTRACE_SETSIGMASK requests using print_sigset_addr_len.

8 years agoptrace: return RVAL_DECODED for requests decoded on entering
Dmitry V. Levin [Thu, 12 May 2016 16:49:34 +0000 (16:49 +0000)]
ptrace: return RVAL_DECODED for requests decoded on entering

* process.c (SYS_FUNC(ptrace)): Return RVAL_DECODED on entering for all
ptrace requests except those that are partially decoded in exiting,

8 years agoptrace: print PTRACE_O_* flags using printflags64
Dmitry V. Levin [Thu, 12 May 2016 16:35:54 +0000 (16:35 +0000)]
ptrace: print PTRACE_O_* flags using printflags64

As flags argument has a long integer type, print it using printflags64
because printflags takes unsigned int argument.

* process.c (SYS_FUNC(ptrace)): Print PTRACE_O_* flags
using printflags64.

8 years agoptrace: print data argument of PTRACE_SEIZE et al requests as flags
Dmitry V. Levin [Thu, 12 May 2016 15:53:28 +0000 (15:53 +0000)]
ptrace: print data argument of PTRACE_SEIZE et al requests as flags

* process.c (SYS_FUNC(ptrace)): Print data argument of
PTRACE_SEIZE and PTRACE_OLDSETOPTIONS as PTRACE_O_* flags.

8 years agoptrace: print data argument of PTRACE_SINGLEBLOCK et al requests as signo
Dmitry V. Levin [Thu, 12 May 2016 15:50:43 +0000 (15:50 +0000)]
ptrace: print data argument of PTRACE_SINGLEBLOCK et al requests as signo

* process.c (SYS_FUNC(ptrace)): Print data argument of
PTRACE_SINGLEBLOCK, PTRACE_SYSEMU, and PTRACE_SYSEMU_SINGLESTEP requests
as a signal number.

8 years agoptrace: decode addr argument of PTRACE_PEEKSIGINFO request
Dmitry V. Levin [Thu, 12 May 2016 15:45:24 +0000 (15:45 +0000)]
ptrace: decode addr argument of PTRACE_PEEKSIGINFO request

The addr argument of PTRACE_PEEKSIGINFO request is a pointer to
a struct ptrace_peeksiginfo_args.

* process.c: Include "xlat/ptrace_peeksiginfo_flags.h".
(SYS_FUNC(ptrace)): Print addr argument of PTRACE_PEEKSIGINFO request
as a struct ptrace_peeksiginfo_args.
* xlat/ptrace_peeksiginfo_flags.in: New file.

8 years agoptrace: fix printing addr argument of PTRACE_GETSIGMASK et al requests
Dmitry V. Levin [Thu, 12 May 2016 15:38:35 +0000 (15:38 +0000)]
ptrace: fix printing addr argument of PTRACE_GETSIGMASK et al requests

For PTRACE_GETSIGMASK and PTRACE_SETSIGMASK requests, addr argument
contains the size of the buffer pointed to by data argument.
For PTRACE_SECCOMP_GET_FILTER request, addr argument contains
an offset counter.

* process.c (SYS_FUNC(ptrace)): Print addr argument of
PTRACE_GETSIGMASK, PTRACE_SETSIGMASK, and PTRACE_SECCOMP_GET_FILTER
requests using %lu format.

8 years agoptrace: do not print data argument of some requests on sparc
Dmitry V. Levin [Thu, 12 May 2016 15:18:05 +0000 (15:18 +0000)]
ptrace: do not print data argument of some requests on sparc

On sparc, kernel ignores data argument of PTRACE_GETREGS,
PTRACE_SETREGS, PTRACE_GETFPREGS, and PTRACE_SETFPREGS requests.

* process.c (SYS_FUNC(ptrace)) [SPARC || SPARC64]: Return RVAL_DECODED
right after printing addr argument if request is one of PTRACE_GETREGS,
PTRACE_SETREGS, PTRACE_GETFPREGS, or PTRACE_SETFPREGS.

8 years agoptrace: do not print addr and data arguments of PTRACE_ATTACH-like requests
Dmitry V. Levin [Thu, 12 May 2016 15:10:41 +0000 (15:10 +0000)]
ptrace: do not print addr and data arguments of PTRACE_ATTACH-like requests

As kernel ignores addr and data arguments of PTRACE_ATTACH,
PTRACE_INTERRUPT, PTRACE_KILL, and PTRACE_LISTEN request,
we do not print them either.

* process.c (SYS_FUNC(ptrace)): After printing pid argument, return
RVAL_DECODED if request is one of PTRACE_ATTACH, PTRACE_INTERRUPT,
PTRACE_KILL, or PTRACE_LISTEN.

8 years agoptrace: do not print arguments of PTRACE_TRACEME request
Dmitry V. Levin [Thu, 12 May 2016 15:03:58 +0000 (15:03 +0000)]
ptrace: do not print arguments of PTRACE_TRACEME request

As kernel ignores arguments of PTRACE_TRACEME request,
we do not print them either.

* process.c (SYS_FUNC(ptrace)): If request is PTRACE_TRACEME,
return early with RVAL_DECODED.

8 years agoptrace: print request using printxval64
Dmitry V. Levin [Thu, 12 May 2016 14:45:38 +0000 (14:45 +0000)]
ptrace: print request using printxval64

As first argument of ptrace syscall has a long integer type, print
it using printxval64 because printxval takes unsigned int argument.

* process.c (SYS_FUNC(ptrace)): Change type of "request" variable
from "long" to "unsigned long", print it using printxval64 instead
of printxval.

8 years agoDo not sign-extend siginfo_t.si_syscall
Dmitry V. Levin [Thu, 12 May 2016 14:27:49 +0000 (14:27 +0000)]
Do not sign-extend siginfo_t.si_syscall

* printsiginfo.c (print_si_info): Explicitly cast si_syscall member
of siginfo_t that has type "int" to "unsigned int", to avoid sign
extension when passed to syscall_name function.

8 years agoExport print_seccomp_fprog for further use in parser of ptrace syscall
Dmitry V. Levin [Thu, 12 May 2016 14:23:50 +0000 (14:23 +0000)]
Export print_seccomp_fprog for further use in parser of ptrace syscall

* defs.h (print_seccomp_fprog): New prototype.
* seccomp.c (print_seccomp_fprog): Remove "static" keyword.
Move printing of struct seccomp_fprog fields ...
(print_seccomp_filter): ... here.

8 years agotests: add munlockall.test
Fei Jie [Wed, 11 May 2016 07:07:29 +0000 (15:07 +0800)]
tests: add munlockall.test

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

8 years agotests: add link.test
Fei Jie [Wed, 11 May 2016 07:07:28 +0000 (15:07 +0800)]
tests: add link.test

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

8 years agotests: check decoding and dumping of preadv2 and pwritev2 syscalls
Dmitry V. Levin [Wed, 11 May 2016 01:34:09 +0000 (01:34 +0000)]
tests: check decoding and dumping of preadv2 and pwritev2 syscalls

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

8 years agoImplement decoding of preadv2 and pwritev2 syscalls
Dmitry V. Levin [Wed, 11 May 2016 00:42:10 +0000 (00:42 +0000)]
Implement decoding of preadv2 and pwritev2 syscalls

* io.c: Include "xlat/rwf_flags.h".
(do_preadv, do_pwritev, SYS_FUNC(preadv2), SYS_FUNC(pwritev2)):
New functions.
(SYS_FUNC(preadv)): Use do_preadv.
(SYS_FUNC(pwritev)): Use do_pwritev.
* linux/32/syscallent.h (preadv2, pwritev2): New entries.
* linux/64/syscallent.h: Likewise.
* linux/arm/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/mips/syscallent-n32.h: Likewise.
* linux/mips/syscallent-n64.h: Likewise.
* linux/mips/syscallent-o32.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/powerpc64/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* syscall.c (dumpio): Handle SEN_preadv2 and SEN_pwritev2.
* xlat/rwf_flags.in: New file.
* NEWS: Mention parsers of new syscalls.

8 years agotests: extend test coverage of xattr family syscalls
Dmitry V. Levin [Tue, 10 May 2016 18:18:32 +0000 (18:18 +0000)]
tests: extend test coverage of xattr family syscalls

* tests/xattr.c: Check decoding of all xattr family syscalls.
* tests/xattr.test: Use run_strace_match_diff.
* tests/xattr.expected: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove it.

8 years agotests: add print_quoted_memory function to libtests
Dmitry V. Levin [Tue, 10 May 2016 22:05:53 +0000 (22:05 +0000)]
tests: add print_quoted_memory function to libtests

* tests/print_quoted_string.c (print_quoted_memory): New function.
(print_quoted_string): Use it.
* tests/tests.h (print_quoted_memory): New prototype.

8 years agoFix corner cases of xattr family syscalls decoding
Dmitry V. Levin [Tue, 10 May 2016 18:52:06 +0000 (18:52 +0000)]
Fix corner cases of xattr family syscalls decoding

* xattr.c (print_xattr_val): Do not take insize into account, print it
as unsigned long.
Do not decode xattr values of size larger than XATTR_SIZE_MAX.
Use static buffer for fetching xattr values.
(print_xattr_list): Do not decode string when size is zero.

8 years agouserfaultfd: Add ioctl tests
Dr. David Alan Gilbert [Tue, 10 May 2016 10:49:03 +0000 (11:49 +0100)]
userfaultfd: Add ioctl tests

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