Commit Graph

3653 Commits

Author SHA1 Message Date
38437688ec Update fs *_MAGIC constants
* xlat/fsmagic.in: Add CGROUP2_SUPER_MAGIC and OVERLAYFS_SUPER_MAGIC.
2016-02-14 00:36:38 +00:00
b9c8e66f46 Update IPV6_* constants
* xlat/sockipv6options.in: Add IPV6_HDRINCL.
2016-02-14 00:36:38 +00:00
c257fbe24d Update SO_* constants
* xlat/sockoptions.in: Add SO_ATTACH_REUSEPORT_CBPF
and SO_ATTACH_REUSEPORT_EBPF.
2016-02-14 00:36:38 +00:00
12d5e7c8c3 Update MADV_* constants
* xlat/madvise_cmds.in: Add MAD_FREE.
2016-02-14 00:36:38 +00:00
84be84db7b tests: robustify execve and execveat tests
* tests/execve.c (main): Use one page gap between two mapped regions
for an address that is more likely to be not yet mapped.
* tests/execveat.c (main): Likewise.
2016-02-13 01:32:48 +00:00
b5faea4c73 tests: simplify execve test
* tests/execve.c (main): Simplify the test assuming that execve syscall
never returns ENOSYS.
2016-02-13 01:32:48 +00:00
4ab20405bc Fix numbers of syscall arguments in syscall tables
This semi-automatic change brings syscall tables in sync with kernel's
include/linux/syscalls.h file.

* linux/aarch64/syscallent.h (recv): Fix nargs.
* linux/alpha/syscallent.h (sigaltstack, init_module,
sched_getscheduler, settimeofday): Likewise.
* linux/arm/syscallent.h (signal, pciconfig_iobase, msgrcv, msgctl,
shmat, shmdt, shmctl, semtimedop, get_mempolicy, set_mempolicy,
timerfd_create): Likewise.
* linux/bfin/syscallent.h (signal, delete_module): Likewise.
* linux/hppa/syscallent.h (init_module, munlockall, sched_getscheduler,
io_cancel, set_tid_address, listxattr, llistxattr, flistxattr,
removexattr, lremovexattr, fremovexattr): Likewise.
* linux/i386/syscallent.h (signal, mmap): Likewise.
* linux/ia64/syscallent.h (init_module, readv, writev,
sched_getscheduler): Likewise.
* linux/m68k/syscallent.h (signal, request_key): Likewise.
* linux/microblaze/syscallent.h (signal, clone, fstatfs64, vmsplice):
Likewise.
* linux/mips/syscallent-n32.h (getpgid, statfs, fstatfs, init_module,
delete_module): Likewise.
* linux/mips/syscallent-n64.h (getpgid, statfs, fstatfs, init_module,
delete_module): Likewise.
* linux/mips/syscallent-o32.h (signal, statfs, fstatfs, ioperm,
fstatfs64): Likewise.
* linux/powerpc/syscallent.h (signal, spu_run, spu_create): Likewise.
* linux/powerpc64/syscallent.h (signal, pread64, pwrite64, readahead,
fadvise64, lookup_dcookie, spu_run, spu_create, sync_file_range2,
fallocate, preadv, pwritev, fanotify_mark): Likewise.
* linux/s390/syscallent.h (signal, mmap, lookup_dcookie, ipc): Likewise.
* linux/s390x/syscallent.h (signal, ipc): Likewise.
* linux/sh/syscallent.h (signal, ipc, munlockall, fstatfs64, vmsplice):
Likewise.
* linux/sh64/syscallent.h (signal, ipc, msgrcv, msgctl, shmat, shmdt,
shmctl, fstatfs64, vmsplice): Likewise.
* linux/sparc/syscallent.h (ptrace, dup, signal, ipc): Likewise.
* linux/sparc64/syscallent.h (ptrace, dup, signal, pread64, pwrite64,
readahead, lookup_dcookie, fadvise64, fadvise64_64, ipc,
sync_file_range, fallocate, preadv, pwritev, fanotify_mark): Likewise.
* linux/x32/syscallent.h (64:recvmsg): Likewise.
* linux/xtensa/syscallent.h (mremap, futex, reboot, init_module,
delete_module, request_key, getcpu, ioprio_set, ioprio_get, utimensat,
futimesat, fchmodat, faccessat): Likewise.
* NEWS: Mention this fix.
2016-02-13 00:57:00 +00:00
f3948fe494 s390: decode fadvise64 and fadvise64_64
* linux/s390/syscallent.h (fadvise64): Set sys_func.
(fadvise64_64): Set nargs and sys_func.
2016-02-13 00:57:00 +00:00
61066ea8e7 mips n64: use the most optimal parser for fadvise64 syscall
* linux/mips/syscallent-n64.h (fadvise64): Replace SEN(fadvise64_64)
with SEN(fadvise64).
2016-02-13 00:57:00 +00:00
1a1661813d ia64: decode fstatfs64 and statfs64
* linux/ia64/syscallent.h (fstatfs64, statfs64): Set nargs and sys_func.
2016-02-13 00:57:00 +00:00
a1e822870e alpha, ia64, mips, sh, sh64: fix the number of pipe syscall arguments
On alpha, ia64, mips, sh, sh64, sparc, and sparc64 architectures
pipe syscall does not take arguments.

