Commit Graph

4654 Commits

Author SHA1 Message Date
Eugene Syromyatnikov
d44a77ca58 process_vm: print pid argument as int
* process_vm.c (SYS_FUNC(process_vm_readv),
SYS_FUNC(process_vm_writev)): Change conversion specifier for pid
argument from "%ld" to "%d".
2016-10-28 18:40:11 +00:00
Eugene Syromyatnikov
44ffbf0adc process_vm: remove syserror check for iovec printing
This check had been done by print_array inside tprint_iov anyway.

* process_vm.c (SYS_FUNC(process_vm_readv)): Use tprint_iov_upto for
printing local_iov; do not check for syserror, provide decode_iov
parameter to tprint_iov{,_upto} based on its value instead.
2016-10-28 18:40:11 +00:00
Eugene Syromyatnikov
030b61c92f io: use umoven_or_printaddr_ignore_syserror as umove function in tprint_iov_upto
This enables printing of iovec arrays even in case of failed syscall
(failed syscall doesn't mean that iovec itself is inaccessible and
useless).  One caveat here is that we should explicitly provide proper
IOV_DECODE_* value based on syserror value in case printing is performed
on exiting; we can't simply override it to IOV_DECODE_ADDR on exiting
when syserror is up, since this may be called by code which tries to
print iovec containing local data, which should be perfectly accessible
(on the other hand, there are no cases of such behaviour at the moment).

Since iovecs themselves are printed even if syscall has failed now,
preadv test is updated to reflect this.  It is notable, though, that this
is the only place where this case is checked.

* io.c (tprint_iov_upto): Specify umoven_or_printaddr_ignore_syserror
instead of umoven_or_printaddr as umoven_func parameter.
(SYS_FUNC(readv), do_preadv): Specify decode_iov parameter value
based on syserror(tcp) value.
* scsi.c: (print_sg_io_v3_res, print_sg_io_v4_res): Likewise.
* tests/preadv.c: Update expected output for the case when preadv
with singe-item iovec failed.
2016-10-28 18:40:11 +00:00
Eugene Syromyatnikov
a980c9ebbd Move umoven_or_printaddr_ignore_syserror to util.c
* defs.h (umoven_or_printaddr_ignore_syserror): New prototype.
* v4l2.c (umoven_or_printaddr_ignore_syserror): Move ...
* util.c: ... here.
2016-10-28 18:40:10 +00:00
Eugene Syromyatnikov
b0c4a35ac1 v4l2: check for verbose flag in umoven_or_printaddr_ignore_syserror
This change makes behaviour of umoven_or_printaddr_ignore_syserror in
line with umoven_or_printaddr when verbose flag is disabled.

* v4l2.c (umoven_or_printaddr_ignore_syserror): Simply call printaddr
when verbose flag is unset.
2016-10-28 18:40:10 +00:00
Eugene Syromyatnikov
a49ba91595 tests: check decoding of kcmp syscall
* tests/kcmp.c: New file.
* tests/kcmp.test: New test.
* tests/.gitignore: Add kcmp.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add kcmp.test.
2016-10-28 18:40:10 +00:00
63c27873b6 kcmp: print index parameters of unknown commands as kernel_ulong_t
* lookup_dcookie.c (SYS_FUNC(kcmp)): Use getarg_ull to retrieve idx1
and idx2, print them using %#llx format in case of unknown command.
2016-10-28 18:40:10 +00:00
Eugene Syromyatnikov
8b0f48ee06 tests: check decoding of inotify family syscalls
* tests/inotify.c: New file.
* tests/inotify_init1.c: Likewise.
* tests/inotify.test: New test.
* tests/inotify_init1.test: Likewise.
* tests/.gitignore: Add inotify and inotify_init1.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add inotify.test and inotify_init1.test.
2016-10-27 23:31:44 +00:00
Eugene Syromyatnikov
3f86e786f1 xlat: use IN_* prefix for inotify_init1 flag constants
* xlat/inotify_init_flags.in: Replace O_* prefix with IN_* prefix for
O_NONBLOCK and O_CLOEXEC constants, provide fallback definitions.
2016-10-27 23:31:44 +00:00
Eugene Syromyatnikov
ebdf6914f1 tests: check decoding of lookup_dcookie syscall
* tests/lookup_dcookie.c: New file.
* tests/lookup_dcookie.test: New test.
* tests/.gitignore: Add lookup_dcookie.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add lookup_dcookie.test.
2016-10-27 23:31:42 +00:00
Eugene Syromyatnikov
2119f8d6b0 lookup_dcookie: print len parameter as kernel_ulong_t
It is size_t and without compat on x32/n32.

