]> granicus.if.org Git - strace/log
strace
7 years agodefs.h: stop including <asm/unistd.h>
Dmitry V. Levin [Sat, 31 Dec 2016 22:12:08 +0000 (22:12 +0000)]
defs.h: stop including <asm/unistd.h>

Limit the number of files where <asm/unistd.h> is included
to only those few that need it.

* defs.h: Do not include <asm/unistd.h>.
* clone.c: Include <asm/unistd.h>.
* strace.c: Likewise.
* syscall.c: Likewise.
* util.c: Likewise.

7 years agotests: do not use BUILT_SOURCES
Dmitry V. Levin [Fri, 30 Dec 2016 11:16:56 +0000 (11:16 +0000)]
tests: do not use BUILT_SOURCES

* tests/Makefile.am (ksysent.$(OBJEXT)): New rule.
(BUILT_SOURCES): Remove.

7 years agoFix cross build
Dmitry V. Levin [Fri, 30 Dec 2016 07:20:25 +0000 (07:20 +0000)]
Fix cross build

This fixes cross build regression introduced by commit
v4.15-39-g605a705a63d533dceb3c2d489468fcd3aed3963c.

* tests/Makefile.am (BUILT_SOURCES): Remove scno.h
(objects, scno_dependants): New variables.
($(scno_dependants)): New rule.

Reported-by: Joakim Bech <joakim.bech@linaro.org>
7 years agotests: do not use defs.h and syscall.h
Dmitry V. Levin [Fri, 30 Dec 2016 09:43:12 +0000 (09:43 +0000)]
tests: do not use defs.h and syscall.h

* tests/generate_scno.c: Include "tests.h", "sysent.h", <stdio.h>,
<string.h>, and <asm/unistd.h> instead of "defs.h" and "syscall.h".
* tests/ksysent.c: Likewise.
* tests/nsyscalls.c: Include "tests.h", "sysent.h", <errno.h>,
<stdio.h>, and <unistd.h> instead of "defs.h" and "syscall.h".

7 years agoMove definition of struct sysent and trace flags to a separate file
Dmitry V. Levin [Fri, 30 Dec 2016 09:40:37 +0000 (09:40 +0000)]
Move definition of struct sysent and trace flags to a separate file

* sysent.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h: Include it.
(struct sysent, TRACE_FILE, TRACE_IPC, TRACE_NETWORK, TRACE_PROCESS,
TRACE_SIGNAL, TRACE_DESC, TRACE_MEMORY, SYSCALL_NEVER_FAILS,
STACKTRACE_INVALIDATE_CACHE, STACKTRACE_CAPTURE_ON_ENTER,
TRACE_INDIRECT_SUBCALL, COMPAT_SYSCALL_TYPES): Remove.

7 years agoMpersify SIOC* ioctls
Eugene Syromyatnikov [Mon, 26 Dec 2016 14:07:24 +0000 (17:07 +0300)]
Mpersify SIOC* ioctls

struct ifreq and struct ifconf are ABI-dependent and should have been
mpersified.

* defs.h (sock_ioctl): Remove prototype.
* sock.c (struct_ifconf, struct_ifreq): New typedefs.
(DEF_MPERS_TYPE(struct_ifconf), DEF_MPERS_TYPE(struct_ifreq),
MPERS_DEFS): New includes.
(print_ifreq, print_ifc_len, print_ifconf_ifreq): Replace struct ifreq
with struct_ifreq.
(decode_ifconf): Replace struct ifconf with struct_ifconf, struct ifreq
with struct_fireq.
(sock_ioctl): Wrap into MPERS_PRINTER_DECL.

7 years agosock: rewrite decode_ifconf
Eugene Syromyatnikov [Fri, 23 Dec 2016 19:53:22 +0000 (22:53 +0300)]
sock: rewrite decode_ifconf

* sock.c (decode_ifconf): Rewrite.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agoxlat: update LOOP_* ioctl flags constants
Eugene Syromyatnikov [Mon, 26 Dec 2016 17:42:18 +0000 (20:42 +0300)]
xlat: update LOOP_* ioctl flags constants

* configure.ac (AC_CHECK_DECLS): Add LO_FLAGS_USE_AOPS
and LO_FLAGS_DIRECT_IO.
* xlat/loop_flags_options.in: Likewise.  Add default values
for constants.

7 years agoloop: add fallback definitions for LOOP_* ioctl command constants
Eugene Syromyatnikov [Mon, 19 Dec 2016 00:11:18 +0000 (03:11 +0300)]
loop: add fallback definitions for LOOP_* ioctl command constants

Since these are architecture-independent and have been added over the
kernel's lifetime, it makes sense to have these definitions in strace
itself.

* xlat/loop_cmds.in: New file.
* loop.c: Include "xlat/loop_cmds.h".
(loop_ioctl): Eliminate conditional compilation based on availability
of LOOP_* constant definitions.

7 years agoxlat: extend syntax
Dmitry V. Levin [Thu, 29 Dec 2016 00:30:26 +0000 (00:30 +0000)]
xlat: extend syntax

* xlat/gen.sh: Implement #stop directive that stops preprocessor
at the line it has been encountered during the first pass.  This could
be used, for example, to provide fallback definitions for constants
without defining xlat tables.

7 years agoloop: mpersify struct loop_info and loop_ioctl function
Eugene Syromyatnikov [Mon, 19 Dec 2016 00:15:27 +0000 (03:15 +0300)]
loop: mpersify struct loop_info and loop_ioctl function

struct loop_info contains fields of type long, so it definitely should
have been mpersified.

* defs.h (loop_ioctl): Remove prototype.
* loop.c (struct_loop_info): New typedef.
Include DEF_MPERS_TYPE(struct_loop_info) and MPERS_DEFS.
(decode_loop_info): Replace struct loop_info with struct_loop_info.
Cast lo_inode, lo_init[0], and lo_init[1] to kernel_ulong_t and print
them using appropriate format specifiers.
(loop_ioctl): Wrap into MPERS_PRINTER_DECL.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agoloop: print lo_device and lo_rdevice fields using print_dev_t
Eugene Syromyatnikov [Mon, 26 Dec 2016 16:36:37 +0000 (19:36 +0300)]
loop: print lo_device and lo_rdevice fields using print_dev_t

* loop.c (decode_loop_info, decode_loop_info64): Use print_dev_t
for printing lo_device and lo_rdevice fields.

7 years agoMove device number printing code into a separate routine
Eugene Syromyatnikov [Mon, 26 Dec 2016 12:25:35 +0000 (15:25 +0300)]
Move device number printing code into a separate routine

* print_dev_t.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (print_dev_t): New prototype.
* dm.c: Do not include <sys/sysmacros.h>.
(dm_decode_device, dm_print_dev, dm_decode_dm_name_list): Use
print_dev_t function for printing device numbers.
* mknod.c: Do not include <sys/sysmacros.h>.
(decode_mknod): Use print_dev_t function for printing device number.
* print_struct_stat.c: Do not include <sys/sysmacros.h>.
(print_struct_stat): Use print_dev_t function for printing device
numbers.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agotests: enhance invalid address decoding check in seccomp-strict.test
Dmitry V. Levin [Wed, 28 Dec 2016 22:33:38 +0000 (22:33 +0000)]
tests: enhance invalid address decoding check in seccomp-strict.test

