Commit Graph

4887 Commits

Author SHA1 Message Date
8f73dc556e tests: check -e signal=set syntax
* tests/qual_signal.c: New file.
* tests/qual_signal.test: New test.
* tests/.gitignore: Add qual_signal.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add qual_signal.test.
2016-11-18 00:11:27 +00:00
1658e9d4c6 Make -e fault= expressions cumulative
Change the way how subsequent -e fault= expressions are interpreted
to implement a cumulative behavior.  For example,
-e fault=file:when=3+ -e fault=chdir
now specifies that all chdir syscalls and 3+ file related syscalls
except chdir are subject for fault injection.

* syscall.c (qualify): Do not reset qual_vec for QUAL_FAULT.
* tests/fault_injection.test: Check it.
2016-11-17 15:44:21 +00:00
622af42dc3 tests: check syscall fault injection
* tests/fault_injection.c: New file.
* tests/fault_injection.test: New test.
* tests/fault_syntax.test: Likewise.
* tests/.gitignore: Add fault_injection.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add fault_injection.test and fault_syntax.test.
2016-11-16 17:27:46 +00:00
9cb6e03d4f Implement syscall fault injection
Introduce new -e fault=EXPR syntax that can be used to specify a subset
of syscalls that are subject of syscall fault injection, an error code
that has to be injected, and a frequency of injection.

The expression specifying syscall fault injection has the following
format: SET[:error=ERRNO][:when=FIRST[+[STEP]]]
where only SET is a required part and all the rest is optional.

The method used to implement syscall fault injection is the following:
on entering syscall the syscall number is substituted by an invalid
syscall number -1, and on exiting syscall the error code returned by
the kernel is substituted with the error code specified in the fault
expression.

This implementaion is based on the prototype developed
by Nahim El Atmani as a part of his GSoC 2016 strace project.

* defs.h (struct fault_opts): New forward declaration.
(struct tcb): Add fault_vec field.
(TCB_FAULT_INJ, QUAL_FAULT): New macros.
* strace.1: Document -e fault expression syntax.
* strace.c (usage): Mention -e fault expression.
(droptcb): Deallocate fault_vec member.
* syscall.c (qual_fault, arch_set_scno, arch_set_error): New prototypes.
(qual_options): Add "fault" option.
(struct fault_opts): New structure.
(num_faults): New variable.
(fault_vec): New array.
(syscall_fault_injected, tcb_fault_opts, reallocate_fault,
find_errno_by_name, qual_syscall_ex, strip_prefix, parse_fault_token,
parse_fault_expression, qual_fault, inject_syscall_fault_entering,
update_syscall_fault_exiting): New functions.
(qual_syscall): Use qual_syscall_ex.
(qualify_one): Add argument: a pointer to struct fault_opts, all callers
changed.  Copy struct fault_opts from the pointer to fault_vec.
Use reallocate_fault.
(qualify_scno, qualify_syscall_class, qualify_syscall_name): Add
argument: a pointer to struct fault_opts.
(qualify): Use reallocate_fault.  Do not check "all" class for
QUAL_FAULT qualifier.
(lookup_class): Check for "all" class.
(trace_syscall_entering): Use inject_syscall_fault_entering.
(trace_syscall_exiting): Use update_syscall_fault_exiting.  Clear
TCB_FAULT_INJ flag along with TCB_INSYSCALL.  Print " (INJECTED)" suffix
when the syscall has been injected successfully.
[ARCH_REGS_FOR_GETREGSET && !HAVE_GETREGS_OLD]
(ptrace_setregset): New function.
(ptrace_setregset_or_setregs): Define to ptrace_setregset.
[ARCH_REGS_FOR_GETREGS && !HAVE_GETREGS_OLD]
(ptrace_setregs): New function.
(ptrace_setregset_or_setregs): Define to ptrace_setregs.
[ptrace_setregset_or_setregs] (set_regs): New function.
Include "set_scno.c" and "set_error.c"
* NEWS: Mention this enhancement.
2016-11-16 17:26:58 +00:00
f1d0729f17 Implement arch specific methods of changing syscall number and error code
This introduces arch_set_error and arch_set_scno functions for each
supported architecture, needed to implement syscall fault injection.

