Commit Graph

3264 Commits

Author SHA1 Message Date
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
f94d8d6e55 Remove unused parser of adjtime syscall
* time.c (sys_adjtime): Remove.
2015-09-19 04:04:49 +03:00
c648b4a832 Fix decoding of clock_nanosleep
* time.c (sys_clock_nanosleep): Use is_erestart,
temporarily_clear_syserror, and restore_cleared_syserror.
* tests/clock_nanosleep.c: New file.
* tests/clock_nanosleep.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add clock_nanosleep.
(TESTS): Add clock_nanosleep.test.
* tests/.gitignore: Add clock_nanosleep.
2015-09-19 04:04:49 +03:00
9af94a2f48 Add is_erestart helper function
* defs.h (is_erestart): New prototype.
* syscall.c (is_erestart): New function.
* time.c (sys_nanosleep): Use is_erestart,
temporarily_clear_syserror, and restore_cleared_syserror.
2015-09-19 04:04:49 +03:00
3858b93ad9 Add helper functions to clear/restore syserror
* defs.h (temporarily_clear_syserror, restore_cleared_syserror):
New prototypes.
* syscall.c (saved_u_error): New variable.
(temporarily_clear_syserror, restore_cleared_syserror): New functions.
* aio.c (sys_io_getevents): Use temporarily_clear_syserror
and restore_cleared_syserror.
* mq.c (sys_mq_timedreceive): Likewise.
* signal.c (sys_rt_sigtimedwait): Likewise.
2015-09-19 04:04:49 +03:00
593602ce5a tests: add nanosleep.test
* tests/nanosleep.c: New file.
* tests/nanosleep.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add nanosleep.
(TESTS): Add nanosleep.test.
* tests/.gitignore: Add nanosleep.
2015-09-19 04:04:48 +03:00
640623c41e tests: rewrite restart_syscall in C
* tests/restart_syscall.c: New file.
* tests/restart_syscall.expected: Remove.
* tests/restart_syscall_unknown.expected: Remove.
* tests/restart_syscall.test: Update to use restart_syscall.
* tests/Makefile.am (check_PROGRAMS): Add restart_syscall.
(EXTRA_DIST): Remove restart_syscall.expected
and restart_syscall_unknown.expected.
* tests/.gitignore: Add restart_syscall.
2015-09-19 04:04:48 +03:00
135f5cf634 Properly initialize siginfo_t object passed to print_stopped function
* strace.c (trace): Clear the whole siginfo_t variable before passing it
to ptrace(PTRACE_GETSIGINFO) because the latter may initialize only a
part of the structure.
2015-09-19 04:04:48 +03:00
9d4c892ceb tests: add clock_xettime.test
* tests/clock_xettime.c: New file.
* tests/clock_xettime.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add clock_xettime.
(TESTS): Add clock_xettime.test.
* tests/.gitignore: Add clock_xettime.
2015-09-19 04:04:48 +03:00
322be80342 Convert parser of struct itimerval to new mpers infrastructure
* defs.h [ALPHA] (print_itimerval32): New prototype.
* print_time.c (print_itimerval): New mpers printer.
[ALPHA] (timeval32_t): New typedef.
[ALPHA] (print_timeval32_t, print_itimerval32): New functions.
* time.c (sys_getitimer, sys_setitimer): Use print_itimerval instead
of printitv.
[ALPHA] (sys_osf_getitimer, sys_osf_setitimer): Use print_itimerval32
instead of printitv_bitness.
(tprint_timeval32, tprint_timeval, printitv_bitness, printitv): Remove.
2015-09-19 04:04:27 +03:00
12431f76be tests: add xetitimer.test
* tests/xetitimer.c: New file.
* tests/xetitimer.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add xetitimer.
(TESTS): Add xetitimer.test.
* tests/.gitignore: Add xetitimer.
2015-09-19 04:04:27 +03:00
2206085929 Convert parser of struct itimerspec to new mpers infrastructure
* print_time.c (print_itimerspec): New mpers printer.
* time.c (sys_timer_settime, sys_timer_gettime, sys_timerfd,
sys_timerfd_settime, sys_timerfd_gettime): Use it instead of printitv.
2015-09-19 04:03:47 +03:00
207ba11125 print_time.c: introduce print_timespec_t helper
* print_time.c (time_fmt): New constant string.
(print_timeval_t): Use it.
(print_timespec_t): New function.
(print_timespec_t_utime): Use it.
2015-09-17 23:23:45 +00:00
79cafcd337 tests: add timerfd_xettime.test
* tests/timerfd_xettime.c: New file.
* tests/timerfd_xettime.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add timerfd_xettime.
(TESTS): Add timerfd_xettime.test.
* tests/.gitignore: Add timerfd_xettime.
2015-09-17 23:23:41 +00:00
1314098cde tests: add timer_xettime.test
* tests/timer_xettime.c: New file.
* tests/timer_xettime.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add timer_xettime.
(TESTS): Add timer_xettime.test.
* tests/.gitignore: Add timer_xettime.
2015-09-17 23:22:43 +00:00