* tests/seccomp-strict.c (main): Change the type of addr variable
containg the invalid address from unsigned long to kernel_ulong_t,
print it using %#llx format.

7 years agotests: check decoding of prctl PR_GET_TID_ADDRESS operation
Eugene Syromyatnikov [Sun, 11 Dec 2016 21:26:07 +0000 (00:26 +0300)]
tests: check decoding of prctl PR_GET_TID_ADDRESS operation

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

7 years agoUpdate the publicly shown copyright information
Dmitry V. Levin [Wed, 28 Dec 2016 17:09:05 +0000 (17:09 +0000)]
Update the publicly shown copyright information

Set the publicly shown copyright holder to "The strace developers.".

* COPYING: Update copyright information.
* configure.ac: Add AC_COPYRIGHT.
* strace.c (print_version): New function.
(init): Use it.
* tests/strace-V.test: Update expected output.

7 years agoconfigure: specify project URL
Dmitry V. Levin [Wed, 28 Dec 2016 16:54:14 +0000 (16:54 +0000)]
configure: specify project URL

* configure.ac (AC_INIT): Add URL.

7 years agoDocument signal injection
Seraphime Kirkovski [Tue, 27 Dec 2016 11:14:36 +0000 (12:14 +0100)]
Document signal injection

* strace.1: Describe :signal=SIG option of the fault injection syntax.
* NEWS: Mention signal injection.

Signed-off-by: Seraphime Kirkovski <kirkseraph@gmail.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agoImplement signal injection
Seraphime Kirkovski [Tue, 27 Dec 2016 11:14:06 +0000 (12:14 +0100)]
Implement signal injection

This extends the fault injection capability with :signal=SIG option
which injects a signal on entering each syscall from the specified set.

:signal and :error options are complementary, if they are both specified
the syscall will be fault injected as usual and the specified signal
will be delivered to the tracee.

* defs.h (struct fault_opts): Change the type of err field to int16_t,
add signo field.
(trace_syscall): Add a pointer argument.
* qualify.c: Include "nsig.h".
(parse_fault_token): Handle signal= option.
(qualify_fault): Update default fault_opts.
* strace.c (trace): Forward signal number from trace_syscall
to ptrace_restart(PTRACE_SYSCALL).
* syscall.c (inject_syscall_fault_entering): Add pointer argument,
save there the signal number specified by fault options.  Do not inject
a syscall fault unless instructed by fault options.
(update_syscall_fault_exiting): Update the error code injection check.
(trace_syscall_entering): Add pointer argument, forward it to
inject_syscall_fault_entering.
(trace_syscall): Add pointer argument, forward it to
trace_syscall_entering.

Signed-off-by: Seraphime Kirkovski <kirkseraph@gmail.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agoUpdate README.md
Dmitry V. Levin [Wed, 28 Dec 2016 11:39:00 +0000 (11:39 +0000)]
Update README.md

* README.md: Update homepage URL, mention command-line interface
and tampering capabilities in the description.

7 years agotests: robustify prctl-arg2-intptr.test
Dmitry V. Levin [Wed, 28 Dec 2016 01:24:31 +0000 (01:24 +0000)]
tests: robustify prctl-arg2-intptr.test

Robustify prctl-arg2-intptr.test against unrelated prctl invocations.

* tests/prctl-arg2-intptr.test: Filter out unrelated PR_GET_*
and PR_SET_* prctl calls.

7 years agosignal: remove redundant checks around NSIG
Dmitry V. Levin [Tue, 27 Dec 2016 23:41:22 +0000 (23:41 +0000)]
signal: remove redundant checks around NSIG

* signal.c (struct old_sigaction, struct new_sigaction,
struct new_sigaction32): Remove safety checks for NSIG >= sizeof(long).

7 years agoIntroduce NSIG_BYTES
Dmitry V. Levin [Tue, 27 Dec 2016 23:32:44 +0000 (23:32 +0000)]
Introduce NSIG_BYTES

* nsig.h (NSIG_BYTES): New macro.
* desc.c: Use it in comments instead of NSIG.
* epoll.c: Likewise.
* poll.c: Likewise.
* signalfd.c: Likewise.
* signal.c: Likewise.
(sprintsigmask_n, print_sigset_addr_len_limit): Use it instead of NSIG.
* linux/alpha/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/arm/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/crisv10/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/ia64/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/m68k/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/microblaze/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/mips/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/powerpc/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/s390/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/sparc/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/tile/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/x86_64/arch_sigreturn.c (arch_sigreturn): Likewise.
* tests/pselect6.c (main): Likewise.

7 years agoMove NSIG ifdefery to a separate header file
Dmitry V. Levin [Tue, 27 Dec 2016 23:18:21 +0000 (23:18 +0000)]
Move NSIG ifdefery to a separate header file

* nsig.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* signal.c: Include "nsig.h" instead of <signal.h>, remove
NSIG workarounds.
* sigreturn.c: Likewise.
* syscall.c: Likewise.
* tests/pselect6.c: Likewise.

7 years agoIntroduce ANY_WORDSIZE_LESS_THAN_KERNEL_LONG macro
Dmitry V. Levin [Mon, 26 Dec 2016 20:12:23 +0000 (20:12 +0000)]
Introduce ANY_WORDSIZE_LESS_THAN_KERNEL_LONG macro

* defs.h (ANY_WORDSIZE_LESS_THAN_KERNEL_LONG): New macro.
(truncate_klong_to_current_wordsize,
truncate_kulong_to_current_wordsize): Use it.
* mem.c (SYS_FUNC(old_mmap)): Likewise.
* util.c (umoven, umovestr, dumpiov_upto): Likewise.
* syscall.c (trace_syscall_exiting): Likewise.

7 years agoSimplify personality checks in msghdr.c and signal.c
Dmitry V. Levin [Mon, 26 Dec 2016 20:21:23 +0000 (20:21 +0000)]
Simplify personality checks in msghdr.c and signal.c

* msghdr.c: Check for [!current_wordsize] instead
of [SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4].
* signal.c: Likewise.

7 years agoReplace widen_to_long with truncate_klong_to_current_wordsize
Dmitry V. Levin [Mon, 26 Dec 2016 17:55:59 +0000 (17:55 +0000)]
Replace widen_to_long with truncate_klong_to_current_wordsize

