4690 Commits

Author SHA1 Message Date
9c260b9e87 Provide a safe definition of O_ACCMODE
Some libcs e.g. musl are guilty of messing up with O_ACCMODE.

* open.c (O_ACCMODE): Redefine to 03.
2016-10-29 02:54:02 +03:00
Eugene Syromyatnikov
0277a64986 Implement dumping of mq_timedsend and mq_timedreceive syscalls
* syscall.c (dumpio): Add SEN_mq_timedreceive and SEN_mq_timedsend.
2016-10-29 02:54:02 +03:00
Eugene Syromyatnikov
2b50662498 mq: print msg_prio as a pointer, not as an immediate value
* mq.c (SYS_FUNC(mq_timedreceive)): Use printnum_int for printing
msg_prio argument.
2016-10-29 02:54:02 +03:00
Eugene Syromyatnikov
26690859f6 mq: print msg payload only in case of successful mq_timedreceive call
Also, use u_rval for determining message size.

* mq.c (SYS_FUNC(mq_timedreceive)): Check for syserror and non-negative
u_rval before calling printstr on msg_ptr argument, or use printaddr otherwise;
provide u_rval as string size.
2016-10-29 02:54:02 +03:00
Eugene Syromyatnikov
19bd947891 mq: Print msg_prio parameter as unsigned int in mq_timedsend
* mq.c (SYS_FUNC(mq_timedsend)): Change conversion specifier from "%ld"
to "%u", cast argument value to unsigned int.
2016-10-29 02:54:02 +03:00
Eugene Syromyatnikov
3e22464ec7 mq: Properly print mq_flags field
mq_flags field of struct mq_attr can contain only O_NONBLOCK flag (other
flags are treated as invalid by mq_getsetattr). Moreover, this field is
ignored by mq_open at all (O_NONBLOCK is set via oflag, not via attr
attribute).

* xlat/mq_attr_flags.in: New file.
* print_mq_attr.c: Include xlat/mq_attr_flags.h.
(printmqattr): New parameter, bool decode_flags; cast members of struct
mq_attr to long long type; use mq_attr_flags xlat for printing mq_flags;
print mq_flags as flags only in case decode_flags parameter is set
to true.
* mq.c (SYS_FUNC(mq_open)): Specify value of false for decode_flags
parameter of printmqattr call.
(SYS_FUNC(mq_getsetattr)): Specify value of true for decode_flags
parameter of printmqattr call.
* tests/mq.expected: Update expected output.
2016-10-29 02:54:02 +03:00
Eugene Syromyatnikov
0302a3186e mq: Print msg_len parameter as kernel_ulong_t
* mq.c (SYS_FUNC(mq_timedsend)): Change conversion specifier from "%lu"
to "%llu", use getarg_ull for obtaining msg_len parameter.
(SYS_FUNC(mq_timedreceive)): Likewise.
2016-10-29 02:54:02 +03:00
Eugene Syromyatnikov
56b7651212 print_mq_attr: fix typo
* print_mq_attr.c (printmqattr): Print field name "mq_curmsgs"
instead of "mq_curmsg".
* tests/mq.expected: Update expected output.
2016-10-29 02:54:02 +03:00
Eugene Syromyatnikov
34ccf12e07 mq: print mqdes parameter as int
It is defined as int in <linux/posix_types.h>.

