]> granicus.if.org Git - strace/log
strace
7 years agoterm: do not abort decoding in case of non-verbose output
Eugene Syromyatnikov [Sun, 1 Jan 2017 18:46:42 +0000 (21:46 +0300)]
term: do not abort decoding in case of non-verbose output

The case of unset verbose is handled by umoven_or_printaddr, moreover,
exiting at this point is plain wrong and leads to last argument not
being printed while it should be.

* term.c (decode_termios, decode_termio, decode_winsize, decode_ttysize,
decode_modem_flags): Do not check verbose flags explicitly and do not
exit early if it is not set.

7 years agotests: skip fault injection tests on hppa if the kernel is too old
Dmitry V. Levin [Thu, 5 Jan 2017 20:46:48 +0000 (20:46 +0000)]
tests: skip fault injection tests on hppa if the kernel is too old

* tests/fault_injection.sh: Add the minimal kernel version for hppa.

7 years agotests: skip readahead.test on MIPS n64 when built with glibc < 2.25
Dmitry V. Levin [Thu, 5 Jan 2017 18:20:57 +0000 (18:20 +0000)]
tests: skip readahead.test on MIPS n64 when built with glibc < 2.25

Due to a bug in glibc readahead syscall wrapper on MIPS n64,
this wrapper cannot be used in readahead.test.

* tests/readahead.c [HAVE_READAHEAD && LINUX_MIPSN64 && glibc < 2.25]:
Undefine HAVE_READAHEAD.

Reported-by: James Cowgill <james410@cowgill.org.uk>
7 years agotests: replace init_magic with fill_memory
Dmitry V. Levin [Thu, 5 Jan 2017 01:34:24 +0000 (01:34 +0000)]
tests: replace init_magic with fill_memory

Use the same fill_memory/fill_memory_ex interface in all affected tests.

* tests/ioctl_block.c (init_magic): Remove.
(main): Replace init_magic with fill_memory.
* tests/ioctl_evdev.c: Likewise.
* tests/ioctl_v4l2.c: Likewise.
* tests/ioctl_mtd.c (magic, init_magic): Remove.
(main): Replace init_magic with fill_memory.
* tests/ioctl_rtc.c: Likewise.

7 years agotests: rewrite ioctl_v4l2 test without reliance on init_magic
Dmitry V. Levin [Thu, 5 Jan 2017 01:34:24 +0000 (01:34 +0000)]
tests: rewrite ioctl_v4l2 test without reliance on init_magic

* tests/ioctl_v4l2.c (cc0, cc1, cc2, cc3, fourcc): New macros.
(main): Use them.  Rewrite expected output without assumptions
on any particular magic data.

7 years agotests: remove redundant casts in fill_memory{,_ex} invocations
Dmitry V. Levin [Wed, 4 Jan 2017 22:17:26 +0000 (22:17 +0000)]
tests: remove redundant casts in fill_memory{,_ex} invocations

* tests/ioctl_loop.c (main): Remove redundant casts of fill_memory
first argument.
* tests/kexec_load.c (main): Likewise.
* tests/perf_event_open.c (main): Likewise.
* tests/quotactl.c (main): Likewise.
* tests/mq_sendrecv.c (main): Remove redundant casts of fill_memory_ex
first argument.
* tests/quotactl-xfs.c (main): Likewise.

7 years agotests: change the type of fill_memory{,_ex} first argument to void *
Dmitry V. Levin [Wed, 4 Jan 2017 22:08:32 +0000 (22:08 +0000)]
tests: change the type of fill_memory{,_ex} first argument to void *

As these functions behave like memset, it's more convenient to have
the first argument of type void * like memset.

* tests/fill_memory.c (fill_memory, fill_memory_ex): Change the type
of first argument from "char *" to "void *".
* tests/tests.h (fill_memory, fill_memory_ex): Likewise.

7 years agotests: check non-verbose decoding of LOOP_* ioctls
Eugene Syromyatnikov [Sun, 1 Jan 2017 19:43:09 +0000 (22:43 +0300)]
tests: check non-verbose decoding of LOOP_* ioctls