* defs.h (widen_to_long): Remove.
(truncate_klong_to_current_wordsize): New static inline function.
* aio.c (SYS_FUNC(io_submit), SYS_FUNC(io_getevents): Use it
instead of widen_to_long.
* linux/sparc64/get_syscall_args.c (get_syscall_args): Update comment.
* linux/x86_64/get_syscall_args.c (get_syscall_args): Likewise.

7 years agoReplace widen_to_ulong with truncate_kulong_to_current_wordsize
Dmitry V. Levin [Mon, 26 Dec 2016 17:47:55 +0000 (17:47 +0000)]
Replace widen_to_ulong with truncate_kulong_to_current_wordsize

* defs.h (widen_to_ulong): Remove.
(truncate_kulong_to_current_wordsize): New static inline function.
* io.c (do_preadv, do_pwritev): Use it instead of widen_to_ulong.

7 years agoSimplify print_lld_from_low_high_val ifdefery
Dmitry V. Levin [Mon, 26 Dec 2016 17:06:12 +0000 (17:06 +0000)]
Simplify print_lld_from_low_high_val ifdefery

The demise of HAVE_STRUCT_TCB_EXT_ARG opens the way for a simpler
implementation.

* io.c (print_lld_from_low_high_val): Merge [SIZEOF_LONG > 4
&& SIZEOF_LONG == SIZEOF_LONG_LONG]
and [SIZEOF_KERNEL_LONG_T > SIZEOF_LONG] cases
into a single [SIZEOF_KERNEL_LONG_T > 4] case.
[SIZEOF_KERNEL_LONG_T == 4]: Use direct casts to long long
instead of zero_extend_signed_to_ull.

7 years agoSimplify getllval ifdefery
Dmitry V. Levin [Mon, 26 Dec 2016 16:54:31 +0000 (16:54 +0000)]
Simplify getllval ifdefery

The demise of HAVE_STRUCT_TCB_EXT_ARG opens the way for a simpler
implementation.

* util.c (getllval): Merge [SIZEOF_LONG > 4
&& SIZEOF_LONG == SIZEOF_LONG_LONG]
and [SIZEOF_KERNEL_LONG_T > SIZEOF_LONG] cases
into a single [SIZEOF_KERNEL_LONG_T > 4] case.

7 years agoprctl: print pointer returned by PR_GET_TID_ADDRESS as kernel long
Eugene Syromyatnikov [Sun, 11 Dec 2016 21:12:27 +0000 (00:12 +0300)]
prctl: print pointer returned by PR_GET_TID_ADDRESS as kernel long

Since there is no compat handler for x32/n32, kernel returns kernel's
long as a result of the call.

Interesting, does any callee out there actually care to have enough room
allocated for kernel long?

* prctl.c (SYS_FUNC(prctl)): Use printnum_kptr instead of printnum_ptr
to print the value stored at address pointed by addr2 argument
of PR_GET_TID_ADDRESS operation.

7 years agoAdd functions for printing pointers of kernel_ulong_t size
Eugene Syromyatnikov [Sun, 11 Dec 2016 19:18:11 +0000 (22:18 +0300)]
Add functions for printing pointers of kernel_ulong_t size

In cases where no compat for x32/n32 is implemented, pointer is of
kernel's long size, so it should be printed appropriately.

* defs.h [!current_klongsize] (printnum_addr_klong_int): New prototype.
(printnum_kptr): New macro.
* util.c [!current_klongsize] (printnum_addr_klong_int): New function.

7 years agoPrint indirect pointers as pointers
Eugene Syromyatnikov [Sun, 11 Dec 2016 15:50:53 +0000 (18:50 +0300)]
Print indirect pointers as pointers

Originally, printnum_long_int was used, but it prints NULL incorrectly.

* defs.h (DECL_PRINTNUM_ADDR): New macro.
(DECL_PRINTNUM_ADDR(int), DECL_PRINTNUM_ADDR(int64)): New prototypes.
[!current_wordsize] (printnum_addr_long_int): New prototype.
[!current_wordsize] (printnum_ptr): Use it.
[current_wordsize > 4] (printnum_ptr): Use printnum_addr_int64.
[current_wordsize == 4] (printnum_ptr) Use printnum_addr_int.
* util.c (DEF_PRINTNUM_ADDR): New macro.
(DEF_PRINTNUM_ADDR(int, unsigned int),
DEF_PRINTNUM_ADDR(int64, uint64_t)): New macro instantiations that
provide printnum_addr_int and printnum_addr_int64, accordingly.
[!current_wordsize] (printnum_addr_long_int): New function.
* xet_robust_list.c (sprintaddr): New function.
(main): Use it, update expected output.
* tests/ipc_sem.c (main): Update expected output.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agoipc_sem: print 4th argument of semctl syscall as an address
Eugene Syromyatnikov [Thu, 15 Dec 2016 15:34:16 +0000 (18:34 +0300)]
ipc_sem: print 4th argument of semctl syscall as an address

* ipc_sem.c (SYS_FUNC(semctl)): Print 4th argument using printaddr.
* tests/ipc_sem.c (cleanup): Update expected output.

7 years agoDo not define printnum_long_int on systems with constant current_wordsize
Dmitry V. Levin [Mon, 26 Dec 2016 13:50:14 +0000 (13:50 +0000)]
Do not define printnum_long_int on systems with constant current_wordsize

* defs.h: Check [!current_wordsize] instead
of [SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4] to select
definitions of printnum_slong, printnum_ulong, and printnum_ptr.
* util.c: Check [!current_wordsize] instead
of [SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4] to decide
whether to compile printnum_long_int.

7 years agoumoven: detect invalid addresses
Dmitry V. Levin [Mon, 26 Dec 2016 13:18:00 +0000 (13:18 +0000)]
umoven: detect invalid addresses

Do not silently truncate tracee addresses to current_wordsize.
After transition from long to kernel_ulong_t there should be no sign
extension issues with tracee addresses, and invalid addresses should
be printed properly.

* util.c (umoven): Check [SIZEOF_KERNEL_LONG_T > 4] instead
of [SIZEOF_LONG > 4], reject addresses that do not fit into
current_wordsize.
* tests/umoven-illptr.c: New file.
* tests/umoven-illptr.test: New test.
* tests/.gitignore: Add umoven-illptr.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add umoven-illptr.test.

7 years agoumovestr: detect invalid addresses
Dmitry V. Levin [Mon, 26 Dec 2016 12:16:38 +0000 (12:16 +0000)]
umovestr: detect invalid addresses

Do not silently truncate tracee addresses to current_wordsize.
After transition from long to kernel_ulong_t there should be no sign
extension issues with tracee addresses, and invalid addresses should
be printed properly.

* util.c (umovestr): Check [SIZEOF_KERNEL_LONG_T > 4] instead
of [SIZEOF_LONG > 4], reject addresses that do not fit into
current_wordsize.
* tests/umovestr-illptr.c: New file.
* tests/umovestr-illptr.test: New test.
* tests/.gitignore: Add umovestr-illptr.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add umovestr-illptr.test.

7 years agolseek: simplify _llseek syscall decoder
Dmitry V. Levin [Mon, 26 Dec 2016 11:19:18 +0000 (11:19 +0000)]
lseek: simplify _llseek syscall decoder

After transition from long to kernel_ulong_t the implementation
could be made a bit simpler.

* lseek.c (SYS_FUNC(llseek)): Use direct cast to long long instead
of zero_extend_signed_to_ull.

7 years agolseek: merge two different implementations of lseek syscall decoder
Dmitry V. Levin [Mon, 26 Dec 2016 11:10:41 +0000 (11:10 +0000)]
lseek: merge two different implementations of lseek syscall decoder

After transition from long to kernel_ulong_t there are no mo
complications that required to keep a separate implementation
for x32 and mips n32.

* lseek.c (SYS_FUNC(lseek)): Merge two different implementations
into a single one.

7 years agoRemove HAVE_STRUCT_TCB_EXT_ARG, ext_arg, and u_lrval
Dmitry V. Levin [Mon, 26 Dec 2016 02:59:36 +0000 (02:59 +0000)]
Remove HAVE_STRUCT_TCB_EXT_ARG, ext_arg, and u_lrval

After transition from long to kernel_ulong_t these fields
are no longer needed.

* defs.h (HAVE_STRUCT_TCB_EXT_ARG): Remove.
(struct tcb) [HAVE_STRUCT_TCB_EXT_ARG]: Remove.
[HAVE_STRUCT_TCB_EXT_ARG]: Remove.
(RVAL_MASK): Update.
* io.c (print_lld_from_low_high_val): Check
[SIZEOF_KERNEL_LONG_T > SIZEOF_LONG]
instead of [HAVE_STRUCT_TCB_EXT_ARG].
Use u_arg instead of ext_arg.
* linux/mips/get_error.c (get_error) [LINUX_MIPSN32]: Remove.
* linux/mips/get_syscall_args.c (get_syscall_args) [LINUX_MIPSN32]:
Remove.
[LINUX_MIPSN64]: Extend to [LINUX_MIPSN32].
* linux/x86_64/get_error.c (get_error) [X32]: Remove.
* linux/x86_64/get_syscall_args.c (get_syscall_args) [X32]: Remove.
* lseek.c: Check [SIZEOF_KERNEL_LONG_T > SIZEOF_LONG]
instead of [HAVE_STRUCT_TCB_EXT_ARG].
[SIZEOF_KERNEL_LONG_T > SIZEOF_LONG] (SYS_FUNC(lseek)): Use u_arg
instead of ext_arg.  Use RVAL_UDECIMAL instead of RVAL_LUDECIMAL.
* mem.c (SYS_FUNC(mmap)): Pass offset syscall argument directly
to print_mmap.
* syscall.c (trace_syscall_exiting) [HAVE_STRUCT_TCB_EXT_ARG]: Remove.
* times.c (SYS_FUNC(times)): Use RVAL_UDECIMAL instead
of RVAL_LUDECIMAL.
* util.c (getllval): Check [SIZEOF_KERNEL_LONG_T > SIZEOF_LONG]
instead of [HAVE_STRUCT_TCB_EXT_ARG].  Use u_arg instead of ext_arg.

7 years agoRemove getarg_klu
Dmitry V. Levin [Mon, 26 Dec 2016 02:28:04 +0000 (05:28 +0300)]
Remove getarg_klu

After transition from long to kernel_ulong_t we no longer need
tcp->ext_arg, and therefore a function to access it is also no longer
needed.

* defs.h (getarg_klu): Remove prototype.
* util.c (getarg_klu): Remove.
(printargs): Access tcp->u_arg directly
* bjm.c (SYS_FUNC(init_module)): Likewise.
* clone.c (SYS_FUNC(unshare)): Likewise.
* fadvise.c (SYS_FUNC(fadvise64)): Likewise.
* kcmp.c (SYS_FUNC(kcmp)): Likewise.
* kexec.c (SYS_FUNC(kexec_file_load)): Likewise.
* keyctl.c (SYS_FUNC(keyctl)): Likewise.
* lookup_dcookie.c (SYS_FUNC(lookup_dcookie)): Likewise.
* mem.c (do_mprotect): Likewise.
* mq.c (SYS_FUNC(mq_timedsend), SYS_FUNC(mq_timedreceive)): Likewise.
* pkeys.c (SYS_FUNC(pkey_alloc)): Likewise.
* prctl.c (print_prctl_args, SYS_FUNC(prctl), SYS_FUNC(arch_prctl)):
Likewise.

7 years agoRemove printaddr_klu
Dmitry V. Levin [Mon, 26 Dec 2016 02:17:29 +0000 (05:17 +0300)]
Remove printaddr_klu

After transition from long to kernel_ulong_t we no longer need
two versions of printaddr function.

* defs.h (printaddr): Remove.
(printaddr_klu): Rename to printaddr.
* util.c (printaddr_klu): Likewise.
* bjm.c (SYS_FUNC(init_module)): Replace printaddr_klu with printaddr.
* mem.c (do_mprotect): Likewise.

7 years agotests: check decoding of a subset of prctl operations
Eugene Syromyatnikov [Sat, 10 Dec 2016 04:03:54 +0000 (07:03 +0300)]
tests: check decoding of a subset of prctl operations

Check decoding of prctl operations that take the second syscall argument
as a pointer to an integer.

* tests/prctl-arg2-intptr.c: New file.
* tests/prctl-arg2-intptr.test: New test.
* tests/.gitignore: Add prctl-arg2-intptr.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add prctl-arg2-intptr.test.

7 years agoAutomatically replace PRI_kr[dux] with PRI_kl[dux]
Dmitry V. Levin [Mon, 26 Dec 2016 10:16:35 +0000 (10:16 +0000)]
Automatically replace PRI_kr[dux] with PRI_kl[dux]

Remove temporary macros created for transition from long
to kernel_ulong_t.

Automatically replace PRI_kr[dux] with PRI_kl[dux] using
$ git grep -l 'PRI_kr[dux]' | xargs sed -ri 's/PRI_kr([dux])/PRI_kl\1/g'

* defs.h (PRI_krd, PRI_kru, PRI_krx): Remove.  All users updated.

7 years agoAutomatically replace kernel_(scno|ureg)_t with kernel_ulong_t
Dmitry V. Levin [Mon, 26 Dec 2016 10:26:03 +0000 (10:26 +0000)]
Automatically replace kernel_(scno|ureg)_t with kernel_ulong_t

Remove temporary types created for transition from long
to kernel_ulong_t.

Automatically replace kernel_scno_t and kernel_ureg_t with
kernel_ulong_t using
$ git grep -El 'kernel_(scno|ureg)_t' |
  xargs sed -ri 's/kernel_(scno|ureg)_t/kernel_ulong_t/g'

* kernel_types.h (kernel_scno_t, kernel_ureg_t): Remove.
All users updated.

7 years agoRedirect kernel_ureg_t and kernel_scno_t from unsigned long to kernel_ulong_t
Dmitry V. Levin [Mon, 26 Dec 2016 00:55:54 +0000 (00:55 +0000)]
Redirect kernel_ureg_t and kernel_scno_t from unsigned long to kernel_ulong_t

* defs.h (struct tcb): Change u_rval type from long to kernel_long_t.
(PRI_krd, PRI_kru, PRI_krx): Redirect to PRI_kld, PRI_klu, and PRI_klx.
* kernel_types.h (kernel_scno_t, kernel_ureg_t): Redirect
to kernel_ulong_t.

7 years agoPrint kernel_ureg_t and kernel_scno_t using dedicated format strings
Dmitry V. Levin [Mon, 26 Dec 2016 00:37:18 +0000 (00:37 +0000)]
Print kernel_ureg_t and kernel_scno_t using dedicated format strings

Prepare for the change of kernel_ureg_t and kernel_scno_t from
unsigned long to kernel_ulong_t.

* defs.h (PRI_krd, PRI_kru, PRI_krx): New temporary macros.
All users updated.

7 years agovm_read_mem: detect address truncation
Dmitry V. Levin [Mon, 26 Dec 2016 01:21:04 +0000 (01:21 +0000)]
vm_read_mem: detect address truncation

When sizeof(kernel_ureg_t) > sizeof(long), the tracee address passed
to vm_read_mem could be silently truncated.  Detect this situation
and return EIO when the tracee address does not fit into unsigned long.

* util.c (vm_read_mem): Save raddr argument into a temporary variable
truncated_raddr of type unsigned long.  Set errno to EIO and return -1
when truncated_raddr does not equal to raddr.

7 years agotrace_syscall_exiting: prepare personality check for u_rval type change
Dmitry V. Levin [Mon, 26 Dec 2016 02:53:05 +0000 (05:53 +0300)]
trace_syscall_exiting: prepare personality check for u_rval type change

* syscall.c (trace_syscall_exiting): Check for sizeof(tcp->u_rval)
instead of sizeof(long) when deciding how to print tcp->u_rval.

7 years agoUse ptr_to_kulong instead of explicit casts of pointers to kernel_ureg_t
Dmitry V. Levin [Mon, 26 Dec 2016 01:37:21 +0000 (01:37 +0000)]
Use ptr_to_kulong instead of explicit casts of pointers to kernel_ureg_t

Direct casts to kernel_ureg_t will not work after the change
of kernel_ureg_t from unsigned long to kernel_ulong_t.

* defs.h (ptr_to_kulong): New macro.
* block.c (print_blkpg_req): Use it instead of explicit casts
to kernel_ureg_t.
* btrfs.c (btrfs_ioctl): Likewise.
* evdev.c (ff_effect_ioctl): Likewise.
* mmsghdr.c (dumpiov_in_mmsghdr): Likewise.
* msghdr.c (print_struct_msghdr, dumpiov_in_msghdr): Likewise.
* mtd.c (decode_mtd_oob_buf): Likewise.
* printsiginfo.c (printsigval, print_si_info): Likewise.
* scsi.c (print_sg_io_v3_req, print_sg_io_v3_res): Likewise.
* sigaltstack.c (print_stack_t): Likewise.
* sock.c (decode_ifconf): Likewise.
* sysctl.c (SYS_FUNC(sysctl)): Likewise.
* util.c (dumpiov_upto): Likewise.
* v4l2.c (print_v4l2_framebuffer, print_v4l2_ext_control,
print_v4l2_ext_controls): Likewise.

7 years agoumove*: remove redundant casts
Dmitry V. Levin [Mon, 26 Dec 2016 01:26:54 +0000 (01:26 +0000)]
umove*: remove redundant casts

* util.c (umoven, umovestr): Remove casts from unsigned long to pointer.

7 years agoupoke: remove redundant casts
Dmitry V. Levin [Mon, 26 Dec 2016 01:19:01 +0000 (01:19 +0000)]
upoke: remove redundant casts

* upoke.c (upoke): Remove casts from unsigned long to pointer.

7 years agosignal: cleanup decoding of sa_handler and sa_restorer
Dmitry V. Levin [Sun, 25 Dec 2016 23:24:08 +0000 (23:24 +0000)]
signal: cleanup decoding of sa_handler and sa_restorer

Change type of sa_handler and sa_restorer fields from function pointers
to unsigned long.  This saves the code from a lot of casts between
pointers and integers.

Rename __sa_handler to sa_handler__ as names starting with underscore
symbol are reserved and should not be used.

* signal.c (old_sigaction): Rename __sa_handler to sa_handler__,
all users updated.  Change the type of sa_handler__ and sa_restorer
from pointer to unsigned long.
(old_sigaction32): Rename __sa_handler to sa_handler__, all users
updated.
(decode_old_sigaction): Remove now redundant casts from
old_sigaction32.sa_handler__ to old_sigaction.sa_handler__,
from old_sigaction32.sa_restorer to old_sigaction.sa_restorer,
and from old_sigaction.sa_handler__ to unsigned long.  Print
old_sigaction.sa_restorer using printaddr.
* signal.c (new_sigaction): Rename __sa_handler to sa_handler__,
all users updated.  Change the type of sa_handler__ and sa_restorer
from pointer to unsigned long.
(new_sigaction32): Rename __sa_handler to sa_handler__, all users
updated.
(decode_new_sigaction): Remove now redundant casts from
new_sigaction32.sa_handler__ to new_sigaction.sa_handler__,
from new_sigaction32.sa_restorer to new_sigaction.sa_restorer,
and from new_sigaction.sa_handler__ to unsigned long.  Print
new_sigaction.sa_restorer using printaddr.

7 years agosignal: change signal handler address type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 23:21:22 +0000 (23:21 +0000)]
signal: change signal handler address type from unsigned long to kernel_ureg_t

