Commit Graph

4887 Commits

Author SHA1 Message Date
0b98d8213e Fix -r option syntax
While -r option implies -t, it should not literally have the effect
of -t option, e.g. -rr should not increment tflag twice.

* strace.c (init): In the getopt loop, do not increment tflag for each
occurrence of -r option.  After the getopt loop, if rflag is set, set
tflag to 1.  Issue a warning that -tt has no effect with -r.
2016-11-28 15:13:25 +00:00
Eugene Syromyatnikov
1aa0697738 Print timeval pair as an array of timeval entries
* print_timeval.c (print_timeval_item): New function.
(print_timeval_pair): Use it as a print_function in print_array call.
* tests/futimesat.c (main): Update to test new behaviour.
* tests/utimes.c (main): Likewise.
2016-11-28 04:38:42 +00:00
Eugene Syromyatnikov
0bf550423c tests: treat tv_sec/tv_usec as signed types in futimesat and utimes tests
* tests/futimesat.c: Print tv_sec and tv_usec fields as signed types.
* tests/utimes.c: Likewise.
2016-11-28 04:26:35 +00:00
7491519823 alpha: print struct timeval32 consistently
* defs.h [ALPHA] (timeval32_t): New type.
[ALPHA] (print_timeval32_t): New prototype.
* print_timeval.c [ALPHA] (timeval32_t): Remove.
[ALPHA] (print_timeval32_t): Remove static keyword.
* printrusage.c [ALPHA] (printrusage32): Use timeval32_t instead
of local definition of struct timeval32.  Use print_timeval32_t.
2016-11-28 04:21:11 +00:00
70864ce6e0 Print struct timeval consistently
Use print_struct_timeval interface to print struct timeval.

* print_timeval.c (print_struct_timeval): New mpers printer.
* print_timex.c (print_timex): Use it.
* printrusage.c (printrusage): Likewise.
* v4l2.c (print_v4l2_buffer): Likewise.
* tests/getrusage.c (main): Print tv_sec and tv_usec fields as signed.
* tests/waitid.c (sprint_rusage): Likewise.

Suggested-by: Eugene Syromyatnikov <evgsyr@gmail.com>
2016-11-28 04:07:37 +00:00
5f6a839d23 Split print_time.c
After commit v4.14-136-g151d1d1 that removed the last object common
for timespec and timeval parsers there is no need to keep them all
in a single file.

* print_timespec.c: New file.
* print_timeval.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* print_time.c: Move all timespec related code to print_timespec.c.
Move all timeval related code to print_timeval.c.
2016-11-28 02:45:13 +00:00
0aaa6976dd tests: check decoding of threads when a non-leader thread invokes execve
* tests/threads-execve.c: New file.
* tests/threads-execve.test: New test.
* tests/.gitignore: Add threads-execve.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(threads_execve_LDADD): New variable.
(MISC_TESTS): Add threads-execve.test.
2016-11-28 00:31:59 +00:00
f6c14637a3 tests: check decoding of fault injected exit_group syscall
* tests/answer.c: New file.
* tests/fault_injection-exit_group.expected: Likewise.
* tests/fault_injection-exit_group.test: New test.
* tests/.gitignore: Add answer.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add fault_injection-exit_group.test.
(EXTRA_DIST): Add fault_injection-exit_group.expected.
2016-11-27 19:40:33 +00:00
2f948b9231 Set PTRACE_O_TRACEEXIT option and handle PTRACE_EVENT_EXIT events
Do not assume that some syscalls do not generate syscall-exit-stops.
When syscalls fail for any reason they may generate syscall-exit-stops.

The solution is to wait for an actual exit reported by PTRACE_EVENT_EXIT
and print the end of unfinished exiting syscall properly.

* exit.c: Remove.
* Makefile.am (strace_SOURCES): Remove exit.c.
* linux/dummy.h (sys_exit): Alias to printargs_d.
* strace.c (ptrace_setoptions): Add PTRACE_O_TRACEEXIT bit.
(print_event_exit): New function.
(trace): Use it in case of PTRACE_EVENT_EXIT.
* syscall.c (trace_syscall_entering): Remove special handling
of SEN_exit.
2016-11-27 14:22:58 +00:00
37c4d4bcfc Change printargs to return RVAL_DECODED
As printargs is invoked as a generic syscall decoder only and
it is not supposed to print anything on exiting, change printargs
to return RVAL_DECODED so it would not be called on exiting at all.