* linux/aarch64/set_error.c: New file.
* linux/aarch64/set_scno.c: Likewise.
* linux/alpha/set_error.c: Likewise.
* linux/alpha/set_scno.c: Likewise.
* linux/arc/set_error.c: Likewise.
* linux/arc/set_scno.c: Likewise.
* linux/arm/set_error.c: Likewise.
* linux/arm/set_scno.c: Likewise.
* linux/avr32/set_error.c: Likewise.
* linux/avr32/set_scno.c: Likewise.
* linux/bfin/set_error.c: Likewise.
* linux/bfin/set_scno.c: Likewise.
* linux/crisv10/set_error.c: Likewise.
* linux/crisv10/set_scno.c: Likewise.
* linux/crisv32/set_error.c: Likewise.
* linux/crisv32/set_scno.c: Likewise.
* linux/hppa/set_error.c: Likewise.
* linux/hppa/set_scno.c: Likewise.
* linux/i386/set_error.c: Likewise.
* linux/i386/set_scno.c: Likewise.
* linux/ia64/set_error.c: Likewise.
* linux/ia64/set_scno.c: Likewise.
* linux/m68k/set_error.c: Likewise.
* linux/m68k/set_scno.c: Likewise.
* linux/metag/set_error.c: Likewise.
* linux/metag/set_scno.c: Likewise.
* linux/microblaze/set_error.c: Likewise.
* linux/microblaze/set_scno.c: Likewise.
* linux/mips/set_error.c: Likewise.
* linux/mips/set_scno.c: Likewise.
* linux/nios2/set_error.c: Likewise.
* linux/nios2/set_scno.c: Likewise.
* linux/or1k/set_error.c: Likewise.
* linux/or1k/set_scno.c: Likewise.
* linux/powerpc/set_error.c: Likewise.
* linux/powerpc/set_scno.c: Likewise.
* linux/powerpc64/set_error.c: Likewise.
* linux/powerpc64/set_scno.c: Likewise.
* linux/riscv/set_error.c: Likewise.
* linux/riscv/set_scno.c: Likewise.
* linux/s390/set_error.c: Likewise.
* linux/s390/set_scno.c: Likewise.
* linux/s390x/set_error.c: Likewise.
* linux/s390x/set_scno.c: Likewise.
* linux/sh/set_error.c: Likewise.
* linux/sh/set_scno.c: Likewise.
* linux/sh64/set_error.c: Likewise.
* linux/sh64/set_scno.c: Likewise.
* linux/sparc/set_error.c: Likewise.
* linux/sparc/set_scno.c: Likewise.
* linux/sparc64/set_error.c: Likewise.
* linux/sparc64/set_scno.c: Likewise.
* linux/tile/set_error.c: Likewise.
* linux/tile/set_scno.c: Likewise.
* linux/x32/set_error.c: Likewise.
* linux/x32/set_scno.c: Likewise.
* linux/x86_64/set_error.c: Likewise.
* linux/x86_64/set_scno.c: Likewise.
* linux/xtensa/set_error.c: Likewise.
* linux/xtensa/set_scno.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
2016-11-16 02:33:13 +00:00
05a3b0b518 cris: add syscall tables
The incomplete CRIS support introduced by commit v4.5.18-77-gea0e6e8
should not have been merged because it lacks essential parts, e.g.
syscall tables.

This change adds missing syscall tables for crisv10 and crisv32.

* linux/crisv10/syscallent.h: New file.
* linux/crisv32/syscallent.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
2016-11-16 02:32:43 +00:00
081b2a821b Introduce string_to_uint_ex and string_to_uint_upto functions
* defs.h (string_to_uint_ex): New prototype.
(string_to_uint_upto): New function, a thin wrapper around
string_to_uint_ex.
* util.c (string_to_uint_ex): New function.
(string_to_uint): Change into a thin wrapper around string_to_uint_upto.
* strace.c (init): Use string_to_uint_upto.
* syscall.c (qualify_scno, qual_signal, qual_desc): Use
string_to_uint_upto instead of string_to_uint.
2016-11-16 01:41:51 +00:00
0323fa3217 Split qual_syscall into separate functions
Split qual_syscall into qualify_scno, qualify_syscall_class,
and qualify_syscall_name.
This might be needed later to implement syscall fault injection.

