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].
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.
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.
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.
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.
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.
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.
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.
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.
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.
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].
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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>.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.