* util.c (printargs): Print args unconditionally, return RVAL_DECODED.
2016-11-27 14:22:58 +00:00
88017cbae8 Enhance error diagnostics of exit/exit_group decoder
* exit.c (SYS_FUNC(exit)): Print the name of syscall that has returned.
2016-11-26 20:54:31 +00:00
0c836eb060 Restrain from fault injection while the trace executes strace code
There is little use in injections of faults into syscalls made by strace.

* syscall.c (trace_syscall_entering): Clear QUAL_FAULT bit from
tcp->qual_flg when tcp->flags has TCB_HIDE_LOG bit set.
2016-11-26 20:54:01 +00:00
634a6a55e8 Move two global flags to tracee scope
A simultaneous use of -p option and tracing of a command available
since commit v4.11-183-gfa8c286 introduces a race condition because
the flags whether the first exec has happened are global.

Fix the race by moving hide_log_until_execve and hide_log_until_execve
global variables to TCB_HIDE_LOG and TCB_SKIP_DETACH_ON_FIRST_EXEC bits
in struct tcb.flags, correspondingly.

* defs.h (TCB_HIDE_LOG, TCB_SKIP_DETACH_ON_FIRST_EXEC, hide_log):
New macros.
(hide_log_until_execve): Remove prototype.
* strace.c (skip_one_b_execve, hide_log_until_execve): Remove.
(startup_child): Set TCB_HIDE_LOG and TCB_SKIP_DETACH_ON_FIRST_EXEC bits
in the allocated tcb structure.
(init): Remove initialization of hide_log_until_execve and
skip_one_b_execve.
(print_stopped): Use hide_log() instead of hide_log_until_execve.
(trace): Check and clear TCB_SKIP_DETACH_ON_FIRST_EXEC flag instead
of skip_one_b_execve.
* syscall.c (trace_syscall_entering): Clear TCB_HIDE_LOG flag instead of
hide_log_until_execve.
(trace_syscall_entering, trace_syscall_exiting): Check hide_log()
instead of hide_log_until_execve.
2016-11-26 19:47:38 +00:00
7910ac9638 Treat execveat as an execve family syscall
* syscall.c (trace_syscall_entering): Clear hide_log_until_execve flag
also when SEN_execveat is encountered.
2016-11-26 16:08:10 +00:00
d5b9c75d61 Change parser of fault expressions to conform the documentation
Make expressions like fault=SYSCALL1,SYSCALL2:error=EPERM work
as documented, i.e. fail both SYSCALL1 and SYSCALL2 with EPERM.

