Commit Graph

3478 Commits

Author SHA1 Message Date
87d64ed61f userfaultfd: fix pathtrace support
* pathtrace.c (pathtrace_match): Add SEN_userfaultfd.
2015-11-22 19:59:58 +00:00
1f111cff5a Implement IPPROTO_IP control messages decoding
* net.c: Include "xlat/ip_cmsg_types.h".
(print_cmsg_ip_pktinfo, print_cmsg_ip_ttl, print_cmsg_ip_tos,
print_cmsg_ip_opts, print_cmsg_ip_recverr, print_cmsg_ip_checksum,
print_cmsg_ip_origdstaddr): New functions.
(print_cmsg_type_data): Add generic SOL_IP level decoding.
Use these functions for decoding of IP_PKTINFO, IP_TTL, IP_TOS,
IP_RECVOPTS, IP_RETOPTS, IP_RECVERR, IP_ORIGDSTADDR, IP_CHECKSUM,
and SCM_SECURITY type messages.
* xlat/ip_cmsg_types.in: New file.
* xlat/sockipoptions.in: Move IP_RETOPTS before IP_RECVRETOPTS.
* tests/inet-cmsg.c: New file.
* tests/inet-cmsg.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add inet-cmsg.
(TESTS): Add inet-cmsg.test.
* tests/.gitignore: Add inet-cmsg.

Suggested-by: Orion Poplawski <orion@cora.nwra.com>
2015-11-22 02:56:45 +00:00
1103b4ee86 Simplify control messages printers
Do not pass sizeof(struct cmsghdr) to every cmsg printer.

* net.c (printcmsghdr): Pass pointer to cmsg_data and length
of cmsg_data to print_cmsg_type_data.
(print_cmsg_type_data): Update prototype.  Pass pointer to cmsg_data
and length of cmsg_data to cmsg printers.
(print_scm_rights, print_scm_creds, print_scm_security): Update.
2015-11-22 02:42:45 +00:00
1019f002c1 net: factor out address printing code to a separate function
* net.c (sockaddr_buf_t): New type.
(print_sockaddr): New function.
(printsock, print_group_req): Use it.
2015-11-21 02:52:23 +00:00
5cb45b25a3 mpers: skip xlat struct definitions in mpers mode
Avoid duplicate definitions of xlat structures in files
compiled in mpers mode.

Each xlat file defines the corresponding xlat struct with
either global or local visibility using the following rules:

- if xlat struct declaration is available in defs.h,
  a global definition is provided in regular mode,
  and nothing is provided in mpers mode;
- otherwise, if xlat file is included by a mpers source file,
  a global definition is provided in regular mode
  (unless no mpers mode is supported on this architecture,
  in that case, a local definition is provided instead),
  and a declaration is provided in mpers mode;
- otherwise, a local definition is provided in regular mode,
  and an error message is printed in mpers mode.

Fallback definitions of constants provided by xlat files
remain available in all modes.

* bootstrap: Invoke generate_mpers_am.sh before xlat/gen.sh.
* defs.h (adjtimex_modes, adjtimex_status, sigev_value): Remove.
* generate_mpers_am.sh: Generate mpers_xlat.h.
* Makefile.am (EXTRA_DIST): Add mpers_xlat.h.
* print_sigevent.c: Include "xlat/sigev_value.h" unconditionally.
* print_timex.c: Include "xlat/adjtimex_modes.h" and
"xlat/adjtimex_status.h" unconditionally.
* xlat/gen.sh (cond_xlat): Move printing of fallback definitions ...
(cond_def): ... here.
(gen_header): Check also mpers_xlat.h for global declarations
of xlat structures.
Process input file twice, first time print directives
only, second time print everything.
Wrap struct xlat into #ifdef IN_MPERS ... #else ... #endif.
* xlat/getrandom_flags.in: Cleanup.
2015-11-20 05:44:49 +00:00
7528a0b2e1 tests: rewrite getdents test in C for better coverage
* tests/getdents.awk: Remove.
* tests/getdents.out: Remove.
* tests/getdents.c: New file.
* tests/getdents.test: Rewrite.
* tests/getdents64.c: New file.
* tests/getdents64.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add getdents and getdents64.
(TESTS): Add getdents64.test.
(EXTRA_DIST): Remove getdents.awk and getdents.out.
* tests/.gitignore: Add getdents and getdents64.
2015-11-20 00:08:48 +00:00
4f461581b7 tests: add readdir.test
* tests/readdir.c: New file.
* tests/readdir.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add readdir.
(TESTS): Add readdir.test.
* tests/.gitignore: Add readdir.
2015-11-19 22:57:42 +00:00
a367db8e5b Mpersify parsers of readdir and getdents syscalls
* defs.h (dirent_types): New xlat prototype.
* dirent.c: Stop including "xlat/direnttypes.h".
(kernel_dirent): New typedef.  Mpersify it.
(print_old_dirent): Use it instead of old_dirent_t.
(SYS_FUNC(getdents)): Use it instead of struct kernel_dirent.
Rename direnttypes to dirent_types.
(SYS_FUNC(getdents64)): Move ...
* dirent64.c: ... here.  Rename direnttypes to dirent_types.
Include "xlat/dirent_types.h".
* Makefile.am (strace_SOURCES): Add dirent64.c.
* xlat/direnttypes.in: Rename to xlat/dirent_types.in.
2015-11-19 22:49:58 +00:00
Gabriel Laskar
a2df1c12de getdents: fix typos in array output
Array should be enclosed by square brakets, and elements should be
separated by commas.