* linux/alpha/syscallent.h (pipe): Change nargs to 0.
* linux/ia64/syscallent.h (pipe): Likewise.
* linux/mips/syscallent-n32.h (pipe): Likewise.
* linux/mips/syscallent-n64.h (pipe): Likewise.
* linux/mips/syscallent-o32.h (pipe): Likewise.
* linux/sh/syscallent.h (pipe): Likewise.
* linux/sh64/syscallent.h (pipe): Likewise.
2016-02-13 00:57:00 +00:00
9b38885803 alpha, ia64, mips, sh*, sparc*: fix error path decoding of pipe syscall
* net.c (do_pipe) [HAVE_GETRVAL2]: Remove.
Always call decode_pair_fd on exiting.
(SYS_FUNC(pipe)) [HAVE_GETRVAL2]: Call printpair_fd instead of do_pipe.
2016-02-13 00:57:00 +00:00
f9f04f74fc Fix pathtrace match for pipe2 syscall
* pathtrace.c (pathtrace_match): As pipe2 syscall has no descriptors
or paths to test, move SEN_pipe2 to the appropriate category.
2016-02-13 00:57:00 +00:00
3a630751eb avr32: wire up missing syscalls
* linux/avr32/syscallent.h [322..324]: Add userfaultfd, membarrier,
and mlock2 entries.
2016-02-13 00:57:00 +00:00
0aae167293 tests: check decoding of madvise, mlockall, mremap, and msync syscalls
* tests/mmap.c (main): Change output format from regexp to verbatim.
Add tests for madvise, mlockall, mremap, and msync syscalls.
* tests/mmap.test: Convert from match_grep to match_diff.
Add madvise, mlockall, mremap, and msync syscalls to syscall filter.
2016-02-12 02:35:54 +00:00
af618fa943 Simplify decoding of waitpid and wait4 syscalls
* wait.c (printwaitn): Replace "n" and "bitness" integer arguments
with a single print_rusage function pointer.  All callers updated.
2016-02-11 03:06:17 +00:00
591906cccb waitid: print pid argument as int
* wait.c (SYS_FUNC(waitid)): As the type of second syscall argument
in the kernel is pid_t, print it as int.
2016-02-11 03:06:17 +00:00
d3f17c642d waitid: always print 5th argument
* wait.c (SYS_FUNC(waitid)): Do not check for tcp->s_ent->nargs
as waitid syscall has 5 arguments.
2016-02-11 03:06:17 +00:00
ea21823d27 socketutils: add const qualifier to variables
* socketutils.c (cache_and_print_inode_details): Make "details"
parameter const.
(print_sockaddr_by_inode_cached): Make "e" variable const.
(inet_send_query): Make struct nlmsghdr and struct inet_diag_req_v2
members const.  Make "msg" variable const.
(inet_parse_response): Make "data" parameter and diag_msg variable const.
(receive_responses): Make "h" and "rc" variables const.
(unix_send_query): Make struct nlmsghdr and struct unix_diag_req
members const.  Make "msg" variable const.
(unix_print): Make all parameters const.
(print_sockaddr_by_inode): Make proto_name parameter const.
2016-02-11 03:06:17 +00:00
bcf5975a3e print_sockaddr_by_inode: cleanup protocol lookup
* socketutils.c (tcp_v4_print, udp_v4_print, tcp_v6_print,
udp_v6_print): New functions.
(print_sockaddr_by_inode): Make "protocols" array static, replace
"family" and "protocol" members with "print" in its underlying
structure.  Iterate through protocols array when the protocol name
is specified.
2016-02-11 03:06:17 +00:00
6204654329 tests: check that -f -p attaches to threads properly
Check that -f -p attaches and follows all threads of the given pid.