* syscall.c (parse_fault_expression): Remove const qualifier from
"name" and "token: variables, as well as from the return value.
(qual_fault): Remove const qualifier from "name" variables.
Split "name" into comma delimited tokens and pass each token
to individual qual_syscall_ex call.
(qualify): For QUAL_FAULT options, pass the whole option value
to their qualify methods without prior splitting into comma
delimited tokens.
* tests/fault_injection.test: Check it.
* tests/fault_syntax.test: Check empty syscall sets.
2016-11-25 23:47:32 +00:00
cba0d84def Simplify parse_fault_expression
* syscall.c (parse_fault_expression): Rewrite iterator over strtok_r
in a more concise way.
2016-11-24 21:35:05 +00:00
Eugene Syromyatnikov
151d1d158c Fix omission of field names in printers of timeval structure
* print_time.c (time_fmt): Remove.
(timeval_fmt): New constant.
(print_timeval_t, sprint_timeval, print_timeval32_t, sprint_timeval32):
Use it instead of time_fmt.
* print_timex.c (print_timex): Print field names of the time field.
* printrusage.c (printrusage, printrusage32): Print field names
of ru_utime and ru_stime fields.
* tests/adjtimex.c (main): Add field names to expected output.
* tests/clock_nanosleep.c (main): Likewise.
* tests/futimesat.c (main): Likewise.
* tests/getrusage.c (main): Likewise.
* tests/nanosleep.c (main): Likewise.
* tests/oldselect.expected: Likewise.
* tests/utimes.c (main): Likewise.
* tests/wait4.c (sprint_rusage): Likewise.
* tests/waitid.c (sprint_rusage): Likewise.
* tests/xetitimer.c (main): Likewise.
* tests/xettimeofday.c (main): Likewise.
* tests/xselect.c (main): Likewise.
2016-11-26 00:40:53 +00:00
Eugene Syromyatnikov
acdb08613e Fix omission of field names in printers of timespec structure
* print_time.c (timespec_fmt): New constant.
(print_timespec_t, sprint_timespec): Use it instead of time_fmt.
* tests/aio.c: Add field names to expected output.
* tests/clock_nanosleep.c (main): Likewise.
* tests/clock_xettime.c (main): Likewise.
* tests/futex.c (main): Likewise.
* tests/mq_sendrecv.c (do_send, do_recv): Likewise.
* tests/nanosleep.c (main): Likewise.
* tests/ppoll-v.expected: Likewise.
* tests/ppoll.expected: Likewise.
* tests/pselect6.c (main): Likewise.
* tests/recvmmsg-timeout.c (main): Likewise.
* tests/restart_syscall.c (main): Likewise.
* tests/rt_sigtimedwait.c (iterate, main): Likewise.
* tests/sched_rr_get_interval.c (main): Likewise.
* tests/semop.c (main): Likewise.
* tests/strace-T.expected: Likewise.
* tests/timer_xettime.c (main): Likewise.
* tests/timerfd_xettime.c (main): Likewise.
* tests/utimensat.c (print_ts): Likewise.
2016-11-26 00:40:53 +00:00
6daba2ec29 tests: robustify prctl-name.test against unrelated prctl invocations
* tests/prctl-name.test: Filter out unrelated PR_GET_* prctl calls.
2016-11-26 00:40:39 +00:00
994afa8b71 tests: cleanup prctl-name.c
* tests/prctl-name.c (main): Remove "len" variable, rename "len1"
to "len".  Remove "name1" variable, use "name" instead.
2016-11-22 01:46:07 +00:00
e4997ecb89 Move KVM_* ioctl entries from ioctls_inc*.h to ioctls_arch*.h
* linux/32/ioctls_inc_align32.h: Regenerate.
* linux/32/ioctls_inc_align64.h: Likewise.
* linux/64/ioctls_inc.h: Likewise.
* linux/arm/ioctls_arch0.h: Likewise.
* linux/i386/ioctls_arch0.h: Likewise.
* linux/powerpc/ioctls_arch0.h: Likewise.
* linux/s390/ioctls_arch0.h: Likewise.
* linux/s390x/ioctls_arch0.h: Likewise.
* linux/x32/ioctls_inc0.h: Likewise.
* linux/x86_64/ioctls_arch0.h: Likewise.
2016-11-22 00:21:01 +00:00
5532ac185b maint: add more workarounds for alpha and powerpc
* maint/ioctls_sym.sh: Skip asm/core_*.h.  Filter out from
asm-generic/ioctls.h those macros that are defined using unavailable
struct termios2 on alpha and powerpc.
2016-11-22 00:21:01 +00:00
Andreas Schwab
3317da7a3a Add ioctl definitions for 16-bit alignment
* Makefile.am (EXTRA_DIST): Add linux/32/ioctls_inc_align16.h.
* linux/32/ioctls_inc_align16.h: New file.
* linux/32/ioctls_inc.h [M68K]: Include it.
2016-11-22 00:15:20 +00:00
702c5c29a1 maint: move KVM_* constants from ioctls_inc.h to ioctls_arch.h
* maint/ioctls_gen.sh: Place constants defined in linux/kvm.h
into ioctls_arch.h instead of ioctls_inc.h.
2016-11-22 00:15:20 +00:00
0bb5372ddd maint: harmonize use of ioctls_sym.sh
* maint/ioctls_gen.sh: Consistently specify INCLUDES for all
ioctls_sym.sh invocations.  Use $mydir to specify ioctls_sym.sh
location.
2016-11-21 22:34:05 +00:00
c06335cdd4 maint: rework workarounds for linux/kvm.h
* maint/ioctls_sym.sh: Remove pre-include linux/kvm.h workarounds.
Skip linux/kvm.h on those architectures that have no asm/kvm.h file.
Introduce post-process workarounds, add post-process workarounds
for linux/kvm.h.
2016-11-21 16:08:08 +00:00
Elvira Khabirova
e0bf512cfc Restructure strace.1
* strace.1 (OPTIONS): Add subsections.
(PROBLEMS): Rename to REPORTING BUGS.
(SEE ALSO): Move to the bottom.
2016-11-20 22:39:29 +00:00
Eugene Syromyatnikov
10922d3112 prctl: implement decoding of PR_SET_FP_MODE and PR_GET_FP_MODE options
* xlat/pr_fp_mode.in: New file.
* prctl.c: Include "xlat/pr_fp_mode.h".
(SYS_FUNC(prctl)): Add handling for PR_SET_FP_MODE and PR_GET_FP_MODE
options.
2016-11-20 11:32:34 +00:00
Eugene Syromyatnikov
c8af54e328 prctl: add braces for conditional blocks with else/else-if blocks having braces 2016-11-20 11:32:34 +00:00
Eugene Syromyatnikov
6b7ad9947b prctl: cast arg2 to int in PR_SET_PTRACER handler
Kernel code does this when compares it with -1 (apart from comparing it with
PR_SET_PTRACER_ANY, which is also -1) in security/yama/yama_lsm.c.