* dirent.c (SYS_FUNC(getdents), SYS_FUNC(getdents64)): Fix typos
in array output.
* tests/getdents.awk: Update regexps to match fixed output.
* tests/getdents.out: Update output.

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
2015-11-19 17:52:35 +00:00
f54cb96f7f printcmsghdr: move type and data decoders to a separate function
* net.c (print_scm_rights, print_scm_creds, print_scm_security): Change
to return void.  Move printing of struct cmsghdr closing '}' ...
(printcmsghdr): ... here.  Move type and data decoders to ...
(print_cmsg_type_data): ... new function.
2015-11-19 00:31:32 +00:00
b36d132907 Assume that libc provides sendmsg
Starting with commit v4.6-281-g7af9f35, we implicitly assume that
HAVE_SENDMSG is always defined.  Therefore, the check for sendmsg
availability is redundant and could be safely removed.

* configure.ac (AC_CHECK_FUNCS): Remove sendmsg.
* linux/dummy.h [!HAVE_SENDMSG] (sys_recvmsg, sys_sendmsg): Remove
stub aliases.
* net.c [HAVE_SENDMSG]: Define unconditionally.
* syscall.c (dumpio) [HAVE_SENDMSG]: Likewise.
2015-11-18 23:18:17 +00:00
3a1e95d14e net.c: move fallback definition of SCM_SECURITY to xlat/
* net.c: Move fallback definition of SCM_SECURITY ...
* xlat/scmvals.in: ... here.
2015-11-18 23:11:34 +00:00
0d0a50aa25 Implement mlock2 syscall decoding
* mem.c: Include "xlat/mlock_flags.h".
(SYS_FUNC(mlock2)): New function.
* xlat/mlock_flags.in: New file.
* xlat/mlockall_flags.in: Add MCL_ONFAULT, add default values.
* linux/dummy.h (mlock2): Remove.
* tests/mlock2.c: New file.
* tests/mlock2.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add mlock2.
(TESTS): Add mlock2.test.
* tests/.gitignore Add mlock2.
2015-11-17 00:40:22 +00:00
2aec1e67df Implement membarrier syscall decoding
* membarrier.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/membarrier_cmds.in: New file.
* linux/dummy.h (membarrier): Remove.
* tests/membarrier.c: New file.
* tests/membarrier.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add membarrier.
(TESTS): Add membarrier.test.
* tests/.gitignore: Add membarrier.
2015-11-17 00:40:22 +00:00
a6ebdb149e Implement userfaultfd syscall decoding
* userfaultfd.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/uffd_flags.in: New file.
* linux/dummy.h (userfaultfd): Remove.
* tests/userfaultfd.c: New file.
* tests/userfaultfd.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add userfaultfd.
(TESTS): Add userfaultfd.test.
* tests/.gitignore: Add userfaultfd.
2015-11-17 00:40:22 +00:00
1fc01fdee6 ia64: wire up kcmp syscall
ia64 has kcmp syscall starting with linux kernel commit
v4.3-rc7-1-gd305c47.

* linux/ia64/syscallent.h (kcmp): New entry.
2015-11-17 00:40:22 +00:00
7171821dde powerpc: wire up direct sysv ipc syscalls
Starting with linux commit v4.3-rc3-33-ga342361, powerpc has
direct sysv ipc syscalls in addition to traditional ipc syscall.