* tests/ioctl_loop-nv.c: New file.
* tests/ioctl_loop-nv.test: New test.
* tests/ioctl_loop.c [!ABBREV] (ABBREV): Define to 0.
(print_loop_info, print_loop_info64): Handle [ABBREV != 0] case.
* tests/.gitignore: Add ioctl_loop-nv.
* tests/Makefile.am (check_PROGRAMS): Likewise.

7 years agotests: add more checks of LOOP_* ioctls decoding
Eugene Syromyatnikov [Sun, 1 Jan 2017 19:29:56 +0000 (22:29 +0300)]
tests: add more checks of LOOP_* ioctls decoding

* tests/ioctl_loop.c: Include <linux/ioctl.h>.
(magic, lmagic): Move static constants ...
(main): ... here.  Change types of magic constants to kernel_ulong_t.
Add more checks.

7 years agotests: check decoding of LOOP_* ioctls
JingPiao Chen [Tue, 27 Dec 2016 03:43:30 +0000 (11:43 +0800)]
tests: check decoding of LOOP_* ioctls

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

Co-authored-by: Eugene Syromyatnikov <evgsyr@gmail.com>
7 years agoDrop vsprintf.c
Dmitry V. Levin [Wed, 4 Jan 2017 13:22:19 +0000 (13:22 +0000)]
Drop vsprintf.c

Drop custom vfprintf implementation that was disabled by default.
Apparently nobody tests strace with this vfprintf enabled, otherwise
multiple uses of format specifiers not supported by this custom vfprintf
would not left unnoticed.

The GNU C library is not the only libc available, so those who want
faster implementations of libc functions are encouraged to try building
strace with other libc implementations.

* vsprintf.c: Remove.
* Makefile.am (strace_SOURCES): Remove vsprintf.c.
* defs.h (USE_CUSTOM_PRINTF, strace_vfprintf): Remove.
* strace.c (tprintf): Replace strace_vfprintf with vfprintf.

7 years agoloop: remove unnecessary verbose check
Eugene Syromyatnikov [Sun, 1 Jan 2017 19:40:34 +0000 (22:40 +0300)]
loop: remove unnecessary verbose check

The verbose flag is responsible for dereferencing of addresses, and it
is perfectly handled by umove_or_printaddr; moreover, this early exit
leads to incorrect formatting of last argument.

* loop.c (loop_ioctl): Do not check verbose flag explicitly and do not
exit early if it is not set.

7 years agoloop: fix lo_encrypt_key field output
Eugene Syromyatnikov [Sun, 1 Jan 2017 19:26:30 +0000 (22:26 +0300)]
loop: fix lo_encrypt_key field output

lo_encrypt_key is a sized string with its size specified by
lo_encrypt_key_size field, so take lo_encrypt_key_size into account.

* loop.c (decode_loop_info, decode_loop_info64): Use minimum of
LO_KEY_SIZE and lo_encrypt_key_size field value as lo_encrypt_key size.

7 years agoloop: print lo_encrypt_key_size field of struct loop_info as unsigned
Eugene Syromyatnikov [Sun, 1 Jan 2017 19:19:18 +0000 (22:19 +0300)]
loop: print lo_encrypt_key_size field of struct loop_info as unsigned

It is converted to an unsigned value in kernel (see loop_info64_from_old
in drivers/block/loop.c), so let's print it that way despite its type.

* loop.c (decode_loop_info): Print lo_encrypt_key_size as an uint32_t
value.

7 years agotests: add more checks of unknown ioctl command formatting
Eugene Syromyatnikov [Sun, 1 Jan 2017 18:59:12 +0000 (21:59 +0300)]
tests: add more checks of unknown ioctl command formatting

* tests/ioctl.c (main): Additional check for unknown ioctl command
decoding.
* tests/ioctl_evdev.c (main): Likewise.
* tests/ioctl_dm.c: Include <linux/ioctl.h> for _IOC_SIZE and _IOC_NR.
(main) <dummy_dm_ioctl1, dummy_dm_ioctl2, dummy_dm_arg>: New constants.
Add more checks for unknown command formatting.

7 years agoioctl: do not print explicit 0x prefix and do not specify minimum width
Eugene Syromyatnikov [Sun, 1 Jan 2017 18:53:48 +0000 (21:53 +0300)]
ioctl: do not print explicit 0x prefix and do not specify minimum width