* prctl.c (SYS_FUNC(prctl)) <PR_SET_PTRACER>: Cast arg2 to int before
comparing it with -1.
2016-11-20 11:32:34 +00:00
Eugene Syromyatnikov
aeff861218 prctl: use getarg_ull for option value retrieval
The prctl syscall does not use compat on x32/n32, so argument types
are in fact kernel_ulong_t.

* prctl.c (print_prctl_args): Use getarg_ull, print as "%#llx" instead
of "%#lx".
(SYS_FUNC(prctl)): Use getarg_ull to store call arguments in arg2, arg3,
arg4, arg5 variables of type unsigned long long.  Use them in printing
routines.
(SYS_FUNC(arch_prctl)): Use getarg_ull to store call argument in addr
variable of type unsigned long long.  Print it as "%#llx" instead of
"%#lx".
2016-11-20 11:32:34 +00:00
Eugene Syromyatnikov
1d82c0f8c0 block: add some definitions from <linux/blkpg.h>
This is done in order to fix build error on old distributions where
struct blkpg_ioctl_arg declaration is broken:

In file included from block.c:35:
/usr/include/linux/blkpg.h:36: error: expected ':', ',', ';', '}' or '__attribute__' before '*' token
block.c: In function 'print_blkpg_req':
block.c:113: error: 'struct_blkpg_ioctl_arg' has no member named 'data'

(from SLE10)

* block.c: Include <linux/ioctl.h> instead of <linux/blkpg.h>.
(BLKPG, BLKPG_DEVNAMELTH, BLKPG_VOLNAMELTH): New macros.
(struct_blkpg_ioctl_arg, struct_blkpg_partition): New definitions,
copied from blkpg_ioctl_arg and blkpg_partition structures defined
in <linux/blkpg.h>.
2016-11-20 10:41:07 +00:00
Eugene Syromyatnikov
2c9464c5a3 xlat: add values to new ARCH_* constants
Since UAPI header declares them under CONFIG_CHECKPOINT_RESTORE
and they would never be defined in user space.

* xlat/archvals.in: Add numeric values to ARCH_MAP_VDSO_* constants.
2016-11-20 02:41:30 +00:00
9eb38322fb prctl: include <linux/prctl.h> instead of <sys/prctl.h>
There are no users of prctl function in prctl.c, and all the rest
is provided by <linux/prctl.h> anyway.