* linux/powerpc/syscallent.h (semop, semget, semctl, semtimedop, msgsnd,
msgrcv, msgget, msgctl, shmat, shmdt, shmget, shmctl): New entries.
2015-11-17 00:40:21 +00:00
401d4bd601 Wire up userfaultfd, membarrier, and mlock2 syscalls
* linux/dummy.h (membarrier, mlock2, userfaultfd): New stub aliases.
* linux/32/syscallent.h (userfaultfd, membarrier, mlock2): New entries.
* linux/64/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/arm/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/hppa/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/i386/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/ia64/syscallent.h (userfaultfd, membarrier): Likewise.
* linux/m68k/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/microblaze/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/mips/syscallent-n32.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/mips/syscallent-n64.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/mips/syscallent-o32.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/powerpc/syscallent.h (userfaultfd, membarrier): Likewise.
* linux/s390/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/s390x/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/sparc/syscallent.h (membarrier, userfaultfd, mlock2): Likewise.
* linux/x32/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/x86_64/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
2015-11-17 00:39:49 +00:00
71af1158ec sprintflags: skip zero flags
Tweak sprintflags behaviour to match printflags.

* util.c (sprintflags): Skip zero flags unless the value passed
to sprintflags is also zero.
2015-11-16 03:08:41 +00:00
Mike Frysinger
79bddff923 printflags: handle empty xlats
If the set of headers are unable to produce a valid list, printflags
will try to pass NULL to tprints which crashes.  Add a sanity check
for this edge case.

* util.c (printflags): Check xlat->str is not NULL.
2015-11-16 03:08:41 +00:00
35bd0b8b84 mpers: forward mpers_DEFS to mpers.sh
mpers_DEFS has to be forwarded to mpers.sh so that config.h would be
properly included by defs.h at preprocessor stage.

* Makefile.am (mpers-m%.stamp): Add the whole $(mpers_sh_opts) set of
options to mpers.sh's CPPFLAGS.
2015-11-16 03:08:41 +00:00
0f8af61154 tests/ioctl: workaround glibc ioctl wrapper on powerpc
* tests/ioctl.c (main) [POWERPC] Disable TCGETS test.
2015-11-16 03:08:41 +00:00
b3ab30f218 powerpc: wire up switch_endian syscall
powerpc has switch_endian syscall starting with linux commit
v4.0-rc4-67-g529d235.

* linux/powerpc/syscallent.h (switch_endian): New entry.
2015-11-15 16:51:55 +00:00
a1982b404b sparc: reserve more space for new syscalls
Move socket subcalls further down the table to make room
for new syscalls.

* linux/sparc/syscallent.h (SYS_socket_subcall): Raise from 353 to 400.
2015-11-15 16:48:50 +00:00
b070229f56 m68k: wire up direct socket syscalls
Starting with linux commit v4.3-rc3-1-g5b3f33e, m68k has direct
socket syscalls in addition to traditional socketcall syscall.

* linux/m68k/syscallent.h (socket, socketpair, bind, connect, listen,
accept4, getsockopt, setsockopt, getsockname, getpeername, sendto,
sendmsg, recvfrom, recvmsg, shutdown, recvmmsg, sendmmsg): New entries.
2015-11-15 03:05:34 +00:00
5f394f5e14 i386: wire up direct socket syscalls
Starting with linux commit v4.2-rc1-64-g9dea5dc, x86 has direct
socket syscalls in addition to traditional socketcall syscall.

* linux/i386/syscallent.h (socket, socketpair, bind, connect, listen,
accept4, getsockopt, setsockopt, getsockname, getpeername, sendto,
sendmsg, recvfrom, recvmsg, shutdown): New entries.
2015-11-15 03:05:34 +00:00
Heiko Carstens
4b499f4190 s390, s390x: update syscall tables
* linux/s390/syscallent.h: Add new syscalls available with kernel 4.3.0.
* linux/s390x/syscallent.h: Likewise.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2015-11-11 22:32:37 +00:00
370eb16ed2 Fix *_printer_defs.h rules ambiguousness
There is an ambiguousness in *_printer_defs.h rules definition:

$ grep '^[^ ]*_defs\.h: ' Makefile.am
m%_defs.h: $(srcdir_mpers_source_files)
%_printer_defs.h: $(srcdir_mpers_source_files)

While it appears to work with GNU make, it has to be fixed nevertheless.