* lookup_dcookie.c (SYS_FUNC(lookup_dcookie)): Change conversion
specifier from "%lu" to "%llu", use getarg_ull for len argument
retrieval.
2016-10-27 21:44:58 +00:00
Eugene Syromyatnikov
6e6c11d9dd defs.h: add offsetofend macro
Analogous to offsetof but returns structure offset after the specified
field.  Useful for checking whether specific field is present in obtained
data or specifying amount of data to copy based on the (last) field needed.

* defs.h (offsetofend): New macro.
2016-10-26 04:20:06 +03:00
Eugene Syromyatnikov
d212c95b84 tests: move ARG_STR and similar macros to tests.h
* tests/add_key.c (_STR, ARG_STR): Move ...
* tests/tests.h: ... here.
(ARG_ULL_STR): New macro.
* tests/keyctl.c (ARG_STR): Remove.
* tests/quotactl.h (ARG_STR): Likewise.
* tests/request_key.c (ARG_STR): Likewise.
2016-10-26 04:18:34 +03:00
Eugene Syromyatnikov
f0fb4e9de4 tests: move LL_PAIR and LL_VAL_TO_PAIR macros to tests.h
* tests/fadvise.h (LL_PAIR, LL_VAL_TO_PAIR): Move ...
* tests/tests.h: ... here.
2016-10-26 04:13:24 +03:00
Eugene Syromyatnikov
eabfa5e9e0 tests: check decoding of ioprio_get and ioprio_set syscalls
* tests/ioprio.c: New file.
* tests/ioprio.test: New test.
* tests/.gitignore: Add ioprio.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add ioprio.test.
2016-10-26 01:06:09 +00:00
Eugene Syromyatnikov
79fb93a7c6 xlat: provide fallback definitions for CLOCK_* constants
Since new values have been added gradually over various kernel versions,
it's better to define them explicitly in order to avoid situations when
strace built with older kernel headers cannot decode some recently
defined values.

* xlat/clocknames.in: Add values for constants.
2016-10-26 01:06:09 +00:00
Eugene Syromyatnikov
06934669ea tests: move fill_memory and fill_memory_ex into a separate file
* tests/fill_memory.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
* tests/quotactl.h (fill_memory, fill_memory_ex): Move to fill_memory.c.
* tests/tests.h (fill_memory, fill_memory_ex): New prototypes.
2016-10-26 01:06:09 +00:00
Eugene Syromyatnikov
ab648c804c tests: add period parameter to fill_memory_ex
* tests/quotactl.h (fill_memory_ex): Add period parameter,
use it as a divisor in non-constant part of value.
(fill_memory): Specify period of 0x80 to fill_memory_ex call.
* tests/quotactl-xfs.c (main): Likewise.
2016-10-26 01:06:09 +00:00
e0916b6dc3 Post-release administrivia
* NEWS: Add a header line for the next release.
* debian/changelog.in: Add a changelog entry for 4.14-1.
* strace.spec.in: Likewise.
2016-10-05 06:19:41 +00:00
e1fec334db Prepare for 4.14 release
* NEWS: Update for 4.14 release.
2016-10-04 18:19:20 +00:00
c1a0b67db5 Generate SEN numbers in a locale independent order
* generate_sen.sh: Sort SEN numbers using C collation rules.
2016-10-04 08:19:27 +00:00
7082acc0e3 Assume that offsetof is provided by stddef.h
According to C89, <stddef.h> shall define offsetof macro.