* signal.c (get_sa_handler_str, print_sa_handler): Change handler type
from unsigned long to kernel_ureg_t.

7 years agoquota: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 22:56:21 +0000 (22:56 +0000)]
quota: change address argument type from unsigned long to kernel_ureg_t

* quota.c (decode_cmd_data): Change the type of data argument
from unsigned long to kernel_ureg_t.

7 years agoexecve: prepare for handling big pointers
Dmitry V. Levin [Sun, 25 Dec 2016 22:27:33 +0000 (22:27 +0000)]
execve: prepare for handling big pointers

* execve.c (printargv): Change cp.p64 type from unsigned long
to kernel_ulong_t so it could handle wordsize > sizeof(long) properly.

7 years agoclone: print clone flags without truncation
Dmitry V. Levin [Sun, 25 Dec 2016 22:17:38 +0000 (22:17 +0000)]
clone: print clone flags without truncation

The flags argument is defined in kernel as unsigned long,
so change its decoding to avoid truncation.

* clone.c (SYS_FUNC(clone)): Change flags type from unsigned long
to kernel_ureg_t, print it using printflags64 instead of printflags.

7 years agoUse printxval64 instead of printxval_long
Dmitry V. Levin [Sun, 25 Dec 2016 21:59:59 +0000 (21:59 +0000)]
Use printxval64 instead of printxval_long