* prctl.c: Include <linux/prctl.h> instead of <sys/prctl.h>.
2016-11-20 02:00:35 +00:00
9e8b95977d tests: check decoding of prctl PR_GET_NAME/PR_SET_NAME operations
* tests/prctl-name.c: New file.
* tests/prctl-name.test: New test.
* tests/.gitignore: Add prctl-name.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add prctl-name.test.
2016-11-20 01:33:16 +00:00
43017ef466 prctl: fix printing of PR_SET_NAME's argument
* prctl.c (SYS_FUNC(prctl)): Use printstr_ex with QUOTE_0_TERMINATED
instead of printstr to print the argument of PR_SET_NAME and PR_GET_NAME
operations.
2016-11-20 01:33:16 +00:00
52b85c6fdf printstr_ex: fix handling of last byte when QUOTE_0_TERMINATED bit set
* util.c (printstr_ex): Simplify handling of size == 0 case.
Do not artificially decrement size when QUOTE_0_TERMINATED bit is set.
Ensure that str[size] byte is non-zero if it hasn't been fetched.
2016-11-20 00:29:46 +00:00
03d65a05b9 printstr_ex: handle QUOTE_0_TERMINATED bit consistently
When user_style has QUOTE_0_TERMINATED bit set, printstr_ex prints
the fetched string as a NUL-terminated.
After this change, the string is being fetched as a NUL-terminated, too.

* util.c (printstr_ex): Use umovestr instead of umoven
if QUOTE_0_TERMINATED bit is set.
2016-11-19 21:01:03 +00:00
ead746af18 Cleanup fetch part of printstr_ex
* util.c (printstr_ex): Initialize "style" early, unify error handling.
2016-11-19 16:33:37 +00:00
6931903807 Update prctl ARCH_* constants
* xlat/archvals.in: Add ARCH_MAP_VDSO_X32, ARCH_MAP_VDSO_32, and
ARCH_MAP_VDSO_64 introduced by linux kernel commit v4.9-rc1~155^2~6.
2016-11-18 15:23:35 +00:00
76b57d67f0 Update V4L2_* constants
* xlat/v4l2_device_capabilities_flags.in: Add V4L2_CAP_TOUCH introduced
by linux kernel commit v4.9-rc4~7^2~422.
* xlat/v4l2_input_types.in: Add V4L2_CAP_TOUCH introduced
by linux kernel commit v4.9-rc4~7^2~422.
2016-11-18 15:23:35 +00:00
841744c4c9 Update fs *_MAGIC constants
* xlat/fsmagic.in: Add DAXFS_MAGIC introduced by linux kernel commit
v4.9-rc1~45^2^2~5.
2016-11-18 15:23:35 +00:00
2a914e6c1f Update MS_* constants
* xlat/mount_flags.in: Add MS_NOREMOTELOCK introduced
by linux kernel commit v4.9-rc1~57^2~1^2~7.
2016-11-18 15:23:35 +00:00
c4e428bd22 Update FALLOC_* constants
* xlat/falloc_flags.in: Add FALLOC_FL_UNSHARE_RANGE introduced
by linux kernel commit v4.9-rc1~31^2~69.
2016-11-18 15:23:35 +00:00
75cfe3346b Update BTRFS_* constants
* xlat/btrfs_features_compat_ro.in: Add
BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID introduced
by linux kernel commit v4.9-rc1~7^2^2~4.
2016-11-18 15:23:35 +00:00
a082fe833e Update BPF_* constants
* xlat/bpf_prog_types.in: Add BPF_PROG_TYPE_PERF_EVENT introduced
by linux kernel commit v4.9-rc1~127^2~302^2~4.
2016-11-18 15:23:35 +00:00
Eugene Syromyatnikov
79dca294d1 make-dist: use HEAD for making distribution package
* make-dist: Use HEAD commit instead of master branch by default.
2016-11-18 12:57:02 +00:00
95308d89ce tests: fix btrfs build error on some old systems
Fix the following build error on SLE 11 SP4:

btrfs.c: In function 'btrfs_test_dev_replace_ioctl':
btrfs.c:1570: error: unknown field 'start' specified in initializer

* tests/btrfs.c (btrfs_test_dev_replace_ioctl): Move initialization
of struct btrfs_ioctl_dev_replace_args.start.srcdevid out of the
designated initializer.
2016-11-18 00:51:37 +00:00
f860e8c3e0 tests: check decoding of ERESTARTSYS error code
* tests/erestartsys.c: New file.
* tests/erestartsys.test: New test.
* tests/.gitignore: Add erestartsys.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add erestartsys.test.
2016-11-18 00:28:29 +00:00
57506ae00f Fix signame usage in qual_signal
Do not assume that the string returned by signame starts with "SIG"
prefix, this is not always the case.

* syscall.c (qual_signal): Skip signame return value
when it does not have "SIG" prefix.
2016-11-18 00:11:39 +00:00