Commit Graph

4859 Commits

Author SHA1 Message Date
Eugene Syromyatnikov
fdd97aac53 util: add support for QUOTE_0_TERMINATED in user_style to ptrintstr_ex
This enables printing size-limited (expectedly) ASCIZ strings.

This is done by increasing umoven size limit for sized strings by one
byte above max_strlen (enabling copying possible NUL byte in case len is
greater than max_strlen) and decreasing size after copying by one byte
in case QUOTE_0_TERMINATED is set (due to user_style or usage of len of
-1).  As a result, there is one excess byte for string_quote in case
QUOTE_0_TERMINATED is set so string_quote can check for NUL termination
of strings up to size bytes in size (which is len or max_strlen, whatever
is greater).

The catch here is that when string is not properly NUL-terminated and
QUOTE_0_TERMINATED is provided in user_style and len is less than
max_strlen then last non-NUL byte is not printed.  But ellipsis is
printed instead, being indication that string is not terminated
properly.  QUOTE_OMIT_TRAILING_0 should be used instead in case this
behaviour is not intended.

* util.c (printstr_ex): Copy one excess byte in case of non-negative len
provided and it is more than max_strlen; handle case of max_strlen of 0
in case QUOTE_0_TERMINATED is set separately; check for need of printing
ellipsis by checking resulting style against QUOTE_0_TERMINATED.
2016-11-10 22:44:18 +03:00
Eugene Syromyatnikov
62218efa6c tests: check decoding of mq_{notify,open,timedreceive,timedsend,unlink}
* tests/mq_sendrecv.c: New file.
* tests/mq_sendrecv-read.c: Likewise.
* tests/mq_sendrecv-write.c: Likewise.
* tests/mq_sendrecv.test: New test.
* tests/mq_sendrecv-read.test: Likewise.
* tests/mq_sendrecv-write.test: Likewise.
* tests/.gitignore: Add mq_sendrecv, mq_sendrecv-read,
and mq_sendrecv-write.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(mq_sendrecv_LDADD, mq_sendrecv_read_LDADD, mq_sendrecv_write_LDADD):
New variables.
(DECODER_TESTS): Add mq_sendrecv.test, mq_sendrecv-read.test,
and mq_sendrecv-write.test.
2016-11-09 04:27:53 +03:00
64ac9ee785 tests: skip times.test if CLOCK_PROCESS_CPUTIME_ID does not work
* tests/times.c (main): Skip if clock_gettime consistenly returns zero
for CLOCK_PROCESS_CPUTIME_ID timer.
2016-11-08 15:32:47 +00:00
Eugene Syromyatnikov
015aee943e tests: add tests for perf_event_attr structure decoding in perf_event_open
* configure.ac: Add checks for presence of various fields of struct
perf_event_attr defined in kernel headers.
* tests/perf_event_open.c: New file.
* tests/perf_event_open_unabbrev.c: Likewise.
* tests/perf_event_open.test: New test.
* tests/perf_event_open_unabbrev.test: Likewise.
* tests/.gitignore: Add perf_event_open, perf_event_open_unabbrev.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add perf_event_open.test, perf_event_open_unabbrev.test.
2016-10-31 11:29:20 +03:00
Eugene Syromyatnikov
6ed2a84aab Implement decoding of perf_event_attr structure in perf_event_open syscall
* linux/perf_event_struct.h: New file, definition of struct perf_event_attr
from Linux 4.8
* Makefile.am (strace_SOURCES): Add it.
* xlat/hw_breakpoint_len.in: New file.
* xlat/hw_breakpoint_type.in: Likewise.
* xlat/perf_attr_size.in: Likewise.
* xlat/perf_branch_sample_type.in: Likewise.
* xlat/perf_event_read_format.in: Likewise.
* xlat/perf_event_sample_format.in: Likewise.
* xlat/perf_hw_cache_id.in: Likewise.
* xlat/perf_hw_cache_op_id.in: Likewise.
* xlat/perf_hw_cache_op_result_id.in: Likewise.
* xlat/perf_hw_id.in: Likewise.
* xlat/perf_sw_ids.in: Likewise.
* xlat/perf_type_id.in: Likewise.
* perf.c [HAVE_LINUX_PERF_EVENT_H]: Remove inclusion of
<linux/perf_event.h>.
(PRINT_XLAT): New macro for simplifying printing values from
sorted xlat.
(printxlat_search): New function, wrapper for xlat_search with behaviour
similar to printval.
(print_perf_event_attr): New print_event_attr structure fetching and
printing function.
(SYS_FUNC(perf_event_open)): Use print_perf_event_attr for displaying
attr argument contents.
* tests/perf_event_open.c: Renamed to
tests/perf_event_open_nonverbose.c.
* tests/perf_event_open.test: add -e verbose=none in order to preserve
output format being checked (in case verbose output is enabled,
contents of attr arguments are shown now); rename to
tests/perf_event_open_nonverbose.test; add -e trace=perf_event_open.
2016-10-31 04:59:10 +03:00
Eugene Syromyatnikov
48dd98ba81 tests: fix name spelling 2016-10-31 04:59:10 +03:00
Eugene Syromyatnikov
fd992caa81 tests: fix name spelling 2016-10-30 22:54:27 +00:00
Eugene Syromyatnikov
3d6436d7cb Update NEWS 2016-10-30 22:53:52 +00:00
Eugene Syromyatnikov
06c8831cf4 Fix typo in comment in tests/quotactl.h 2016-10-31 01:32:45 +03:00
Eugene Syromyatnikov
5ca0852f5f tests: fix invalid pointer checks in quotactl test
* tests/quotactl.h (bogus_special, bogus_addr): Move it...
* tests/quotactl.c (main): ... here; remove static and const qualifiers,
use memory after tail_alloc instead of magic numbers.
* tests/quotactl-xfs.c (main): Likewise.
2016-10-31 00:49:29 +03:00
Eugene Syromyatnikov
3fb04c6aec tests: fix invalid pointer checks in getcpu test
* test/getcpu.c (main): Replace magic numbers deemed invalid pointers
with addresses after memory returned by tail_alloc.
2016-10-31 00:49:29 +03:00
Eugene Syromyatnikov
d6fd023b17 tests: fix invalid pointer checks in request_key test
* test/request_key.c (main): Replace magic numbers deemed invalid pointers
with addresses after memory returned by tail_alloc.
2016-10-31 00:49:29 +03:00
Eugene Syromyatnikov
64de69186e tests: fix invalid pointer checks in add_key test
* test/add_key.c (main): Replace magic numbers deemed invalid pointers
with addresses after memory returned by tail_alloc.
2016-10-31 00:49:29 +03:00
Eugene Syromyatnikov
c1c3fed7c9 statfs: use printxval_search
* print_statfs.c (print_statfs_type): Use printxval_search for printing
FS magic xlat value.
2016-10-31 00:49:28 +03:00
Eugene Syromyatnikov
cdf0885fe0 util: add printing helper for sorted xlat arrays
* util.c (printxval_searchn): New function.
* defs.h (printxval_searchn): New prototype.
(printxval_search): New helper macro useful in conjunction with static
xlat arrays.
2016-10-31 00:49:28 +03:00
Eugene Syromyatnikov
48252db2a2 defs: add check for argument being array to ARRAY_SIZE macro
* gcc_compat.h [GNUC_PREREQ(3, 0)] (BUILD_BUG_ON_ZERO): New macro.
(SAME_TYPE, MUST_BE_ARRAY): Likewise.
* defs.h (ARRAY_SIZE): Add MUST_BE_ARRAY for build-time type check.
2016-10-31 00:49:28 +03:00
Eugene Syromyatnikov
a1a42e1f0d tests: check decoding of oldfstat, oldlstat, and oldstat syscalls
* tests/oldfstat.c: New file.
* tests/oldlstat.c: Likewise.
* tests/oldstat.c: Likewise.
* tests/oldfstat.test: New test.
* tests/oldlstat.test: Likewise.
* tests/oldstat.test: Likewise.
* tests/xstatx.c [!OLD_STAT]: define OLD_STAT to 0.
(print_stat) [OLD_STAT]: Print predefined values for
st_blksize/st_blocks.
(print_stat): Check for !OLD_STAT in nanosecond precision checks.
(main) [OLD_STAT]: Ignore EOVERFLOW.
(main): Test for successful rc in returned size value check;
print address only on non-successful rc.
* tests/.gitignore: Add oldfstat, oldlstat, and oldstat.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add oldfstat.test, oldlstat.test, and oldstat.test.
2016-10-31 00:49:28 +03:00
Eugene Syromyatnikov
7497b1c700 tests: additional tests of stat decoders
* tests/fstatx.c (IS_FSTAT): Define to 1.
* tests/fstatat64.c [__GLIBC__ && __sparc64__] (TEST_BOGUS_STRUCT_STAT):
Define to 0.
* tests/xstatx.c [!IS_STAT] (IS_STAT): Define to 0.
[!TEST_BOGUS_STRUCT_STAT] (TEST_BOGUS_STRUCT_STAT): Define to 1.
(main): Add a check for non-available pointer and a check
for block device file.
* tests/statx.sh: Add tracing of /dev/full file, specify alignment.
* tests/fstat.test: Specify alignment.
2016-10-31 00:49:28 +03:00
Eugene Syromyatnikov
3815851894 tests: prepare for additional tests of stat decoders
PRINT_SYSCALL_HEADER/PRINT_SYSCALL_FOOTER now contain open/close brace
pair in order to save errno.  PRINT_SYSCALL_FOOTER now uses sprintrc for
printing rc/errno.

* tests/xstatx.c: Include <errno.h>.
(main): Update PRINT_SYSCALL_FOOTER call convention.
* tests/fstatat.c (PRINT_SYSCALL_HEADER): Add errno saving.
(PRINT_SYSCALL_FOOTER): Restore errno.
* tests/fstatx.c: Likewise.
* tests/lstatx.c: Likewise.
2016-10-31 00:49:28 +03:00
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