* syscall.c (qualify_scno, qualify_syscall_class, qualify_syscall_name):
New functions.
(qual_syscall): Use them.
2016-11-16 01:41:51 +00:00
b299b3e611 xtensa: wire up new syscalls
* linux/xtensa/syscallent.h [342..347]: New entries.
2016-11-15 01:09:51 +00:00
5df31f90ec arc: wire up new syscalls
* linux/arc/syscallent.h [247, 248]: New entries.
2016-11-14 01:07:59 +00:00
24eb02da83 tests: fix potential compilation warning in ioctl_block.c
ioctl_block.c:48: warning: 'init_magic' defined but not used

* tests/ioctl_block.c (init_magic): Define only for
[BLKTRACESETUP && HAVE_STRUCT_BLK_USER_TRACE_SETUP].
2016-11-13 22:29:30 +00:00
Eugene Syromyatnikov
98a93b46fd Add support for pkey_mprotect, pkey_alloc, pkey_free syscalls
* linux/32/syscallent.h: Add syscall entries for pkey_* calls.
* linux/64/syscallent.h: Likewise.
* linux/arm/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/mips/syscallent-n32.h: Likewise.
* linux/mips/syscallent-n64.h: Likewise.
* linux/mips/syscallent-o32.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* mem.c (do_mprotect): New function, common handler for mprotect and
pkey_mprotect.
(SYS_FUNC(mprotect)): Convert to wrapper around do_mprotect.
(SYS_FUNC(pkey_mprotect)): New function.
* xlat/pkey_access.in: New file.
* pkeys.c: New file containing implementation of pkey_alloc and
pkey_free.
* Makefile.am: Add it.
* NEWS: Mention this enhancement.
* tests/.gitignore: Add pkey_alloc, pkey_free, and pkey_mprotect.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add pkey_alloc.test, pkey_free.test, and
pkey_mprotect.test.
* tests/pkey_alloc.c: New file.
* tests/pkey_free.c: Likewise.
* tests/pkey_mprotect.c: Likewise.
* tests/pkey_alloc.test: New test.
* tests/pkey_free.test: Likewise.
* tests/pkey_mprotect.test: Likewise.
2016-11-13 21:41:58 +00:00
Eugene Syromyatnikov
13c467bf69 tests: fix "constant is too large" compilation warnings
alarm.c: In function 'main':
alarm.c:41: warning: integer constant is too large for 'long' type
aio.c: In function 'main':
aio.c:162: warning: integer constant is too large for 'long' type
btrfs.c: In function 'btrfs_test_sync_ioctls':
btrfs.c:202: warning: integer constant is too large for 'long' type
btrfs.c: In function 'btrfs_test_subvol_ioctls':
btrfs.c:289: warning: integer constant is too large for 'long' type
btrfs.c:290: warning: integer constant is too large for 'long' type
dup2.c: In function 'main':
dup2.c:12: warning: integer constant is too large for 'long' type
dup2.c:13: warning: integer constant is too large for 'long' type
dup3.c: In function 'main':
dup3.c:13: warning: integer constant is too large for 'long' type
dup3.c:14: warning: integer constant is too large for 'long' type
epoll_create.c: In function 'main':
epoll_create.c:12: warning: integer constant is too large for 'long' type
epoll_ctl.c: In function 'invoke_syscall':
epoll_ctl.c:14: warning: integer constant is too large for 'long' type
faccessat.c: In function 'main':
faccessat.c:13: warning: integer constant is too large for 'long' type
fchdir.c: In function 'main':
fchdir.c:12: warning: integer constant is too large for 'long' type
struct_flock.c: In function 'invoke_test_syscall':
struct_flock.c:48: warning: integer constant is too large for 'long' type
struct_flock.c: In function 'test_flock_einval':
struct_flock.c:58: warning: integer constant is too large for 'long' type
struct_flock.c:59: warning: integer constant is too large for 'long' type
fcntl64.c: In function 'test_flock64_einval':
fcntl64.c:44: warning: integer constant is too large for 'long' type
fcntl64.c:45: warning: integer constant is too large for 'long' type
fcntl.c: In function 'test_flock64_einval':
fcntl.c:44: warning: integer constant is too large for 'long' type
fcntl.c:45: warning: integer constant is too large for 'long' type
fdatasync.c: In function 'main':
fdatasync.c:12: warning: integer constant is too large for 'long' type
flock.c: In function 'main':
flock.c:13: warning: integer constant is too large for 'long' type
xstatx.c: In function 'main':
xstatx.c:255: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatfsx.c: In function 'main':
xstatfsx.c:113: warning: integer constant is too large for 'long' type
fsync.c: In function 'main':
fsync.c:12: warning: integer constant is too large for 'long' type
ftruncate64.c: In function 'main':
ftruncate64.c:39: warning: integer constant is too large for 'long' type
futimesat.c: In function 'main':
futimesat.c:52: warning: integer constant is too large for 'long' type
futimesat.c:59: warning: integer constant is too large for 'long' type
get_mempolicy.c: In function 'main':
get_mempolicy.c:83: warning: integer constant is too large for 'long' type
get_mempolicy.c:84: warning: integer constant is too large for 'long' type
get_mempolicy.c:85: warning: integer constant is too large for 'long' type
get_mempolicy.c:86: warning: integer constant is too large for 'long' type
getdents.c: In function 'main':
getdents.c:109: warning: integer constant is too large for 'long' type
getdents.c:110: warning: integer constant is too large for 'long' type
getdents.c:114: warning: integer constant is too large for 'long' type
getdents64.c: In function 'main':
getdents64.c:114: warning: integer constant is too large for 'long' type
getdents64.c:115: warning: integer constant is too large for 'long' type
getdents64.c:119: warning: integer constant is too large for 'long' type
xgetrlimit.c: In function 'main':
xgetrlimit.c:71: warning: integer constant is too large for 'long' type
ioctl_block.c:44: warning: integer constant is too large for 'long' type
ioctl_block.c: In function 'main':
ioctl_block.c:136: warning: integer constant is too large for 'long' type
ioctl_block.c:137: warning: integer constant is too large for 'long' type
ioctl_block.c:161: warning: integer constant is too large for 'long' type
ioctl_block.c:170: warning: integer constant is too large for 'long' type
ioctl_block.c:171: warning: integer constant is too large for 'long' type
ioctl_evdev.c:42: warning: integer constant is too large for 'long' type
ioctl_mtd.c:46: warning: integer constant is too large for 'long' type
ioctl_rtc.c:40: warning: integer constant is too large for 'long' type
ioperm.c: In function 'main':
ioperm.c:12: warning: integer constant is too large for 'long' type
ioctl_v4l2.c: In function 'main':
ioctl_v4l2.c:409: warning: integer constant is too large for 'long' type
ipc.c: In function 'ipc_call':
ipc.c:52: warning: integer constant is too large for 'long' type
kill.c: In function 'main':
kill.c:59: warning: integer constant is too large for 'long' type
kill.c:62: warning: integer constant is too large for 'long' type
kill.c:63: warning: integer constant is too large for 'long' type
kill.c:68: warning: integer constant is too large for 'long' type
linkat.c: In function 'main':
linkat.c:14: warning: integer constant is too large for 'long' type
linkat.c:15: warning: integer constant is too large for 'long' type
mbind.c: In function 'main':
mbind.c:41: warning: integer constant is too large for 'long' type
mbind.c:43: warning: integer constant is too large for 'long' type
mbind.c:44: warning: integer constant is too large for 'long' type
migrate_pages.c: In function 'main':
migrate_pages.c:41: warning: integer constant is too large for 'long' type
In file included from mkdirat.c:10:
umode_t.c: In function 'test_syscall':
umode_t.c:47: warning: integer constant is too large for 'long' type
mknod.c: In function 'call_mknod':
mknod.c:16: warning: integer constant is too large for 'long' type
mknod.c: In function 'main':
mknod.c:23: warning: integer constant is too large for 'long' type
mknod.c:49: warning: integer constant is too large for 'long' type
mknod.c:56: warning: integer constant is too large for 'long' type
mknodat.c:12: warning: integer constant is too large for 'long' type
mknodat.c: In function 'call_mknodat':
mknodat.c:17: warning: integer constant is too large for 'long' type
mknodat.c: In function 'main':
mknodat.c:24: warning: integer constant is too large for 'long' type
mknodat.c:50: warning: integer constant is too large for 'long' type
mknodat.c:57: warning: integer constant is too large for 'long' type
mmap.c: In function 'main':
mmap.c:51: warning: integer constant is too large for 'long' type
move_pages.c: In function 'print_stat_pages':
move_pages.c:139: warning: integer constant is too large for 'long' type
move_pages.c: In function 'print_move_pages':
move_pages.c:166: warning: integer constant is too large for 'long' type
move_pages.c: In function 'main':
move_pages.c:188: warning: integer constant is too large for 'long' type
mq_sendrecv.c: In function 'main':
mq_sendrecv.c:238: warning: integer constant is too large for 'long' type
mq_sendrecv.c:401: warning: integer constant is too large for 'long' type
mq_sendrecv.c:403: warning: integer constant is too large for 'long' type
nsyscalls.c: In function 'test_syscall':
nsyscalls.c:64: warning: integer constant is too large for 'long' type
nsyscalls.c:65: warning: integer constant is too large for 'long' type
nsyscalls.c:66: warning: integer constant is too large for 'long' type
nsyscalls.c:67: warning: integer constant is too large for 'long' type
nsyscalls.c:68: warning: integer constant is too large for 'long' type
nsyscalls.c:69: warning: integer constant is too large for 'long' type
preadv-pwritev.c: In function 'main':
preadv-pwritev.c:162: warning: comparison between signed and unsigned
prlimit64.c: In function 'main':
prlimit64.c:65: warning: integer constant is too large for 'long' type
prlimit64.c:70: warning: integer constant is too large for 'long' type
remap_file_pages.c: In function 'main':
remap_file_pages.c:42: warning: integer constant is too large for 'long' type
remap_file_pages.c:43: warning: integer constant is too large for 'long' type
remap_file_pages.c:45: warning: integer constant is too large for 'long' type
renameat.c: In function 'main':
renameat.c:15: warning: integer constant is too large for 'long' type
renameat.c:16: warning: integer constant is too large for 'long' type
rt_sigqueueinfo.c: In function 'main':
rt_sigqueueinfo.c:41: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c: In function 'k_tgsigqueueinfo':
rt_tgsigqueueinfo.c:45: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c:46: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c:47: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c: In function 'main':
rt_tgsigqueueinfo.c:67: warning: integer constant is too large for 'long' type
sendfile.c: In function 'main':
sendfile.c:110: warning: integer constant is too large for 'long' type
sendfile64.c: In function 'main':
sendfile64.c💯 warning: integer constant is too large for 'long' type
set_mempolicy.c: In function 'main':
set_mempolicy.c:129: warning: integer constant is too large for 'long' type
set_mempolicy.c:130: warning: integer constant is too large for 'long' type
setrlimit.c: In function 'main':
setrlimit.c:44: warning: integer constant is too large for 'long' type
socketcall.c: In function 'test_socketcall':
socketcall.c:58: warning: integer constant is too large for 'long' type
splice.c: In function 'main':
splice.c:41: warning: integer constant is too large for 'long' type
splice.c:42: warning: integer constant is too large for 'long' type
splice.c:45: warning: integer constant is too large for 'long' type
splice.c:46: warning: integer constant is too large for 'long' type
symlinkat.c: In function 'main':
symlinkat.c:12: warning: integer constant is too large for 'long' type
sync_file_range.c: In function 'main':
sync_file_range.c:42: warning: integer constant is too large for 'long' type
sync_file_range.c:43: warning: integer constant is too large for 'long' type
syslog.c: In function 'main':
syslog.c:14: warning: integer constant is too large for 'long' type
tee.c: In function 'main':
tee.c:41: warning: integer constant is too large for 'long' type
tee.c:42: warning: integer constant is too large for 'long' type
timer_create.c: In function 'main':
timer_create.c:52: warning: integer constant is too large for 'long' type
timer_create.c:84: warning: integer constant is too large for 'long' type
timer_create.c:85: warning: integer constant is too large for 'long' type
truncate64.c: In function 'main':
truncate64.c:41: warning: integer constant is too large for 'long' type
xgetrlimit.c: In function 'main':
xgetrlimit.c:71: warning: integer constant is too large for 'long' type
umode_t.c: In function 'test_syscall':
umode_t.c:46: warning: integer constant is too large for 'long' type
unlinkat.c: In function 'main':
unlinkat.c:13: warning: integer constant is too large for 'long' type
waitpid.c: In function 'main':
waitpid.c:43: warning: integer constant is too large for 'long' type
waitid.c: In function 'poison':
waitid.c:141: warning: integer constant is too large for 'long' type
xetpriority.c: In function 'main':
xetpriority.c:15: warning: integer constant is too large for 'long' type
xetpriority.c:19: warning: integer constant is too large for 'long' type
xetpriority.c:20: warning: integer constant is too large for 'long' type
xetpgid.c: In function 'main':
xetpgid.c:43: warning: integer constant is too large for 'long' type
xetpgid.c:47: warning: integer constant is too large for 'long' type
xetpgid.c:48: warning: integer constant is too large for 'long' type