* Makefile.am (m%_defs.h): Rename to m%_type_defs.h.
(mpers_m32_targets): Rename m32_defs.h to m32_type_defs.h.
(mpers_mx32_targets): Rename mx32_defs.h to mx32_type_defs.h.
* mpers_type.h: Rename m32_defs.h to m32_type_defs.h,
mx32_defs.h to mx32_type_defs.h.
* .gitignore: Likewise.

Reported-by: Elliott Hughes <enh@google.com>
2015-11-07 23:33:47 +00:00
c3410ba543 fcntl.c: make use of RVAL_DECODED
* fcntl.c (SYS_FUNC(fcntl)): Return RVAL_DECODED for write-only operations.
2015-10-09 02:18:27 +00:00
2512003cea desc.c: move parser of fcntl syscall to a separate file
* fcntl.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* desc.c (printflock64, printflock, SYS_FUNC(fcntl)): Move to fcntl.c.
2015-10-08 22:41:54 +00:00
5d68f468f4 desc.c: move parser of flock syscall to a separate file
* flock.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* desc.c (SYS_FUNC(flock)): Move to flock.c.
2015-10-08 22:41:54 +00:00
f4d6a0d4e1 tests: fix false uio.test failures
* tests/uio.c (main): Use descriptor number 0 in pread/pwrite
and preadv/pwritev syscalls.
* tests/uio.expected: Update regexps.

Reported-by: Lennart Sorensen <lsorense@csclub.uwaterloo.ca>
2015-10-08 22:41:40 +00:00
Gabriel Laskar
ad25c74f4b Fix make -j builds
In files generated by mpers scripts, includes directives are taken from
original files where the type definition was done.  This causes to
include defs.h in multiple files.  defs.h includes printers.h header,
which is a generated header.

This patch add an explicit dependency to printers.h for the mpers
scripts.

* Makefile.am (mpers-m%.stamp): Add printers.h to order-only
prerequisites.

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2015-10-01 22:20:10 +00:00
Mike Frysinger
0656ce9822 mpers: fix shell code to conform better to POSIX
The `echo -n` behavior is non-portable, so use printf instead.

* generate_mpers_am.sh: Change `echo -n` to `printf`.
2015-09-29 19:38:26 +00:00
Gabriel Laskar
9c4fc3404c ioctl: fix ioctl command number decoding in case of conflicts
When a command number was decoded through ioctl_decode_command_number(),
there was no check for conflicts with other potential ioctls numbers.

For example:
	ioctl(fd, MCE_GET_RECORD_LEN, &i);
output:
	ioctl(3, MIXER_READ(1), 0x7ffddce74a58) = 0
instead of:
	ioctl(3, MIXER_READ(1) or MCE_GET_RECORD_LEN, 0x7ffee435ce08) = 0