* defs.h: Include <stddef.h> unconditionally.
[!offsetof]: Remove.
2016-10-04 00:16:44 +00:00
Eugene Syromyatnikov
7bce0e9fd4 tests: check decoding of add_key, keyctl, and request_key syscalls
* tests/add_key.c: New file.
* tests/keyctl.c: Likewise.
* tests/request_key.c: Likewise.
* tests/add_key.test: New test.
* tests/keyctl.test: Likewise.
* tests/request_key.test: Likewise.
* tests/.gitignore: Add add_key, keyctl, and request_key.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add add_key.test, keyctl.test, and request_key.test.
2016-10-03 23:50:57 +00:00
Eugene Syromyatnikov
27aaa29d73 keyctl: use kernel_ulong_t and getarg_ull instead of long
This potentially fixes keyctl decoder for x32 personality.

* keyctl.c (keyctl_update_key, keyctl_read_key, keyctl_instantiate_key,
keyctl_instantiate_key_iov, keyctl_dh_compute): Change addr and len
arguments to kernel_ulong_t.  Print len using %llu format.
(keyctl_keyring_search): Change addr1 and addr2 arguments
to kernel_ulong_t.
(print_dh_params): Change addr argument to kernel_ulong_t.
(SYS_FUNC(keyctl)): Retrieve arguments via getarg_ull, pass them
to the appropriate handlers.
2016-10-03 23:48:48 +00:00
Eugene Syromyatnikov
66db159f7e keyctl: fix parameter signedness
* keyctl.c (keyctl_update_key): Change addr and len arguments
to unsigned.
(keyctl_read_key): Likewise.
(keyctl_instantiate_key): Likewise.
(keyctl_instantiate_key_iov): Likewise.
(keyctl_dh_compute): Likewise.
(keyctl_keyring_search): Change addr1 and addr2 arguments to unsigned.
(keyctl_chown_key): Change user and group arguments to unsigned.
(keyctl_get_persistent): Change uid argument to unsigned.
2016-10-03 21:50:45 +00:00
Eugene Syromyatnikov
9f294b39f5 keyctl: use printstr_ex for printing out buffer
keyctl_read_key had subtle bug by treating out buffer in KEYCTL_READ
as NUL-terminated, which is not true.  We fix it by adding parameter to
keyctl_read_key signalising whether buffer is NUL-terminated and using
printstr_ex for printing (expectedly) NUL-terminated strings.

* keyctl.c (keyctl_read_key): Add has_nul parameter.  Do not use -1 as
string len.  Use printstr_ex for buffer output with user style depending
on has_nul value.
(SYS_FUNC(keyctl)): Specify has_nul parameter to keyctl_read_key
by comparing cmd value with KEYCTL_READ.
2016-10-03 21:50:45 +00:00
Eugene Syromyatnikov
ee70a1baac Add printstr_ex which allows for providing user quotation style
This is useful for providing QUOTE_OMIT_TRAILING_0 and maybe other
flags.

* defs.h (printstr_ex): New prototype.
(printstr): Change to a wrapper around printstr_ex with zero user style.
* util.c (printstr): Rename to ...
(printstr_ex) ... new function, add user_style argument which is or'ed
with computed style.
2016-10-03 21:50:33 +00:00
Eugene Syromyatnikov
5cf68f97d5 util: add quote_string flag signalising that string is NUL-terminated
It is useful in cases strings with size provided are expected to be
NUL-terminated but are not trustworthy enough to call just plain
printstr(str, -1).