* tests/attach-f-p.c: New file.
* tests/attach-f-p.test: New test.
* tests/.gitignore: Add attach-f-p.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(attach_f_p_LDADD): New variable.
(TESTS): Add attach-f-p.test.
2016-02-09 05:08:00 +00:00
6ca4c92c1b Introduce libstrace.a for potentially conditional compilation units
Some files are used conditionally depending on architecture and
configuration.  Create a library for the purpose of keeping such
compilation units.

* Makefile.am (strace_LDADD, noinst_LIBRARIES): Add libstrace.a.
(libstrace_a_CPPFLAGS): New variable, set to $(strace_CPPFLAGS).
(libstrace_a_CFLAGS): New variable, set to $(strace_CFLAGS).
(libstrace_a_SOURCES): New variable, set to upeek.c.
* util.c (upeek): Move ...
* upeek.c: ... here.
2016-02-09 05:08:00 +00:00
0acd8d0ec3 travis-ci: pass more gcov arguments to codecov 2016-02-08 18:35:16 +00:00
b1b692eb23 tests: extend coverage of struct itimerspec
* tests/timer_xettime.c (main): Check decoding of NULL struct itimerspec
pointer.
2016-02-08 18:28:36 +00:00
9ee77b9e65 tests: extend coverage of utimensat syscall
* tests/utimensat.c (main): Check decoding of NULL struct timespec
pointer.
2016-02-08 18:27:59 +00:00
c736b456ad tests: extend coverage of time syscall
* tests/time.c (main): Check decoding of NULL time_t pointer.
2016-02-08 18:27:17 +00:00
595fc10f11 tests: extend coverage of struct sigevent
* tests/timer_create.c (main): Check decoding of NULL struct sigevent
pointer.  Check decoding of invalid sigev_notify value.
2016-02-08 18:26:46 +00:00
23168c1e54 tests: extend coverage of execve and execveat syscalls
Check decoding of inaccessible or partially inaccessible arrays.

* tests/execve-v.c: New file.
* tests/execveat-v.c: Likewise.
* tests/execve-v.test: New test.
* tests/execveat-v.test: Likewise.
* tests/execve.c: Rewrite.
* tests/execveat.c: Likewise.
* tests/execve.test: Likewise.
* tests/execveat.test: Likewise.
* tests/execve.expected: Remove.
* tests/execve-v.expected: Likewise.
* tests/execveat.expected: Likewise.
* tests/execveat-v.expected: Likewise.
* tests/.gitignore: Add execve-v and execveat-v.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add execve-v.test and execveat-v.test.
(EXTRA_DIST): Remove execve.expected, execve-v.expected,
execveat.expected, and execveat-v.expected.
2016-02-08 18:25:33 +00:00
3c00e63b03 Fix decoding of execve and execveat syscalls with invalid input
* execve.c (printargv): Fix decoding of inaccessible or partially
inaccessible array.
(printargc): Diagnose inaccessible or partially inaccessible array.
(decode_execve, SYS_FUNC(execv)): Update printargv and printargc callers.
2016-02-08 18:21:31 +00:00
a59fcec4c9 tests: extend coverage of capget syscall
* tests/caps.c (main): Check decoding of inaccessible cap_user_header_t
and/or cap_user_data_t.
* tests/caps.awk: Update match patterns.
* tests/caps.test: Update.
2016-02-08 18:21:10 +00:00
48d97b6a83 tests: extend coverage of sched_getaffinity syscall
* tests/sched_xetaffinity.c (main): Check decoding of pointer
to inaccessible cpu_set_t.
2016-02-08 18:18:51 +00:00
f2e6f3d3c4 tests: extend coverage of utime syscall
* tests/utime.c (main): Check decoding of NULL struct utimbuf pointer.
Check decoding of struct utimbuf located at the end of page boundary.
* tests/utime.test: Update.
2016-02-08 18:18:05 +00:00
b5a7011d71 tests: extend coverage of sysinfo syscall
* tests/sysinfo.c (main): Check decoding of NULL struct sysinfo pointer.
Check decoding of struct sysinfo located at the end of page boundary.
* tests/sysinfo.test: Update.
2016-02-08 18:17:28 +00:00
7fce7c0332 tests: extend coverage of adjtimex syscall
* tests/adjtimex.c (main): Check decoding of NULL struct timex pointer.
Check decoding of struct timex located at the end of page boundary.
* tests/adjtimex.test: Update.
2016-02-08 18:16:27 +00:00
a88c72ef66 tests: check that strace does not retain stdin and stdout descriptors
* tests/redirect.test: New test.
* tests/Makefile.am (TESTS): Add it.
2016-02-08 17:51:18 +00:00
6aedd42206 Create a dummy pipe descriptor instead of opening /dev/null
* strace.c (open_dev_null): Rename to open_dummy_desc.  All callers
changed.  Create a pipe and return its first descriptor instead of
opening /dev/null.
2016-02-08 17:51:18 +00:00
Denys Vlasenko
0736d4e1a3 If stdin/stdout aren't open on startup, open them to /dev/null
Otherwise, -oLOGFILE may end up using one of them. This conflicts
with the previous change, which closes stdin/out in strace.