(SLES 11SP4, i386)

* tests/alarm.c (main): Add proper suffix to integer constant.
* tests/aio.c (main): Likewise.
* tests/btrfs.c (btrfs_test_sync_ioctls, btrfs_test_subvol_ioctls): Likewise.
* tests/dup2.c (main): Likewise.
* tests/dup3.c (main): Likewise.
* tests/epoll_create.c (main): Likewise.
* tests/epoll_ctl.c (invoke_syscall): Likewise.
* tests/faccessat.c (main): Likewise.
* tests/fchdir.c (main): Likewise.
* tests/fcntl.c (test_flock64_einval): Likewise.
* tests/fcntl64.c (test_flock64_einval): Likewise.
* tests/fdatasync.c (main): Likewise.
* tests/flock.c (main): Likewise.
* tests/fstat64.c (SAMPLE_SIZE): Likewise.
* tests/fstat.c (SAMPLE_SIZE): Likewise.
* tests/fsync.c (main): Likewise.
* tests/ftruncate64.c (main): Likewise.
* tests/futimesat.c (main): Likewise.
* tests/get_mempolicy.c (main): Likewise.
* tests/getdents.c (main): Likewise.
* tests/getdents64.c (main): Likewise.
* tests/ioctl_block.c (lmagic, main): Likewise.
* tests/ioctl_evdev.c (lmagic): Likewise.
* tests/ioctl_mtd.c (lmagic): Likewise.
* tests/ioctl_rtc.c (lmagic): Likewise.
* tests/ioctl_v4l2.c (main): Likewise.
* tests/ioperm.c (main): Likewise.
* tests/ipc.c (ipc_call): Likewise.
* tests/kill.c (main): Likewise.
* tests/linkat.c (main): Likewise.
* tests/lstat64.c (SAMPLE_SIZE): Likewise.
* tests/lstat.c (SAMPLE_SIZE): Likewise.
* tests/mbind.c (main): Likewise.
* tests/migrate_pages.c (main): Likewise.
* tests/mkdirat.c (TEST_SYSCALL_PREFIX_ARGS): Likewise.
* tests/mknod.c (call_mknod, main): Likewise.
* tests/mknodat.c (fd, call_mknodat, main): Likewise.
* tests/mmap.c (main): Likewise.
* tests/move_pages.c (print_stat_pages, print_move_pages): Likewise.
* tests/mq_sendrecv.c (main): Likewise.
* tests/nsyscalls.c (test_syscall): Likewise.
* tests/prlimit64.c (main): Likewise.
* tests/remap_file_pages.c (main): Likewise.
* tests/renameat.c (main): Likewise.
* tests/rt_sigqueueinfo.c (main): Likewise.
* tests/rt_tgsigqueueinfo.c (k_tgsigqueueinfo, main): Likewise.
* tests/sendfile.c (main): Likewise.
* tests/sendfile64.c (main): Likewise.
* tests/set_mempolicy.c (main): Likewise.
* tests/setrlimit.c (main): Likewise.
* tests/socketcall.c (test_socketcall): Likewise.
* tests/splice.c (main): Likewise.
* tests/stat64.c (SAMPLE_SIZE): Likewise.
* tests/stat.c (SAMPLE_SIZE): Likewise.
* tests/struct_flock.c (invoke_test_syscall, test_flock_einval): Likewise.
* tests/symlinkat.c (main): Likewise.
* tests/sync_file_range.c (main): Likewise.
* tests/syslog.c (main): Likewise.
* tests/tee.c (main): Likewise.
* tests/timer_create.c (main): Likewise.
* tests/truncate64.c (main): Likewise.
* tests/umode_t.c (test_syscall): Likewise.
* tests/unlinkat.c (main): Likewise.
* tests/waitid.c (main): Likewise.
* tests/waitpid.c (main): Likewise.
* tests/xetpgid.c (main): Likewise.
* tests/xetpriority.c (main): Likewise.
* tests/xgetrlimit.c (main): Likewise.
* tests/xstatfsx.c (main) [CHECK_ODD_SIZE]: Likewise.
* tests/xstatx.c (main): Likewise.
2016-11-13 21:36:58 +00:00
Eugene Syromyatnikov
35126cda20 tests: fix "comparison between signed and unsigned" compilation warnings
preadv-pwritev.c: In function 'main':
preadv-pwritev.c:162: warning: comparison between signed and unsigned
readv.c: In function 'main':
readv.c:148: warning: comparison between signed and unsigned
recvmsg.c: In function 'main':
recvmsg.c:148: warning: comparison between signed and unsigned