After the change of tcb.u_arg type from long to kernel_ureg_t it is safe
to stop using printxval_long proxy and pass syscall arguments directly
to printxval64.

* defs.h (printxval_long): Remove.
* fcntl.c (print_fcntl): Replace printxval_long with printxval64.
* mtd.c (mtd_ioctl): Likewise.
* numa.c (SYS_FUNC(mbind)): Likewise.
* or1k_atomic.c [OR1K] (SYS_FUNC(or1k_atomic)): Likewise.
* sysmips.c [MIPS] (SYS_FUNC(sysmips)): Likewise.
* term.c (term_ioctl): Likewise.

7 years agoUse printflags64 instead of printflags_long
Dmitry V. Levin [Sun, 25 Dec 2016 21:55:01 +0000 (21:55 +0000)]
Use printflags64 instead of printflags_long

After the change of tcb.u_arg type from long to kernel_ureg_t it is safe
to stop using printflags_long proxy and pass syscall arguments directly
to printflags64.

* defs.h (printflags_long): Remove.
* fcntl.c (print_fcntl): Replace printflags_long with printflags64.
* numa.c (SYS_FUNC(get_mempolicy)): Likewise.
* perf.c (SYS_FUNC(perf_event_open)): Likewise.
* sram_alloc.c [BFIN] (SYS_FUNC(sram_alloc)): Likewise.

7 years agoupeek, upoke: change argument types from long to unsigned long
Dmitry V. Levin [Sun, 25 Dec 2016 12:53:14 +0000 (12:53 +0000)]
upeek, upoke: change argument types from long to unsigned long