* mq.c (SYS_FUNC(mq_timedsend)): Use "%d" conversion specifier instead
of "%ld" for printing mqdes (0th parameter), cast parameter value to
int.
(SYS_FUNC(mq_timedreceive)): Likewise.
(SYS_FUNC(mq_notify)): Likewise.
(SYS_FUNC(mq_getsetattr)): Likewise.
2016-10-29 02:54:02 +03:00
Eugene Syromyatnikov
0a37603ef6 mq: curly brackets usage fix
Use curly brackets for denoting blocks in both of if branches if they
are already used in at least one branch.
2016-10-29 02:54:02 +03:00
Eugene Syromyatnikov
9a4eb55465 tests: additional name_to_handle_at/open_by_handle_at checks
* tests/file_handle.c: Additional name_to_handle_at/open_by_handle_at
checks.
2016-10-29 02:54:02 +03:00
Eugene Syromyatnikov
ad7f4354d5 tests: require only presence of __NR_* macros for file_handle test
* tests/file_handle.c: replace fcntl.h include with asm/unistd.h.
[MAX_HANDLE_SZ]: change to defined __NR_name_to_handle_at
&& defined __NR_open_by_handle_at, add fcntl.h include
[!MAX_HANDLE_SZ]: Add definition of MAX_HANDLE_SZ and struct
file_handle.
(main): Change name_to_handle_at and open_by_handle_at calls to syscall.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
d6ee2bba25 tests: proper type conversion in keyctl test
* tests/keyctl.c (printarg): Add intermediate conversion of arg to uintptr_t
since kernel_ulong_t may be of different size.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
8e1f1e7a92 file_handle: use separate xlat for name_ta_handle_at flags
Since the only two flags supported are AT_SYMLINK_FOLLOW and
AT_EMPTY_PATH.

* xlat/name_to_handle_at_flags.in: New file.
* file_handle.c (SYS_FUNC(name_to_handle_at)): Use name_to_handle_at_flags
for printing flags parameter.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
88cac72e95 tests: check decoding of kexec_file_load and kexec_load syscalls
* tests/kexec_file_load.c: New file.
* tests/kexec_load.c: Likewise.
* tests/kexec_file_load.test: New test.
* tests/kexec_load.test: Likewise.
* tests/.gitignore: Add kexec_file_load and kexec_load.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add kexec_file_load.test and kexec_load.test.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
108d574c54 kexec: use widen_to_ulong since kexec_load has compat on x32/n32
Curiously, kexec_load uses compat on x32/n32, so its parameters should
be 4 bytes in size on these ABIs.

* kexec.c (SYS_FUNC(kexec_load)): Use widen_to_ulong for casting
parameters to proper size on x32/n32.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
920b4d5114 kexec: fix zeroing of higher bits of flags parameter in kexec_load
* kexec.c (SYS_FUNC(kexec_load)): Perform type conversion before
negation in order to properly negate higher bits of KEXEC_ARCH_MASK.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
41c468b26c kexec: add printing of struct kexec_segment field names
* kexec.c (print_seg): Print field names of the kexec_segment structure.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
5732d38e1a tests: check decoding of unshare syscall
* tests/unshare.c: New file.
* tests/unshare.test: New test.
* tests/.gitignore: Add unshare.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add unshare.test.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
0cffca31df clone: use kernel_ulong_t as type of flags parameter of unshare call
Kernel declares flags parameter as long and looks like x32 and n32
implement no compat for this call.

* clone.c (SYS_FUNC(unshare)): Use getarg_ull and printflags64 for
obtaining and parsing flags parameter.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
951f1b1163 clone: use separate flag list for unshare
Not all clone flags could be passed to unshare (see check_unshare_flags
function in kernel/fork.c).

* xlat/unshare_flags.in: New file.
* clone.c (SYS_FUNC(unshare)): Use unshare_flags for printing flags
parameter.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
3fa672fa7a tests: check decoding of setns syscall
* tests/setns.c: New file.
* tests/setns.test: New test.
* tests/.gitignore: Add setns.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add setns.test.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
7b0ae21f5c clone: use separate xlat for nstype parameter of setns syscall
nstype is not flag set but specific type value against which it is
compared in kernel (see kernel/nsproxy.c, SYSCALL_DEFINE2(setns, ...)).