* tests/preadv-pwritev.c (main): Cast r_len to int.
* tests/readv.c (main): Likewise.
* tests/recvmsg.c (main): Likewise.
2016-11-13 19:30:11 +00:00
695545a8b3 syscall.c: refactor getregs_old fallback in get_regs
This change moves remaining arch specific getregs_old code into
appropriate arch subdirectories and removes unnecessary code
duplication.

* linux/getregs_old.h: New file.
* linux/powerpc/getregs_old.h: Likewise.
* linux/powerpc64/getregs_old.h: Likewise.
* linux/x86_64/getregs_old.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* syscall.c: Include "getregs_old.h".
[X86_64 || POWERPC]: Remove.
[ARCH_REGS_FOR_GETREGSET] (ptrace_getregset_or_getregs): Define
to ptrace_getregset.
[ARCH_REGS_FOR_GETREGS] (ptrace_getregset_or_getregs): Define
to ptrace_getregs.
(get_regs): Check for ptrace_getregset_or_getregs instead
of ARCH_REGS_FOR_GETREGSET and ARCH_REGS_FOR_GETREGS.  Use
ptrace_getregset_or_getregs instead of ptrace_getregset and
ptrace_getregs.  Check for HAVE_GETREGS_OLD instead of X86_64
and POWERPC.  Use use_getregs_old instead of getregset_support
and old_kernel.
2016-11-13 11:16:15 +00:00
Eugene Syromyatnikov
e061d67dff Rename BUILD_BUG_ON_ZERO macro
In order to avoid name clash on distributions which decide to include
kernel headers instead of UAPI ones.  For example, on SLES 11SP4:

gcc -DHAVE_CONFIG_H -I./linux/x86_64 -I./linux -I. -Wall -O2 -c net.c
In file included from /usr/include/linux/sysctl.h:25:0,
                 from /usr/include/linux/netfilter.h:6,
                 from /usr/include/linux/netfilter_arp.h:8,
                 from /usr/include/linux/netfilter_arp/arp_tables.h:14,
                 from net.c:60:
net.c: In function 'print_packet_mreq':
gcc_compat.h:59:27: error: negative width in bit-field '<anonymous>'
 # define MUST_BE_ARRAY(a) BUILD_BUG_ON_ZERO(!SAME_TYPE((a), &(a)[0]))
                           ^
defs.h:76:53: note: in expansion of macro 'MUST_BE_ARRAY'
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]) + MUST_BE_ARRAY(a))
                                                     ^
net.c:747:22: note: in expansion of macro 'ARRAY_SIZE'
   if (mreq.mr_alen > ARRAY_SIZE(mreq.mr_address))
                      ^
due to the fact BUILD_BUG_ON_ZERO is already defined in <linux/kernel.h>.

* gcc_compat.h (BUILD_BUG_ON_ZERO): Rename to FAIL_BUILD_ON_ZERO.
(MUST_BE_ARRAY): Update usage.
2016-11-13 11:04:49 +00:00
c93f39ca5b syscall.c: factor out ptrace_getregs from get_regs
Move the code that calls ptrace(PTRACE_GETREGS) to a separate function.