* defs.h (QUOTE_OMIT_TRAILING_0): New constant definition.
* util.c (string_quote): Swallow terminating NUL if
QUOTE_OMIT_TRAILING_0 is set.
2016-10-03 19:28:15 +00:00
Eugene Syromyatnikov
04ec08ab62 keyctl: add support for KEYCTL_DH_COMPUTE
* keyctl.c (struct keyctl_dh_params): New structure.
(print_dh_params, keyctl_dh_compute): New functions.
(SYS_FUNC(keyctl)): Add support for KEYCTL_DH_COMPUTE cmd value.
2016-10-03 19:27:38 +00:00
820adffcd9 x86_64: fix is_negated_errno for x32 personality
* syscall.c (is_negated_errno) [X86_64]: Do not truncate kernel_ulong_t
to uint32_t for x32 personality.
2016-10-03 15:51:49 +00:00
7b6d66f215 tests: fix another regression in qual_syscall.test
* tests/qual_syscall.test: Fix pattern_nonabbrev_verbose pattern.
(check_output_mismatch): Print the pattern that triggered match failure.
2016-10-03 12:13:19 +00:00
4503da0816 Use err_name, print unrecognized errno values as numbers
* syscall.c (trace_syscall_exiting): Use err_name() instead
of open-coding it.  Print unrecognized errno values using %lu format
instead of ERRNO_%lu as the latter prodices an invalid constant.
2016-10-03 12:03:03 +00:00
Eugene Syromyatnikov
7211bdb982 keyctl: print errno name in KEYCTL_REJECT in case it is available
* keyctl.c (keyctl_reject_key): Get errno string via err_name
and print it if it is not NULL.
2016-10-03 12:03:03 +00:00
Eugene Syromyatnikov
6fdb10455a Add function for getting errno string
* defs.h (err_name): New prototype.
* syscall.c (err_name): New function.
2016-10-03 11:54:49 +00:00
ba63d8a166 struct tcb: change the type of u_error field from int to unsigned long
This is the type actually used for the error code on architectures
that use a dedicated register.

* defs.h (struct tcb): Change the type of u_error to unsigned long.
* syscall.c (trace_syscall_exiting): Change the type of u_error variable
to unsigned long, print it using %lu format, drop no longer needed
explicit cast to unsigned long.
(saved_u_error): Change type to unsigned long.
2016-10-03 11:48:55 +00:00
cce5aaef1e Use tprints instead of tprintf in a few more places
* btrfs.c (btrfs_print_qgroup_inherit, btrfs_print_tree_search,
btrfs_ioctl): Replace tprintf with tprints for printing strings without
format specifiers.
* net.c (print_group_req): Likewise.
* scsi.c (scsi_ioctl): Likewise.
* term.c (decode_termios, decode_termio): Likewise.
* userfaultfd.c (uffdio_ioctl): Likewise.
2016-10-02 19:19:28 +00:00
Eugene Syromyatnikov
7fa26e1712 keyctl: do not print comma for KEYCTL_SESSION_TO_PARENT command
Since this command doesn't have any additional arguments, the comma does
not needed.  Since this is the only command which lacks additional
arguments, it's better to add special case for it rather than add
printing of comma to all other commands.

* keyctl.c (SYS_FUNC(keyctl)): Add check for command not being
KEYCTL_SESSION_TO_PARENT when printing comma dividing cmd argument
from the rest.
2016-10-02 19:19:15 +00:00
Eugene Syromyatnikov
f5278a7d94 keyctl: use getarg_ull for printing generic arguments
Otherwise it is erroneous on x32, for example.

* keyctl.c (SYS_FUNC(keyctl)): Use "%#llx" conversion specifier
and getarg_ull for fallback argument printing.
2016-10-02 19:19:15 +00:00
Eugene Syromyatnikov
db098f9a3d keyctl: use printuid for printing UID/GID
UID/GID are unsigned except special -1 value (which is also special in
context of specific keyctl commands), so special printing function
should be used.

* keyctl.c (keyctl_chown_key, keyctl_get_persistent): Use printuid
instead of printf with "%d" conversion for printing UID/GID.
2016-10-02 19:19:15 +00:00
Eugene Syromyatnikov
f3228d3268 io: handle data_size of -1 as unlimited data in print_iovec
Otherwise it can be depleted and print_iovec starts printing empty
strings.