Specifying output width for size argument is rather misleading - it can
be up to 14 bits in size.  The use of explicit "0x" prefix is
discouraged because 0x0 looks ugly.  Usage of width specification along
with alternate form flag leads to inconsistent output for 0.
Let's use just plain %#x qualifiers instead.

* ioctl.c (ioctl_print_code): Change printf qualifiers for ioctl command
type, number and size to "%#x".
* tests/ioctl.c (main): Update expected test output.
* tests/ioctl_dm.c (main): Likewise.
* tests/ioctl_evdev.c (main): Likewise.

7 years agoloop: fix printing of the reserved field array items
Eugene Syromyatnikov [Sun, 1 Jan 2017 18:13:07 +0000 (21:13 +0300)]
loop: fix printing of the reserved field array items

They are of char type, so "hh" length modifier should be used (otherwise
they are printed incorrectly as they are sign extended implicitly when
passed as printf arguments in case char is a signed type which is true
for most compilers).

* loop.c (decode_loop_info): Change "%#x" printf qualifier to "%#hhx"
in printing routine for array elements of the "reserved" field of
loop_info structure.

7 years agotests: check ioctl(SIOCGIFCONF) decoding
Eugene Syromyatnikov [Sat, 24 Dec 2016 16:18:51 +0000 (19:18 +0300)]
tests: check ioctl(SIOCGIFCONF) decoding

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

7 years agodm.c: add copyright notice
Eugene Syromyatnikov [Mon, 26 Dec 2016 12:24:45 +0000 (15:24 +0300)]
dm.c: add copyright notice

7 years agoAdd scno.h and syscallent.i to .gitignore files
Dmitry V. Levin [Wed, 4 Jan 2017 11:29:32 +0000 (11:29 +0000)]
Add scno.h and syscallent.i to .gitignore files

* .gitignore: Add /scno.h and /syscallent.i.
* tests/.gitignore: Add scno.h and syscallent.i.

7 years agotests/.gitignore: add generated files that should be ignored
JingPiao Chen [Tue, 27 Dec 2016 03:43:28 +0000 (11:43 +0800)]
tests/.gitignore: add generated files that should be ignored

* tests/.gitignore: Replace addkey with add_key, add attach-f-p-cmd.

7 years agoRemove checks of __NR_* availability from strace source code
Dmitry V. Levin [Tue, 3 Jan 2017 13:46:26 +0000 (13:46 +0000)]
Remove checks of __NR_* availability from strace source code

* strace.c: Remove __NR_tkill checks, assume it is always defined.
* util.c: Remove __NR_process_vm_readv checks and fallback definitions,
assume it is always defined.

7 years agoInclude "scno.h" in files that check __NR_* constants
Dmitry V. Levin [Mon, 2 Jan 2017 22:37:57 +0000 (22:37 +0000)]
Include "scno.h" in files that check __NR_* constants

* strace.c: Include "scno.h".
* util.c: Likewise.

7 years agoGenerate scno.h for use during the build of strace itself
Dmitry V. Levin [Mon, 2 Jan 2017 21:27:42 +0000 (21:27 +0000)]
Generate scno.h for use during the build of strace itself

* Makefile.am: Include scno.am.
($(strace_OBJECTS)): New rule.

7 years agoGenerate scno.h without invoking a generated executable helper
Dmitry V. Levin [Sun, 1 Jan 2017 20:59:11 +0000 (20:59 +0000)]
Generate scno.h without invoking a generated executable helper

Generate scno.h using only those tools that are available for cross
build.  This allows to use scno.h during the build of strace itself.

* scno.am: New file.
* scno.head: New file.
* Makefile.am (EXTRA_DIST): Add it.
* tests/generate_scno.c: Remove.
* tests/.gitignore: Remove generate_scno.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(CLEANFILES): Remove scno.h.
(scno.h, $(scno_dependants)): Remove rules.
(scno_dependants): Remove.
($(objects)): New rule.
Include ../scno.am.

7 years agoUpdate all publicly shown copyright year number ranges
Dmitry V. Levin [Sun, 1 Jan 2017 11:33:40 +0000 (11:33 +0000)]
Update all publicly shown copyright year number ranges

* COPYING: Update copyright year number range.
* configure.ac: Likewise.
* strace.c: Likewise.
* tests/strace-V.test: Use the current year for the check.

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.