* syscall.c (ptrace_getregs): New function.
(get_regs): Use it.
2016-11-12 21:29:58 +00:00
1d886734c7 syscall.c: rename get_regset to ptrace_getregset
* syscall.c (get_regset): Rename to ptrace_getregset.
(get_regs): Rename get_regset to ptrace_getregset.
2016-11-12 21:29:58 +00:00
Andreas Schwab
a00648aa2b m68k: switch to PTRACE_GETREGS
* Makefile.am (EXTRA_DIST): Add linux/m68k/arch_regs.h, remove
linux/m68k/get_syscall_result.c.
* linux/m68k/arch_regs.c (m68k_d0, ARCH_PC_PEEK_ADDR): Don't
define.
(m68k_regs, m68k_usp_ptr, ARCH_PC_REG, ARCH_REGS_FOR_GETREGS):
Define.
* linux/m68k/arch_regs.h: New file.
* linux/m68k/arch_sigreturn.c (arch_sigreturn): Use m68k_usp_ptr.
* linux/m68k/get_error.c (get_error): Use m68k_regs.d0.
* linux/m68k/get_scno.c (arch_get_scno): Use m68k_regs.orig_d0.
* linux/m68k/get_syscall_args.c (get_syscall_args): Use m68k_regs.
* linux/m68k/get_syscall_result.c: Remove.
2016-11-12 21:29:58 +00:00
Andreas Schwab
f8d3d18f39 tests: do not run old_mmap test on m68k
* tests/old_mmap.c: Skip test on m68k.
2016-11-12 21:29:58 +00:00
5e33997559 syscall.c: introduce reallocate_vec function
This might be needed later to implement syscall fault injection.