* io.c (print_iovec): Interpret c->data_size of -1 as unlimited data
and do not decrease it in this case.
2016-10-02 19:19:15 +00:00
e8f36ec0c5 tests: fix typo in qual_syscall.test
Fix test regression introduced by commit v4.13-225-g55334ef.

* tests/qual_syscall.test: Fix typo.
2016-10-01 14:27:00 +00:00
a606d3a74a Enhance -e abbrev=set, -e raw=set, and -e verbose=set
Enhance abbrev=, raw=, and verbose= to accept the same syntax as trace=.
For example, this allows such syntax as -e verbose=file.

* syscall.c (lookup_class): Define before qual_syscall.
(qualify): Move the loop based on lookup_class ...
(qual_syscall): ... here.
* tests/qual_syscall.test: Check it.
2016-09-30 13:43:48 +00:00
55334effed tests/qual_syscall.test: rewrite without ls
* tests/qual_syscall.test: Invoke ./umovestr instead of ls.
Update expected output.
2016-09-30 13:09:36 +00:00
Eugene Syromyatnikov
a2402cea20 tests: check decoding of fadvise64 and fadvise64_64 syscalls
* tests/fadvise.h: New file.
* tests/fadvise64.c: Likewise.
* tests/fadvise64_64.c: Likewise.
* tests/fadvise64.test: New test.
* tests/fadvise64_64.test: Likewise.
* tests/.gitignore: Add fadvise64 and fadvise64_64.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add fadvise64.test, fadvise64_64.test.
(EXTRA_DIST): Add fadvise.h.
2016-09-28 03:00:10 +00:00
54a4a1a918 mips o32: implement fetching the 7th subcall argument
* syscall.c [LINUX_MIPSO32] (decode_mips_subcall): Fetch the last
argument of 7-arg syscalls.
2016-09-28 03:00:10 +00:00
Eugene Syromyatnikov
1929c2216a x32: use proper decoder for fadvise64 syscall
fadvise_64_64 decoder used before this change prints different sign
of the "len" argument (loff_t vs size_t).

* linux/x32/syscallent.h (fadvise64): Replace SEN(fadvise64_64)
with SEN(fadvise64).
2016-09-28 03:00:10 +00:00
Eugene Syromyatnikov
2c871eb566 fadvise: use getarg_ull for obtaining len argument of fadvise64 syscall
Since its type is size_t, it is 64-bit wide on x32 and special care
should be taken in order to obtain it.

* fadvise.c (SYS_FUNC(fadvise64)): Use getarg_ull for obtaining value
of "len" syscall argument.
2016-09-28 03:00:10 +00:00
Eugene Syromyatnikov
b93991d381 util: add getarg_ll and getarg_ull functions
These allow retrieving specific argument in full taking into account
peculiarities of runtimes which employ tcp->ext_arg (e.g. x32).

* defs.h (getarg_ll, getarg_ull): New prototypes.
* util.c (getarg_ll, getarg_ull): New functions.
(printargs): Use getarg_ull.
2016-09-28 03:00:10 +00:00
Eugene Syromyatnikov
11f7093560 fadvise: change printing of len argument to unsigned in fadvise64 syscall
The kernel declares fadvise64 as
long sys_fadvise64(int fd, loff_t offset, size_t len, int advice);

* fadvise.c (SYS_FUNC(fadvise64)): Change conversion specifier from
"%ld" to "%lu" for printing len argument since kernel expects argument
of type size_t.
2016-09-28 03:00:10 +00:00
cfa1b17619 sh64, sparc64: use proper decoder for fadvise64_64 syscall
This change is no-op yet, but things will change when decoder
of fadvise64 syscall get fixed.

* linux/sh64/syscallent.h (fadvise64_64): Replace SEN(fadvise64)
with SEN(fadvise64_64).
* linux/sparc64/syscallent.h (fadvise64_64): Likewise.
2016-09-28 03:00:10 +00:00