* defs.h (upeek, upoke): Change offset argument type from long
to unsigned long.  Change res argument type from long to kernel_ureg_t.
* upeek.c (upeek): Likewise.
* upoke.c (upoke.c): Likewise.
* syscall.c (print_pc) [ARCH_PC_PEEK_ADDR]: Change pc type from long
to kernel_ureg_t.
* linux/aarch64/arch_regs.c (arm_sp_ptr): Remove redundant cast.
* linux/metag/get_syscall_args.c (get_syscall_args): Likewise.
* linux/sh/get_syscall_result.c (get_syscall_result_regs): Likewise.
* linux/sh64/get_syscall_result.c (get_syscall_result_regs): Likewise.
* linux/powerpc/getregs_old.c (getregs_old): Remove redundant casts.
* linux/alpha/arch_getrval2.c (getrval2): Change r20 type from long
to unsigned long.
* linux/alpha/arch_regs.c (alpha_r0, alpha_a3): Change type from long
to unsigned long.
* linux/bfin/arch_regs.c (bfin_r0): Likewise.
* linux/crisv10/arch_regs.c (cris_r10): Likewise.
* linux/hppa/arch_regs.c (hppa_r28): Likewise.
* linux/ia64/arch_regs.c (IA64_PSR_IS): Likewise.
* linux/microblaze/arch_regs.c (microblaze_r3): Likewise.
* linux/sh/arch_regs.c (sh_r0): Likewise.
* linux/sh64/arch_regs.c (sh64_r9): Likewise.
* linux/xtensa/arch_regs.c (xtensa_a2): Likewise.
* linux/alpha/arch_sigreturn.c (arch_sigreturn): Change addr type
from long to unsigned long.
* linux/microblaze/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/alpha/get_scno.c (arch_get_scno): Update for the change
of signedness.
* linux/arc/get_syscall_args.c (get_syscall_args): Change arc_args type
from pointer to long to pointer to unsigned long.
* linux/arm/arch_regs.c (arm_sp_ptr): Change type from pointer to long
to pointer to unsigned long.
* linux/arm/arch_regs.h (arm_sp_ptr): Likewise.
* linux/i386/arch_regs.c (i386_esp_ptr): Likewise.
* linux/i386/arch_regs.h (i386_esp_ptr): Likewise.
* linux/m68k/arch_regs.c (m68k_usp_ptr): Likewise.
* linux/m68k/arch_regs.h (m68k_usp_ptr): Likewise.
* linux/ia64/get_syscall_args.c (get_syscall_args): Use umove
instead of umoven.
* linux/sh/arch_getrval2.c (getrval2): Change val type from long
to unsigned long.

7 years agoarch_sigreturn: change tracee address type from long to unsigned long
Dmitry V. Levin [Sun, 25 Dec 2016 09:47:03 +0000 (09:47 +0000)]
arch_sigreturn: change tracee address type from long to unsigned long

* linux/arm/arch_sigreturn.c (arch_sigreturn): Change addr variable
type from long to unsigned long.
* linux/ia64/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/m68k/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/powerpc/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/s390/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/sparc/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/tile/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/crisv10/arch_sigreturn.c (arch_sigreturn): Change the type
of addr and regs variables from long to unsigned long.
* linux/mips/arch_sigreturn.c (arch_sigreturn): Change addr variable
type from long to kernel_ureg_t.
* linux/x86_64/arch_sigreturn.c (arch_sigreturn): Change the type
of offset and addr variables from long to kernel_ureg_t.

7 years agokexec: change flags type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 03:03:34 +0000 (03:03 +0000)]
kexec: change flags type from unsigned long to kernel_ureg_t

* kexec.c (SYS_FUNC(kexec_load)): Change n variable type
from unsigned long to kernel_ureg_t.  Use printxval64 instead
of printxval_long.  Use printflags64 instead of printflags_long.

7 years agokexec: change types of pointers and sizes to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 02:58:00 +0000 (02:58 +0000)]
kexec: change types of pointers and sizes to kernel_ureg_t

* kexec.c (print_seg): Change the type of *seg and seg_buf variables
from unsigned long to kernel_ureg_t.
(print_kexec_segments): Change len argument type from unsigned long
to kernel_ureg_t.  Change seg variable type from unsigned long
to kernel_ureg_t.

7 years agoprintsiginfo: change len argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 02:53:16 +0000 (02:53 +0000)]
printsiginfo: change len argument type from unsigned long to kernel_ureg_t

* printsiginfo.c (print_siginfo_array): Change len argument type
from unsigned long to kernel_ureg_t.

7 years agosignal: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 02:47:22 +0000 (02:47 +0000)]
signal: change address argument type from unsigned long to kernel_ureg_t

* signal.c (print_sigqueueinfo): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agostatfs64: change size argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 02:02:36 +0000 (02:02 +0000)]
statfs64: change size argument type from unsigned long to kernel_ureg_t

* defs.h (print_struct_statfs64): Change size argument type
from unsigned long to kernel_ureg_t.
* print_statfs.c (print_struct_statfs64): Likewise.
* fetch_struct_statfs.c (fetch_struct_statfs64): Likewise.
* fstatfs64.c (SYS_FUNC(fstatfs64)): Pass size argument directly
to print_struct_statfs64.
* statfs64.c (SYS_FUNC(statfs64)): Likewise.

7 years agoCast tcp->u_rval to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Sun, 25 Dec 2016 01:46:47 +0000 (01:46 +0000)]
Cast tcp->u_rval to kernel_ureg_t instead of unsigned long

* fcntl.c (print_fcntl): Cast tcp->u_rval to kernel_ureg_t instead
of unsigned long.
* membarrier.c (SYS_FUNC(membarrier)): Likewise.
* prctl.c (SYS_FUNC(prctl)): Likewise.
* sched.c (SYS_FUNC(sched_getscheduler)): Likewise.
* time.c (do_adjtimex): Likewise.

7 years agodecode_sockbuf: change addrlen argument type from long to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 01:36:15 +0000 (01:36 +0000)]
decode_sockbuf: change addrlen argument type from long to kernel_ureg_t

* net.c (decode_sockbuf): Change addrlen argument type from long
to kernel_ureg_t.

7 years agonetlink: change size types from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 01:31:49 +0000 (01:31 +0000)]
netlink: change size types from unsigned long to kernel_ureg_t

* defs.h (decode_netlink): Change len argument type from unsigned long
to kernel_ureg_t.
* netlink.c (fetch_nlmsghdr): Likewise.
(decode_nlmsghdr_with_payload): Likewise.  Change nlmsg_len variable
type from unsigned long to unsigned int.
(decode_netlink): Change the type of len argument and next_len variable
from unsigned long to kernel_ureg_t.  Change nlmsg_len variable type
from unsigned long to unsigned int.

7 years agoipc_msg: change size types from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 01:11:24 +0000 (01:11 +0000)]
ipc_msg: change size types from unsigned long to kernel_ureg_t

* ipc_msg.c (tprint_msgsnd): Change count argument type
from unsigned long to kernel_ureg_t.  Change flags argument type
from unsigned long to unsigned int.
(tprint_msgrcv): Change the type of count and msgtyp arguments
from unsigned long to kernel_ureg_t.
(fetch_msgrcv_args): Change *pair type from unsigned long
to kernel_ureg_t.
(SYS_FUNC(msgrcv)): Change pair type from unsigned long
to kernel_ureg_t.
* print_msgbuf.c (tprint_msgbuf): Change count argument type
from unsigned long to kernel_ureg_t.