* ioctl.c (SYS_FUNC(ioctl)): Fix ioctl command number decoding
in case of conflicts.
* tests/ioctl.c (main): Add a case for command number conflicts.

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2015-09-23 23:29:30 +00:00
fb2a54300e tests: convert ioctl.test from match_grep to match_diff
* tests/ioctl.c (main): Print expected output.
* tests/ioctl.test: Use match_diff instead of match_grep.
* tests/ioctl.expected: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove ioctl.expected.
2015-09-23 23:29:27 +00:00
7a12974e95 Convert parser of seccomp filter program to new mpers infrastructure
* seccomp_fprog.h: New file.
* fetch_seccomp_fprog.c: New file.
* Makefile.am (strace_SOURCES): Add them.
* seccomp.c: Include "seccomp_fprog.h".
(print_seccomp_filter): Use fetch_seccomp_fprog.
2015-09-20 00:02:26 +00:00
3b731941f3 tests/init.sh: enhance match_grep error diagnostics
* tests/init.sh (match_grep): Check patterns one by one,
output only those patterns that didn't match.
2015-09-19 04:04:49 +03:00
a69854a90b tests/init.sh: fix comment
* tests/init.sh (match_awk): Fix usage description.
2015-09-19 04:04:49 +03:00
39e3be6d74 tests: add one more case to select.test
* tests/select.c (main): Check how timeout is printed
on exiting syscall.
2015-09-19 04:04:49 +03:00
10a40757bf tests: uncouple pselect6 from select.test
* tests/select.c Do not include <string.h>.
Include <sys/syscall.h>.
[!__NR_select]: Skip the test.
(main): Remove pselect6 support, test just select syscall.
* tests/select.test: Remove all pselect6 checks, test just
select syscall.
2015-09-19 04:04:49 +03:00
100bf7c896 tests: robustify select test
* tests/select.c: Do not include <assert.h>.
(main): Skip the test instead of assertions.
Add some padding to the timeval structure.
2015-09-19 04:04:49 +03:00
81ea4bf063 tests: add one more case to pselect6.test
* tests/pselect6.c (main): Check how timeout is printed
on exiting syscall.
2015-09-19 04:04:49 +03:00
5d98310e00 tests: robustify pselect6 test
* tests/pselect6.c: Do not include <assert.h> and <string.h>.
Include <sys/syscall.h>.
[!__NR_pselect6]: Skip the test.
(main): Skip the test instead of assertions.
Add some padding to the timespec structure.
2015-09-19 04:04:49 +03:00
4cb5ccca24 Convert another parser of struct timeval to new mpers infrastructure
* print_time.c (sprint_timeval): New mpers printer.
[ALPHA] (sprint_timeval32): New function.
* defs.h [ALPHA] (sprint_timeval32): New prototype.
(bitness_t, TIMEVAL_TEXT_BUFSIZE, printtv_bitness, sprinttv): Remove.
* desc.c (decode_select): Replace bitness parameter with two printers.
Use them instead of printtv_bitness and sprinttv.
(sys_oldselect, sys_select): Pass print_timeval and sprint_timeval
to decode_select.
[ALPHA] (sys_osf_select): Pass print_timeval32 and sprint_timeval32
to decode_select.
(pselect6): Pass print_timespec and sprint_timespec to decode_select.
* time.c (UTIME_NOW, UTIME_OMIT, current_time_t_is_compat,
struct timeval32, printtv_bitness, do_sprinttv, sprinttv): Remove.
2015-09-19 04:04:49 +03:00
2950de3631 Convert another parser of struct timespec to new mpers infrastructure
* print_time.c (sprint_timespec): New mpers printer.
* defs.h (TIMESPEC_TEXT_BUFSIZE): Update.
(sprint_timespec): Remove.
* time.c (sprint_timespec): Remove.
* net.c (sys_recvmmsg): Update callers.
* poll.c (decode_poll_exiting): Likewise.
2015-09-19 04:04:49 +03:00
6c528f5502 tests: add another case to pselect6 test
* tests/pselect6.c: Include <sys/time.h>.
(handler): New function.
(main): Install an interval timer.
Use it to check how ERESTARTNOHAND is printed.
2015-09-19 04:04:49 +03:00
f57edf4d37 Fix decoding of gettimeofday and settimeofday
* time.c (print_timezone): new function.
(sys_gettimeofday, sys_settimeofday): Use it instead of print_timeval
to print struct timezone.
[ALPHA] (sys_osf_gettimeofday, sys_osf_settimeofday): Use it
instead of print_timeval32 to print struct timezone.
* tests/xettimeofday.c: New file.
* tests/xettimeofday.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add xettimeofday.
(TESTS): Add xettimeofday.
* tests/.gitignore: Add xettimeofday.
2015-09-19 04:04:49 +03:00
f1e3a32045 Convert parser of struct timeval to new mpers infrastructure
* defs.h (printtv, printtv_special): Remove.
[ALPHA] (print_timeval32, print_timeval32_pair): New prototypes.
* print_time.c (print_timeval): New mpers printer.
[ALPHA] (print_timeval32, print_timeval32_pair): New functions.
* time.c (sys_gettimeofday, sys_settimeofday): Use print_timeval
instead of printtv.
[ALPHA] (sys_osf_gettimeofday, sys_osf_settimeofday):
Use print_timeval32 instead of printtv_bitness.
* utimes.c [ALPHA] (sys_osf_utimes): Use print_timeval32_pair
instead of printtv_bitness.
2015-09-19 04:04:49 +03:00
5938526c81 Convert parser of struct timespec to new mpers infrastructure
* defs.h (print_timespec): Remove.
* print_time.c (print_timespec): New mpers printer.
* futex.c (sys_futex): Use print_timespec instead of printtv.
* ipc_sem.c (sys_semtimedop): Likewise.
* mq.c (sys_mq_timedsend, sys_mq_timedreceive): Likewise.
* time.c (clock_settime, clock_gettime, clock_nanosleep): Likewise.
(print_timespec): Remove.
2015-09-19 04:04:49 +03:00