* xlat/setns_types.in: New file.
* clone.c: Use printxval and setns_types for nstype parameter.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
aece0f417f tests: check non-verbose capget/capset output
* tests/caps-abbrev.awk: New file.
* tests/caps-abbrev.c: Likewise.
* tests/caps-abbrev.test: New test.
* tests/.gitignore: Add caps-abbrev.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add caps-abbrev.test.
(EXTRA_DIST): Add caps-abbrev.awk.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
f84b99b353 tests: additional capset decoder checks
* tests/caps.awk: Add patterns for additional checks.
* tests/caps.c: Implement additional checks.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
73d66c84d5 tests: check decoding of fanotify_init syscall
* tests/fanotify_init.c: New file.
* tests/fanotify_init.test: New test.
* tests/.gitignore: Add fanotify_init.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add fanotify_init.test.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
e3645be4d6 tests: some additional checks for fanotify_mark
* tests/fanotify_mark.c (do_call): New function.
(main): Use it.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
f3a326c85b tests: use sprintrc in tests/fanotify_mark.c
* tests/fanotify.c (main): Use sprintrc.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
3b31d33ada tests: check decoding of {init,finit,delete}_module syscalls
* tests/delete_module.c: New file.
* tests/finit_module.c: Likewise.
* tests/init_delete_module.h: Likewise.
* tests/init_module.c: Likewise.
* tests/delete_module.test: New test.
* tests/finit_module.test: Likewise.
* tests/init_module.test: Likewise.
* tests/.gitignore: Add delete_nodule, finit_module, and init_module.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add delete_module.test, finit_module.test,
and init_module.test.
(EXTRA_DIST): Add init_delete_module.h.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
dad07434a8 bjm: use getarg_ull for retrieving first two parameters of init_module syscall
As init_module has no compat wrapper, its first parameter is a pointer
and the second is length, they both have the same size as kernel_ulong_t
type.

* bjm.c (SYS_FUNC(init_module)): Obtain first two parameters using
getarg_ull, print address argument using printaddr_ull, print length
argument using "%llu" conversion specifier.
2016-10-29 02:54:01 +03:00
b61f3251c0 Add printaddr_ull, change printaddr into a thin wrapper around it
* defs.h (printaddr_ull): New prototype.
(printaddr): Change to a static inline wrapper around printaddr_ull.
* util.c (printaddr): Rename to printaddr_ull, change argument type
to unsigned long long, change print format to %#llx.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
73acaec01e xlat: add values for MODULE_INIT_* constants
* bjm.c (MODULE_INIT_IGNORE_MODVERSIONS, MODULE_INIT_IGNORE_VERMAGIC):
Remove.
* xlat/module_init_flags.in: Add values for
MODULE_INIT_IGNORE_MODVERSIONS and MODULE_INIT_IGNORE_VERMAGIC records.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
d71973c31f Remove parser of create_module syscall
Since create_module syscall is present only in kernels before Linux 2.6
and strace does not support those kernels, there is no use to keep this
parser any longer.

* bjm.c (SYS_FUNC(create_module)): Remove.
* linux/dummy.h (sys_create_module): Add stub alias.
2016-10-29 02:54:01 +03:00
Eugene Syromyatnikov
6a1632c7e1 tests: check decoding of process_vm_readv and process_vm_writev syscalls
* tests/process_vm_readv.c: New file.
* tests/process_vm_readv_writev.c: Likewise.
* tests/process_vm_writev.c: Likewise.
* tests/process_vm_readv.test: New test.
* tests/process_vm_writev.test: Likewise.
* tests/.gitignore: Add process_vm_readv and process_vm_writev.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add process_vm_readv.test and process_vm_writev.test.
(EXTRA_DIST): Add process_vm_readv_writev.c.
2016-10-29 02:54:00 +03:00
Eugene Syromyatnikov
5fbb3d299d process_vm: use widen_to_ulong for local_iovcnt, renote_iovcnt, and flags
* process_vm.c (SYS_FUNC(process_vm_readv),
SYS_FUNC(process_vm_writev)): Use widen_to_ulong for local_iovcnt,
renote_iovcnt, and flags parameters.
2016-10-28 18:40:11 +00:00
Eugene Syromyatnikov
714d68127a defs: add widen_to_ulong macro
This is similar to widen_to_long, but for unsigned values.

* defs.h (widen_to_ulong): New macro.
2016-10-28 18:40:11 +00:00
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