7 years agodumpiov_upto: change size types from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 00:53:52 +0000 (00:53 +0000)]
dumpiov_upto: change size types from unsigned long to kernel_ureg_t

* defs.h (dumpiov_upto): Change data_size argument type
from unsigned long to kernel_ureg_t.
* util.c (dumpiov_upto): Change the type of data_size argument
and iov_len variable from unsigned long to kernel_ureg_t.

7 years agomsghdr: change cmsghdr size types from size_t to unsigned int
Dmitry V. Levin [Sun, 25 Dec 2016 00:30:28 +0000 (00:30 +0000)]
msghdr: change cmsghdr size types from size_t to unsigned int

As the kernel does not accept control messages longer than the value
of int sysctl_optmem_max kernel variable exported as
/proc/sys/net/core/optmem_max, we do not print them either.

Since unsigned int has enough room to contain any valid control message
size, change all internal cmsghdr size types from size_t
to unsigned int.

* msghdr.c (print_scm_rights, print_scm_creds, print_scm_security,
print_cmsg_ip_pktinfo, print_cmsg_uint, print_cmsg_uint8_t,
print_cmsg_ip_opts, print_cmsg_ip_recverr, print_cmsg_ip_origdstaddr,
cmsg_printer, print_cmsg_type_data): Change data_len argument type
from size_t to unsigned int.
(cmsg_socket_printers): Change min_len type from size_t to unsigned int.
(decode_msg_control): Change the type of in_control_len argument,
cmsg_len, and len variables from size_t to kernel_ureg_t.
Change the type of cmsg_size, control_len, and buf_len variables
from size_t to unsigned int.

7 years agomsghdr: change register based size types from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sun, 25 Dec 2016 00:20:30 +0000 (00:20 +0000)]
msghdr: change register based size types from unsigned long to kernel_ureg_t

* defs.h (dumpiov_in_msghdr): Change data_size argument type
from unsigned long to kernel_ureg_t.
* msghdr.h (print_struct_msghdr): Likewise.
* msghdr.c (print_struct_msghdr): Likewise.  Cast msghdr.msg_iovlen
and msghdr.msg_controllen to kernel_ureg_t instead of unsigned long.
(decode_msghdr, dumpiov_in_msghdr): Change data_size argument type
from unsigned long to kernel_ureg_t.
(SYS_FUNC(sendmsg)): Pass -1 instead of -1UL as data_size argument
to decode_msghdr.
* mmsghdr.c (print_struct_mmsghdr): Pass (kernel_ureg_t) -1 instead
of -1UL as data_size argument to print_struct_msghdr.
(dumpiov_in_mmsghdr): Cast msghdr.msg_iovlen to kernel_ureg_t instead
of unsigned long.
* syscall.c (dumpio): Pass -1 instead of -1UL as data_size argument
to dumpiov_in_msghdr

7 years agomq: remove redundant u_rval check
Dmitry V. Levin [Sat, 24 Dec 2016 23:20:22 +0000 (23:20 +0000)]
mq: remove redundant u_rval check

* mq.c (SYS_FUNC(mq_timedreceive)): Do not check for tcp->u_rval < 0,
syserror(tcp) is enough, and printstrn can handle len < 0 anyway.

7 years agoio: change size types from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sat, 24 Dec 2016 23:09:16 +0000 (23:09 +0000)]
io: change size types from unsigned long to kernel_ureg_t

* defs.h (tprint_iov_upto): Change the type of len and data_size
arguments from unsigned long to kernel_ureg_t.
(tprint_iov): Change the type of len argument from unsigned long
to kernel_ureg_t.
* io.c (print_iovec_config): Change data_size type from unsigned long
to kernel_ureg_t.
(print_iovec): Change the type of *iov, iov_buf, and len variables
from unsigned long to kernel_ureg_t.
(tprint_iov_upto): Change the type of len and data_size arguments, and
the type of iov variable from unsigned long to kernel_ureg_t.

7 years agomount: change flags type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sat, 24 Dec 2016 22:58:16 +0000 (22:58 +0000)]
mount: change flags type from unsigned long to kernel_ureg_t

* mount.c (SYS_FUNC(mount)): Change the type of flags from unsigned long
to kernel_ureg_t, use printflags64 instead of printflags_long
to print it.

7 years agomem: change mmap arguments type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sat, 24 Dec 2016 22:39:06 +0000 (22:39 +0000)]
mem: change mmap arguments type from unsigned long to kernel_ureg_t

* mem.c (print_mmap): Change the type of len, prot, and flags
from unsigned long to kernel_ureg_t.  Use printflags64 instead
of printflags_long.  Use printxval64 instead of printxval_long.
(SYS_FUNC(old_mmap)): Check for current_klongsize instead
of [AARCH64 || X86_64] to take X32 into account.
(SYS_FUNC(mremap)): Use printflags64 instead of printflags_long.
(SYS_FUNC(remap_file_pages)): Change the type of size, prot, pgoff, and
flags from unsigned long to kernel_ureg_t.  Use printflags64 instead
of printflags_long.  Use printxval64 instead of printxval_long.
[POWERPC] (SYS_FUNC(subpage_prot)): Change the type of len and nmemb
from unsigned long to kernel_ureg_t.

7 years agonuma: change size arguments type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sat, 24 Dec 2016 22:12:16 +0000 (22:12 +0000)]
numa: change size arguments type from unsigned long to kernel_ureg_t

* numa.c (print_node, print_addr): Add kernel_ureg_t support.
(print_nodemask): Change type of maxnodes argument from unsigned long
to kernel_ureg_t.
(SYS_FUNC(move_pages)): Change npages type from unsigned long
to kernel_ureg_t.  Change buf type from long to kernel_ureg_t.

7 years agoprint_sigset_addr_len: change len argument type from long to kernel_ureg_t
Dmitry V. Levin [Sat, 24 Dec 2016 21:50:37 +0000 (21:50 +0000)]
print_sigset_addr_len: change len argument type from long to kernel_ureg_t

* defs.h (print_sigset_addr_len): Change len argument type from long
to kernel_ureg_t.
* signal.c (print_sigset_addr_len_limit, print_sigset_addr_len): Likewise.

7 years agoprocess_vm: change size arguments type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sat, 24 Dec 2016 21:31:20 +0000 (21:31 +0000)]
process_vm: change size arguments type from unsigned long to kernel_ureg_t

* process_vm.c (SYS_FUNC(process_vm_readv),
SYS_FUNC(process_vm_writev)): Change the type of local_iovcnt,
remote_iovcnt, and flags from unsigned long to kernel_ureg_t.

7 years agoprintstr*: change len argument type from long to kernel_ureg_t
Dmitry V. Levin [Sat, 24 Dec 2016 19:24:37 +0000 (19:24 +0000)]
printstr*: change len argument type from long to kernel_ureg_t

* defs.h (printstr_ex, printstrn): Change len argument type from long
to kernel_ureg_t.
* util.c (printstr_ex): Likewise.

7 years agoxattr: change size arguments type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Sat, 24 Dec 2016 19:20:25 +0000 (19:20 +0000)]
xattr: change size arguments type from unsigned long to kernel_ureg_t