* syscall.c (reallocate_vec): New function.
(reallocate_qual): Use it.
2016-11-12 21:29:58 +00:00
5d2293dea6 Fix prototypes of qual_desc, qual_signal, and qual_syscall functions
* syscall.c (qual_desc, qual_signal, qual_syscall): Fix prototypes.
(struct qual_options): Fix type of "qualify" member.
2016-11-12 21:29:58 +00:00
Eugene Syromyatnikov
f793bda073 linux/x32/syscallent.h: fix syscallent array initialisation on x32
Why gcc didn't complain about it? It is definitely an index clash.

* linux/x32/syscallent.h: Change initializer indices for empty records from
[327 ... 511] to [329 ... 511].
2016-11-12 21:03:55 +03:00
b5b750b289 Introduce upoke function
This will be needed to implement fault injection on those architectures
that lack PTRACE_SETREGSET/PTRACE_SETREGS support.

* defs.h (upoke): New prototype.
* upoke.c: New file.
* Makefile.am (libstrace_a_SOURCES): Add it.
2016-11-11 17:53:44 +00:00
Gleb Fotengauer-Malinovskiy
d3fc04ebdf Update ioctl entries from linux 4.9
* linux/32/ioctls_inc_align32.h: Update from linux v4.9 using ioctls_gen.sh.
* linux/32/ioctls_inc_align64.h: Likewise.
* linux/64/ioctls_inc.h: Likewise.
* linux/x32/ioctls_inc0.h: Likewise.
* NEWS: Mention this.
2016-11-11 17:53:28 +00:00
Eugene Syromyatnikov
916b0c3594 Update NEWS 2016-11-10 22:44:49 +03:00
Mikulas Patocka
a507a0bb77 Add support for decoding of DM_* ioctl commands
* dm.c: New file.
* xlat/dm_flags.in: Likewise.
* Makefile.am (strace_SOURCES): Add dm.c.
* configure.ac (AC_CHECK_HEADERS): Add linux/dm-ioctl.h.
* defs.h (dm_ioctl): New prototype.
* ioctl.c (ioctl_decode) [HAVE_LINUX_DM_IOCTL_H]: Call dm_ioctl
for 0xfd ioctl type.
* tests/ioctl_dm.c: New file.
* tests/ioctl_dm-v.c: Likewise.
* tests/ioctl_dm.test: New test.
* tests/ioctl_dm-v.test: Likewise.
* tests/.gitignore: Add ioctl_dm and ioctl_dm-v.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add ioctl_dm.test and ioctl_dm-v.test.

Co-authored-by: Eugene Syromyatnikov <evgsyr@gmail.com>
2016-11-10 22:44:49 +03:00
98b944bb66 Introduce ALIGNOF macro
* gcc_compat.h (ALIGNOF): New macro.
2016-11-10 22:44:49 +03:00
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