* strace.c (init): If fcntl(F_GETFD) fails on stdin or stdout,
sanitize them: open /dev/null and dup it until fds 0,1,2
are all used up.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2016-02-08 18:17:38 +01:00
Denys Vlasenko
c9f85b3876 Close stdin/out after child is forked
Testcase:

{ sleep 1; yes | head -n99999; } | strace -o/dev/null sh -c 'exec <&-; sleep 9'

The writer (head) will be able to perform writes to write end of the pipe.
With strace call removed, head will immediately get SIGPIPE.

This change fixes this: now writer immediately gets SIGPIPE with strace too.

* strace.c (startup_child): Close stdin/out and reopen them to /dev/null.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2016-02-08 18:17:38 +01:00
7469e252fa tests: add opipe.test
Check that -o |pipe_command works.  In particular, check that
strace waits for completion of piped command.

* tests/opipe.test: New test.
* tests/Makefile.am (TESTS): Add it.
2016-02-05 14:58:41 +00:00
Keith Owens
320fb41682 strace-graph: print the pid in the graph
* strace-graph: Prefix each command with its pid.
2016-02-05 00:41:23 +00:00
Keith Owens
7e0ba4bdcc strace-graph: cope with clone immediately followed by exit
* strace-graph: A clone() followed by exit() with no intervening fork
or execve resulted in the new pid having no seq key.  That breaks when
trying to use seq as an array reference.  Ensure that clone populates
the new pid with an empty seq entry.
2016-02-05 00:41:23 +00:00
Keith Owens
ef445b5daf strace-graph: handle recent strace output
* strace-graph: Fix regex for --SIG.  Ignore '+++ exited with <n> +++'
lines.  Handle exit_group syscall as well as _exit.
2016-02-05 00:41:23 +00:00
Keith Owens
dbc1ffb2a4 strace-graph: handle strace -T
* strace-graph: Ignore extra ' <time.spent>' field added by strace -T.
2016-02-05 00:41:23 +00:00
Keith Owens
a0bc25f085 strace-graph: use "strict" and "warnings" pragmas
* strace-graph: Set "use strict" and "use warnings" options.  Fix errors
detected by strict/warnings.  $result is really a string, it can be "-1"
followed by an error text.
2016-02-05 00:41:23 +00:00
26ed70b252 Add README.md file with links to build status and test coverage 2016-02-04 18:20:14 +00:00
5be488c3a5 travis-ci: prepare and submit test coverage report 2016-02-04 17:04:13 +00:00
d8a81dfa40 tests: extend readlink and readlinkat coverage
* tests/readlink.c (PREFIX, TARGET, LINKPATH): New macros.
(main): Allocate memory for string and buffer passed to the syscall
being tested using tail_alloc mechanism.  Create and cleanup test
symlink.  Test syscall error path output.  Print hexquoted strings
using hexquote_strndup.
* tests/readlinkat.c: Likewise.
* tests/readlink.test: Remove creation and cleanup of test symlinks.
2016-02-04 03:36:25 +00:00
7637b1d9e8 tests: add hexquote_strndup function to libtests
* tests/tests.h (hexquote_strndup): New prototype.
* tests/hexquote_strndup.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
2016-02-04 03:36:25 +00:00
f2eb27c73e readlinkat.test: use readlink.test
* tests/readlink.test (syscall): Initialize from $0.
* tests/readlinkat.test: Source readlink.test.
2016-02-04 03:36:25 +00:00
Gabriel Laskar
cba67108a0 Add configure --enable-code-coverage option
* m4/ax_code_coverage.m4: New file.
* configure.ac: Use AX_CODE_COVERAGE.
* Makefile.am: Add @CODE_COVERAGE_RULES@.
(CODE_COVERAGE_LCOV_OPTIONS, CODE_COVERAGE_GENHTML_OPTIONS,
CODE_COVERAGE_IGNORE_PATTERN): New variables.
(strace_CPPFLAGS): Add $(CODE_COVERAGE_CPPFLAGS).
(strace_CFLAGS): Add $(CODE_COVERAGE_CFLAGS).
(strace_LDADD): Add $(CODE_COVERAGE_LDFLAGS).
* .gitignore: Add *.gcda and *.gcno.

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2016-02-04 03:36:11 +00:00