* xattr.c (print_xattr_val): Change type of insize and size arguments
from unsigned long to kernel_ureg_t.
(print_xattr_list): Change type of size argument from unsigned long
to kernel_ureg_t.

7 years agoprintstr_ex: fix decoding of non-NUL-terminated strings when len == -1
Dmitry V. Levin [Sat, 24 Dec 2016 17:35:40 +0000 (17:35 +0000)]
printstr_ex: fix decoding of non-NUL-terminated strings when len == -1

Do not treat len == -1 in any special way.  All users who need the
string to be handled as a NUL-terminated string set QUOTE_0_TERMINATED
bit in user_style flags already.

* util.c (printstr_ex): Remove (len == -1) check.
* tests/printstr.c: New file.
* tests/printstr.test: New test.
* tests/.gitignore: Add printstr.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add printstr.test.

7 years agoFix decoding of sethostname syscall
Dmitry V. Levin [Sat, 24 Dec 2016 16:23:45 +0000 (16:23 +0000)]
Fix decoding of sethostname syscall

The second argument of sethostname syscall is not an unsigned long but
unsigned int.  The kernel does not look at the string argument when
the length argument is too long.

* hostname.c [HAVE_LINUX_UTSNAME_H]: Include <linux/utsname.h>.
[!__NEW_UTS_LEN] (__NEW_UTS_LEN): Define.
(SYS_FUNC(sethostname)): Treat the second argument as unsigned int.
Print the first argument as a pointer when the second argument exceeds
__NEW_UTS_LEN.
* tests/sethostname.c [HAVE_LINUX_UTSNAME_H]: Include <linux/utsname.h>.
[!__NEW_UTS_LEN] (__NEW_UTS_LEN): Define.
(main): Use it.  Check that the second argument of sethostname
is handled as unsigned int.  Check that the first argument is printed
as a pointer when the second argument exceeds __NEW_UTS_LEN.

7 years agotests: add F8ILL_KULONG_* and f8ill_ptr_to_kulong to tests.h
Dmitry V. Levin [Fri, 23 Dec 2016 18:44:37 +0000 (18:44 +0000)]
tests: add F8ILL_KULONG_* and f8ill_ptr_to_kulong to tests.h

* tests/tests.h (F8ILL_KULONG_SUPPORTED, F8ILL_KULONG_MASK): New macros.
(f8ill_ptr_to_kulong): New static inline function.

7 years agoprintstr: rename to printstrn, add printstr as a thin wrapper
Dmitry V. Levin [Tue, 20 Dec 2016 16:43:26 +0000 (16:43 +0000)]
printstr: rename to printstrn, add printstr as a thin wrapper

As about half of all printstr uses cases are invocations with the last
argument set to -1, create a dedicated function for this use case.

* defs.h (printstr): Rename to printstrn.  All callers updated.
(printstr): New static inline function.  All callers updated.

7 years agoprocess: change ptrace arguments type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Fri, 23 Dec 2016 23:08:45 +0000 (23:08 +0000)]
process: change ptrace arguments type from unsigned long to kernel_ureg_t

(SYS_FUNC(ptrace)): Change type of request and data arguments
from unsigned long to kernel_ureg_t.

7 years agoprocess: change tracee address type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Fri, 23 Dec 2016 23:02:21 +0000 (23:02 +0000)]
process: change tracee address type from unsigned long to kernel_ureg_t

* process.c (print_user_offset_addr): Change address argument type
from unsigned long to kernel_ureg_t.
(SYS_FUNC(ptrace)): Change addr variable type from unsigned long
to kernel_ureg_t.

7 years agonet: change address argument type from long to kernel_ureg_t
Dmitry V. Levin [Fri, 23 Dec 2016 10:50:10 +0000 (10:50 +0000)]
net: change address argument type from long to kernel_ureg_t

* net.c (decode_sockbuf, decode_pair_fd, print_linger, print_ucred,
print_tpacket_stats, print_icmp_filter, print_getsockopt, print_mreq,
print_mreq6, print_group_req, print_tpacket_req, print_packet_mreq,
print_setsockopt): Change address argument type from long
to kernel_ureg_t.

7 years agoprint_mq_attr: change address argument type from long to kernel_ureg_t
Dmitry V. Levin [Fri, 23 Dec 2016 01:21:34 +0000 (01:21 +0000)]
print_mq_attr: change address argument type from long to kernel_ureg_t

* print_mq_attr.c (printmqattr): Change address argument type from long
to kernel_ureg_t.

7 years agoipc_*: change address argument type from long to kernel_ureg_t
Dmitry V. Levin [Fri, 23 Dec 2016 01:05:06 +0000 (01:05 +0000)]
ipc_*: change address argument type from long to kernel_ureg_t

* ipc_msg.c (tprint_msgsnd, tprint_msgrcv, fetch_msgrcv_args): Change
address argument type from long to kernel_ureg_t.
* ipc_msgctl.c (print_msqid_ds): Likewise.
* ipc_sem.c (tprint_sembuf_array): Likewise.
* ipc_shmctl.c (print_shmid_ds): Likewise.

7 years agoprint_msgbuf: change address argument type from long to kernel_ureg_t
Dmitry V. Levin [Fri, 23 Dec 2016 00:55:57 +0000 (00:55 +0000)]
print_msgbuf: change address argument type from long to kernel_ureg_t

* print_msgbuf.c (tprint_msgbuf): Change address argument type
from long to kernel_ureg_t.

7 years agodesc: change tracee address type from long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 23:23:55 +0000 (23:23 +0000)]
desc: change tracee address type from long to kernel_ureg_t

* desc.c (decode_select): Rename arg to addr, change its type
from long to kernel_ureg_t.

7 years agouid: change address argument type from long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:52:39 +0000 (20:52 +0000)]
uid: change address argument type from long to kernel_ureg_t

* uid.c (get_print_uid): Change address argument type
from long to kernel_ureg_t.

7 years agotime: change address argument type from long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:51:33 +0000 (20:51 +0000)]
time: change address argument type from long to kernel_ureg_t

* time.c (print_timezone, do_adjtimex): Change address argument type
from long to kernel_ureg_t.

7 years agosched: change address argument type from long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:47:39 +0000 (20:47 +0000)]
sched: change address argument type from long to kernel_ureg_t

* sched.c (print_sched_attr): Change address argument type
from long to kernel_ureg_t.

7 years agoprintsiginfo: change address argument type from long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:44:06 +0000 (20:44 +0000)]
printsiginfo: change address argument type from long to kernel_ureg_t

* printsiginfo.c (printsiginfo_at): Change address argument type
from long to kernel_ureg_t.

7 years agoprint_timex: change address argument type from long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:42:50 +0000 (20:42 +0000)]
print_timex: change address argument type from long to kernel_ureg_t

* print_timex.c (print_timex): Change address argument type
from long to kernel_ureg_t.

7 years agoprint_sigevent: change address argument type from long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 17:11:53 +0000 (17:11 +0000)]
print_sigevent: change address argument type from long to kernel_ureg_t

* print_sigevent.c (print_sigevent): Change address argument type
from long to kernel_ureg_t.

7 years agopoll: change address argument type from long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 16:56:14 +0000 (16:56 +0000)]
poll: change address argument type from long to kernel_ureg_t

* poll.c (decode_poll_exiting): Change tracee address argument type
from long to kernel_ureg_t.