]> granicus.if.org Git - strace/log
strace
7 years agoImplement arch specific methods of changing syscall number and error code
Dmitry V. Levin [Tue, 15 Nov 2016 17:38:21 +0000 (17:38 +0000)]
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.

7 years agocris: add syscall tables
Dmitry V. Levin [Wed, 16 Nov 2016 02:25:47 +0000 (02:25 +0000)]
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.

7 years agoIntroduce string_to_uint_ex and string_to_uint_upto functions
Dmitry V. Levin [Wed, 16 Nov 2016 00:58:05 +0000 (00:58 +0000)]
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.

7 years agoSplit qual_syscall into separate functions
Dmitry V. Levin [Tue, 15 Nov 2016 22:57:33 +0000 (22:57 +0000)]
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.

7 years agoxtensa: wire up new syscalls
Dmitry V. Levin [Tue, 15 Nov 2016 01:09:51 +0000 (01:09 +0000)]
xtensa: wire up new syscalls

* linux/xtensa/syscallent.h [342..347]: New entries.

7 years agoarc: wire up new syscalls
Dmitry V. Levin [Mon, 14 Nov 2016 01:07:59 +0000 (01:07 +0000)]
arc: wire up new syscalls

* linux/arc/syscallent.h [247, 248]: New entries.

7 years agotests: fix potential compilation warning in ioctl_block.c
Dmitry V. Levin [Sun, 13 Nov 2016 22:29:30 +0000 (22:29 +0000)]
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].

7 years agoAdd support for pkey_mprotect, pkey_alloc, pkey_free syscalls
Eugene Syromyatnikov [Sat, 12 Nov 2016 17:54:56 +0000 (20:54 +0300)]
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.

7 years agotests: fix "constant is too large" compilation warnings
Eugene Syromyatnikov [Sun, 13 Nov 2016 16:14:46 +0000 (19:14 +0300)]
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:100: 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.

7 years agotests: fix "comparison between signed and unsigned" compilation warnings
Eugene Syromyatnikov [Sun, 13 Nov 2016 18:30:25 +0000 (21:30 +0300)]
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.

7 years agosyscall.c: refactor getregs_old fallback in get_regs
Dmitry V. Levin [Sat, 12 Nov 2016 10:59:57 +0000 (10:59 +0000)]
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.

7 years agoRename BUILD_BUG_ON_ZERO macro
Eugene Syromyatnikov [Sun, 13 Nov 2016 10:45:59 +0000 (13:45 +0300)]
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.

7 years agosyscall.c: factor out ptrace_getregs from get_regs
Dmitry V. Levin [Sat, 12 Nov 2016 10:44:18 +0000 (10:44 +0000)]
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.

7 years agosyscall.c: rename get_regset to ptrace_getregset
Dmitry V. Levin [Sat, 12 Nov 2016 01:11:22 +0000 (01:11 +0000)]
syscall.c: rename get_regset to ptrace_getregset

* syscall.c (get_regset): Rename to ptrace_getregset.
(get_regs): Rename get_regset to ptrace_getregset.

7 years agom68k: switch to PTRACE_GETREGS
Andreas Schwab [Sat, 12 Nov 2016 19:02:23 +0000 (20:02 +0100)]
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.

7 years agotests: do not run old_mmap test on m68k
Andreas Schwab [Sat, 12 Nov 2016 09:48:55 +0000 (10:48 +0100)]
tests: do not run old_mmap test on m68k

* tests/old_mmap.c: Skip test on m68k.

7 years agosyscall.c: introduce reallocate_vec function
Dmitry V. Levin [Sat, 12 Nov 2016 00:36:01 +0000 (00:36 +0000)]
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.

7 years agoFix prototypes of qual_desc, qual_signal, and qual_syscall functions
Dmitry V. Levin [Fri, 11 Nov 2016 23:55:23 +0000 (23:55 +0000)]
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.

7 years agolinux/x32/syscallent.h: fix syscallent array initialisation on x32
Eugene Syromyatnikov [Sat, 12 Nov 2016 10:20:51 +0000 (13:20 +0300)]
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].

7 years agoIntroduce upoke function
Dmitry V. Levin [Fri, 11 Nov 2016 17:10:33 +0000 (17:10 +0000)]
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.

7 years agoUpdate ioctl entries from linux 4.9
Gleb Fotengauer-Malinovskiy [Fri, 11 Nov 2016 17:51:45 +0000 (20:51 +0300)]
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.

7 years agoUpdate NEWS
Eugene Syromyatnikov [Sat, 29 Oct 2016 01:34:37 +0000 (04:34 +0300)]
Update NEWS

7 years agoAdd support for decoding of DM_* ioctl commands
Mikulas Patocka [Sun, 2 Oct 2016 21:59:06 +0000 (17:59 -0400)]
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>
7 years agoIntroduce ALIGNOF macro
Dmitry V. Levin [Thu, 10 Nov 2016 10:29:46 +0000 (10:29 +0000)]
Introduce ALIGNOF macro

* gcc_compat.h (ALIGNOF): New macro.

7 years agoutil: add support for QUOTE_0_TERMINATED in user_style to ptrintstr_ex
Eugene Syromyatnikov [Mon, 10 Oct 2016 16:55:54 +0000 (19:55 +0300)]
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.

7 years agotests: check decoding of mq_{notify,open,timedreceive,timedsend,unlink}
Eugene Syromyatnikov [Thu, 27 Oct 2016 07:18:44 +0000 (10:18 +0300)]
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.

7 years agotests: skip times.test if CLOCK_PROCESS_CPUTIME_ID does not work
Dmitry V. Levin [Tue, 8 Nov 2016 15:32:47 +0000 (15:32 +0000)]
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.

7 years agotests: add tests for perf_event_attr structure decoding in perf_event_open
Eugene Syromyatnikov [Sun, 2 Oct 2016 22:35:53 +0000 (01:35 +0300)]
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.

7 years agoImplement decoding of perf_event_attr structure in perf_event_open syscall
Eugene Syromyatnikov [Sat, 3 Sep 2016 11:44:48 +0000 (14:44 +0300)]
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.

7 years agotests: fix name spelling
Eugene Syromyatnikov [Sun, 30 Oct 2016 20:44:50 +0000 (23:44 +0300)]
tests: fix name spelling

7 years agotests: fix name spelling
Eugene Syromyatnikov [Sun, 30 Oct 2016 20:44:50 +0000 (23:44 +0300)]
tests: fix name spelling

7 years agoUpdate NEWS
Eugene Syromyatnikov [Sat, 29 Oct 2016 01:34:37 +0000 (04:34 +0300)]
Update NEWS

7 years agoFix typo in comment in tests/quotactl.h
Eugene Syromyatnikov [Sun, 30 Oct 2016 20:16:34 +0000 (23:16 +0300)]
Fix typo in comment in tests/quotactl.h

7 years agotests: fix invalid pointer checks in quotactl test
Eugene Syromyatnikov [Sun, 30 Oct 2016 19:28:37 +0000 (22:28 +0300)]
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.

7 years agotests: fix invalid pointer checks in getcpu test
Eugene Syromyatnikov [Sun, 30 Oct 2016 19:27:55 +0000 (22:27 +0300)]
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.

7 years agotests: fix invalid pointer checks in request_key test
Eugene Syromyatnikov [Sun, 30 Oct 2016 19:27:18 +0000 (22:27 +0300)]
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.

7 years agotests: fix invalid pointer checks in add_key test
Eugene Syromyatnikov [Sun, 30 Oct 2016 19:27:07 +0000 (22:27 +0300)]
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.

7 years agostatfs: use printxval_search
Eugene Syromyatnikov [Sat, 29 Oct 2016 02:29:15 +0000 (05:29 +0300)]
statfs: use printxval_search

* print_statfs.c (print_statfs_type): Use printxval_search for printing
FS magic xlat value.

7 years agoutil: add printing helper for sorted xlat arrays
Eugene Syromyatnikov [Sat, 29 Oct 2016 02:26:50 +0000 (05:26 +0300)]
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.

7 years agodefs: add check for argument being array to ARRAY_SIZE macro
Eugene Syromyatnikov [Sat, 29 Oct 2016 02:24:08 +0000 (05:24 +0300)]
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.

7 years agotests: check decoding of oldfstat, oldlstat, and oldstat syscalls
Eugene Syromyatnikov [Mon, 24 Oct 2016 01:50:36 +0000 (04:50 +0300)]
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.

7 years agotests: additional tests of stat decoders
Eugene Syromyatnikov [Wed, 19 Oct 2016 08:11:41 +0000 (11:11 +0300)]
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.

7 years agotests: prepare for additional tests of stat decoders
Eugene Syromyatnikov [Wed, 19 Oct 2016 08:11:41 +0000 (11:11 +0300)]
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.

7 years agoProvide a safe definition of O_ACCMODE
Dmitry V. Levin [Fri, 28 Oct 2016 02:19:58 +0000 (02:19 +0000)]
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.

7 years agoImplement dumping of mq_timedsend and mq_timedreceive syscalls
Eugene Syromyatnikov [Thu, 27 Oct 2016 08:09:07 +0000 (11:09 +0300)]
Implement dumping of mq_timedsend and mq_timedreceive syscalls

* syscall.c (dumpio): Add SEN_mq_timedreceive and SEN_mq_timedsend.

7 years agomq: print msg_prio as a pointer, not as an immediate value
Eugene Syromyatnikov [Thu, 27 Oct 2016 07:14:49 +0000 (10:14 +0300)]
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.

7 years agomq: print msg payload only in case of successful mq_timedreceive call
Eugene Syromyatnikov [Thu, 27 Oct 2016 07:12:32 +0000 (10:12 +0300)]
mq: print msg payload only in case of successful mq_timedreceive call

Also, use u_rval for determining message size.

* mq.c (SYS_FUNC(mq_timedreceive)): Check for syserror and non-negative
u_rval before calling printstr on msg_ptr argument, or use printaddr otherwise;
provide u_rval as string size.

7 years agomq: Print msg_prio parameter as unsigned int in mq_timedsend
Eugene Syromyatnikov [Thu, 27 Oct 2016 07:07:29 +0000 (10:07 +0300)]
mq: Print msg_prio parameter as unsigned int in mq_timedsend

* mq.c (SYS_FUNC(mq_timedsend)): Change conversion specifier from "%ld"
to "%u", cast argument value to unsigned int.

7 years agomq: Properly print mq_flags field
Eugene Syromyatnikov [Thu, 27 Oct 2016 07:00:46 +0000 (10:00 +0300)]
mq: Properly print mq_flags field

mq_flags field of struct mq_attr can contain only O_NONBLOCK flag (other
flags are treated as invalid by mq_getsetattr). Moreover, this field is
ignored by mq_open at all (O_NONBLOCK is set via oflag, not via attr
attribute).

* xlat/mq_attr_flags.in: New file.
* print_mq_attr.c: Include xlat/mq_attr_flags.h.
(printmqattr): New parameter, bool decode_flags; cast members of struct
mq_attr to long long type; use mq_attr_flags xlat for printing mq_flags;
print mq_flags as flags only in case decode_flags parameter is set
to true.
* mq.c (SYS_FUNC(mq_open)): Specify value of false for decode_flags
parameter of printmqattr call.
(SYS_FUNC(mq_getsetattr)): Specify value of true for decode_flags
parameter of printmqattr call.
* tests/mq.expected: Update expected output.

7 years agomq: Print msg_len parameter as kernel_ulong_t
Eugene Syromyatnikov [Thu, 27 Oct 2016 06:56:32 +0000 (09:56 +0300)]
mq: Print msg_len parameter as kernel_ulong_t

* mq.c (SYS_FUNC(mq_timedsend)): Change conversion specifier from "%lu"
to "%llu", use getarg_ull for obtaining msg_len parameter.
(SYS_FUNC(mq_timedreceive)): Likewise.

7 years agoprint_mq_attr: fix typo
Eugene Syromyatnikov [Thu, 27 Oct 2016 06:53:03 +0000 (09:53 +0300)]
print_mq_attr: fix typo

* print_mq_attr.c (printmqattr): Print field name "mq_curmsgs"
instead of "mq_curmsg".
* tests/mq.expected: Update expected output.

7 years agomq: print mqdes parameter as int
Eugene Syromyatnikov [Wed, 26 Oct 2016 14:41:54 +0000 (17:41 +0300)]
mq: print mqdes parameter as int

It is defined as int in <linux/posix_types.h>.

* mq.c (SYS_FUNC(mq_timedsend)): Use "%d" conversion specifier instead
of "%ld" for printing mqdes (0th parameter), cast parameter value to
int.
(SYS_FUNC(mq_timedreceive)): Likewise.
(SYS_FUNC(mq_notify)): Likewise.
(SYS_FUNC(mq_getsetattr)): Likewise.

7 years agomq: curly brackets usage fix
Eugene Syromyatnikov [Wed, 26 Oct 2016 14:38:43 +0000 (17:38 +0300)]
mq: curly brackets usage fix

Use curly brackets for denoting blocks in both of if branches if they
are already used in at least one branch.

7 years agotests: additional name_to_handle_at/open_by_handle_at checks
Eugene Syromyatnikov [Sun, 23 Oct 2016 20:33:02 +0000 (23:33 +0300)]
tests: additional name_to_handle_at/open_by_handle_at checks

* tests/file_handle.c: Additional name_to_handle_at/open_by_handle_at
checks.

7 years agotests: require only presence of __NR_* macros for file_handle test
Eugene Syromyatnikov [Sun, 23 Oct 2016 20:23:05 +0000 (23:23 +0300)]
tests: require only presence of __NR_* macros for file_handle test

* tests/file_handle.c: replace fcntl.h include with asm/unistd.h.
[MAX_HANDLE_SZ]: change to defined __NR_name_to_handle_at
&& defined __NR_open_by_handle_at, add fcntl.h include
[!MAX_HANDLE_SZ]: Add definition of MAX_HANDLE_SZ and struct
file_handle.
(main): Change name_to_handle_at and open_by_handle_at calls to syscall.

7 years agotests: proper type conversion in keyctl test
Eugene Syromyatnikov [Thu, 20 Oct 2016 22:38:47 +0000 (01:38 +0300)]
tests: proper type conversion in keyctl test

* tests/keyctl.c (printarg): Add intermediate conversion of arg to uintptr_t
since kernel_ulong_t may be of different size.

7 years agofile_handle: use separate xlat for name_ta_handle_at flags
Eugene Syromyatnikov [Thu, 20 Oct 2016 21:48:50 +0000 (00:48 +0300)]
file_handle: use separate xlat for name_ta_handle_at flags

Since the only two flags supported are AT_SYMLINK_FOLLOW and
AT_EMPTY_PATH.

* xlat/name_to_handle_at_flags.in: New file.
* file_handle.c (SYS_FUNC(name_to_handle_at)): Use name_to_handle_at_flags
for printing flags parameter.

7 years agotests: check decoding of kexec_file_load and kexec_load syscalls
Eugene Syromyatnikov [Thu, 20 Oct 2016 03:46:02 +0000 (06:46 +0300)]
tests: check decoding of kexec_file_load and kexec_load syscalls

* tests/kexec_file_load.c: New file.
* tests/kexec_load.c: Likewise.
* tests/kexec_file_load.test: New test.
* tests/kexec_load.test: Likewise.
* tests/.gitignore: Add kexec_file_load and kexec_load.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add kexec_file_load.test and kexec_load.test.

7 years agokexec: use widen_to_ulong since kexec_load has compat on x32/n32
Eugene Syromyatnikov [Thu, 20 Oct 2016 08:34:47 +0000 (11:34 +0300)]
kexec: use widen_to_ulong since kexec_load has compat on x32/n32

Curiously, kexec_load uses compat on x32/n32, so its parameters should
be 4 bytes in size on these ABIs.

* kexec.c (SYS_FUNC(kexec_load)): Use widen_to_ulong for casting
parameters to proper size on x32/n32.

7 years agokexec: fix zeroing of higher bits of flags parameter in kexec_load
Eugene Syromyatnikov [Thu, 20 Oct 2016 03:44:06 +0000 (06:44 +0300)]
kexec: fix zeroing of higher bits of flags parameter in kexec_load

* kexec.c (SYS_FUNC(kexec_load)): Perform type conversion before
negation in order to properly negate higher bits of KEXEC_ARCH_MASK.

7 years agokexec: add printing of struct kexec_segment field names
Eugene Syromyatnikov [Thu, 20 Oct 2016 03:42:29 +0000 (06:42 +0300)]
kexec: add printing of struct kexec_segment field names

* kexec.c (print_seg): Print field names of the kexec_segment structure.

7 years agotests: check decoding of unshare syscall
Eugene Syromyatnikov [Wed, 19 Oct 2016 18:16:36 +0000 (21:16 +0300)]
tests: check decoding of unshare syscall

* tests/unshare.c: New file.
* tests/unshare.test: New test.
* tests/.gitignore: Add unshare.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add unshare.test.

7 years agoclone: use kernel_ulong_t as type of flags parameter of unshare call
Eugene Syromyatnikov [Wed, 19 Oct 2016 18:12:51 +0000 (21:12 +0300)]
clone: use kernel_ulong_t as type of flags parameter of unshare call

Kernel declares flags parameter as long and looks like x32 and n32
implement no compat for this call.

* clone.c (SYS_FUNC(unshare)): Use getarg_ull and printflags64 for
obtaining and parsing flags parameter.

7 years agoclone: use separate flag list for unshare
Eugene Syromyatnikov [Wed, 19 Oct 2016 18:09:58 +0000 (21:09 +0300)]
clone: use separate flag list for unshare

Not all clone flags could be passed to unshare (see check_unshare_flags
function in kernel/fork.c).

* xlat/unshare_flags.in: New file.
* clone.c (SYS_FUNC(unshare)): Use unshare_flags for printing flags
parameter.

7 years agotests: check decoding of setns syscall
Eugene Syromyatnikov [Tue, 18 Oct 2016 19:32:07 +0000 (22:32 +0300)]
tests: check decoding of setns syscall

* tests/setns.c: New file.
* tests/setns.test: New test.
* tests/.gitignore: Add setns.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add setns.test.

7 years agoclone: use separate xlat for nstype parameter of setns syscall
Eugene Syromyatnikov [Tue, 18 Oct 2016 18:17:33 +0000 (21:17 +0300)]
clone: use separate xlat for nstype parameter of setns syscall

nstype is not flag set but specific type value against which it is
compared in kernel (see kernel/nsproxy.c, SYSCALL_DEFINE2(setns, ...)).

* xlat/setns_types.in: New file.
* clone.c: Use printxval and setns_types for nstype parameter.

7 years agotests: check non-verbose capget/capset output
Eugene Syromyatnikov [Tue, 18 Oct 2016 11:04:20 +0000 (14:04 +0300)]
tests: check non-verbose capget/capset output

* tests/caps-abbrev.awk: New file.
* tests/caps-abbrev.c: Likewise.
* tests/caps-abbrev.test: New test.
* tests/.gitignore: Add caps-abbrev.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add caps-abbrev.test.
(EXTRA_DIST): Add caps-abbrev.awk.

7 years agotests: additional capset decoder checks
Eugene Syromyatnikov [Tue, 18 Oct 2016 07:16:23 +0000 (10:16 +0300)]
tests: additional capset decoder checks

* tests/caps.awk: Add patterns for additional checks.
* tests/caps.c: Implement additional checks.

7 years agotests: check decoding of fanotify_init syscall
Eugene Syromyatnikov [Mon, 17 Oct 2016 22:57:49 +0000 (01:57 +0300)]
tests: check decoding of fanotify_init syscall

* tests/fanotify_init.c: New file.
* tests/fanotify_init.test: New test.
* tests/.gitignore: Add fanotify_init.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add fanotify_init.test.

7 years agotests: some additional checks for fanotify_mark
Eugene Syromyatnikov [Mon, 17 Oct 2016 17:45:19 +0000 (20:45 +0300)]
tests: some additional checks for fanotify_mark

* tests/fanotify_mark.c (do_call): New function.
(main): Use it.

7 years agotests: use sprintrc in tests/fanotify_mark.c
Eugene Syromyatnikov [Mon, 17 Oct 2016 17:43:17 +0000 (20:43 +0300)]
tests: use sprintrc in tests/fanotify_mark.c

* tests/fanotify.c (main): Use sprintrc.

7 years agotests: check decoding of {init,finit,delete}_module syscalls
Eugene Syromyatnikov [Sun, 16 Oct 2016 23:17:48 +0000 (02:17 +0300)]
tests: check decoding of {init,finit,delete}_module syscalls

* tests/delete_module.c: New file.
* tests/finit_module.c: Likewise.
* tests/init_delete_module.h: Likewise.
* tests/init_module.c: Likewise.
* tests/delete_module.test: New test.
* tests/finit_module.test: Likewise.
* tests/init_module.test: Likewise.
* tests/.gitignore: Add delete_nodule, finit_module, and init_module.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add delete_module.test, finit_module.test,
and init_module.test.
(EXTRA_DIST): Add init_delete_module.h.

7 years agobjm: use getarg_ull for retrieving first two parameters of init_module syscall
Eugene Syromyatnikov [Sun, 16 Oct 2016 23:15:37 +0000 (02:15 +0300)]
bjm: use getarg_ull for retrieving first two parameters of init_module syscall

As init_module has no compat wrapper, its first parameter is a pointer
and the second is length, they both have the same size as kernel_ulong_t
type.

* bjm.c (SYS_FUNC(init_module)): Obtain first two parameters using
getarg_ull, print address argument using printaddr_ull, print length
argument using "%llu" conversion specifier.

7 years agoAdd printaddr_ull, change printaddr into a thin wrapper around it
Dmitry V. Levin [Fri, 28 Oct 2016 00:24:53 +0000 (00:24 +0000)]
Add printaddr_ull, change printaddr into a thin wrapper around it

* defs.h (printaddr_ull): New prototype.
(printaddr): Change to a static inline wrapper around printaddr_ull.
* util.c (printaddr): Rename to printaddr_ull, change argument type
to unsigned long long, change print format to %#llx.

7 years agoxlat: add values for MODULE_INIT_* constants
Eugene Syromyatnikov [Sun, 16 Oct 2016 23:14:00 +0000 (02:14 +0300)]
xlat: add values for MODULE_INIT_* constants

* bjm.c (MODULE_INIT_IGNORE_MODVERSIONS, MODULE_INIT_IGNORE_VERMAGIC):
Remove.
* xlat/module_init_flags.in: Add values for
MODULE_INIT_IGNORE_MODVERSIONS and MODULE_INIT_IGNORE_VERMAGIC records.

7 years agoRemove parser of create_module syscall
Eugene Syromyatnikov [Sun, 16 Oct 2016 11:42:32 +0000 (14:42 +0300)]
Remove parser of create_module syscall

Since create_module syscall is present only in kernels before Linux 2.6
and strace does not support those kernels, there is no use to keep this
parser any longer.

* bjm.c (SYS_FUNC(create_module)): Remove.
* linux/dummy.h (sys_create_module): Add stub alias.

7 years agotests: check decoding of process_vm_readv and process_vm_writev syscalls
Eugene Syromyatnikov [Sat, 15 Oct 2016 00:20:06 +0000 (03:20 +0300)]
tests: check decoding of process_vm_readv and process_vm_writev syscalls

* tests/process_vm_readv.c: New file.
* tests/process_vm_readv_writev.c: Likewise.
* tests/process_vm_writev.c: Likewise.
* tests/process_vm_readv.test: New test.
* tests/process_vm_writev.test: Likewise.
* tests/.gitignore: Add process_vm_readv and process_vm_writev.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add process_vm_readv.test and process_vm_writev.test.
(EXTRA_DIST): Add process_vm_readv_writev.c.

7 years agoprocess_vm: use widen_to_ulong for local_iovcnt, renote_iovcnt, and flags
Eugene Syromyatnikov [Fri, 14 Oct 2016 23:54:39 +0000 (02:54 +0300)]
process_vm: use widen_to_ulong for local_iovcnt, renote_iovcnt, and flags

* process_vm.c (SYS_FUNC(process_vm_readv),
SYS_FUNC(process_vm_writev)): Use widen_to_ulong for local_iovcnt,
renote_iovcnt, and flags parameters.

7 years agodefs: add widen_to_ulong macro
Eugene Syromyatnikov [Thu, 20 Oct 2016 08:33:51 +0000 (11:33 +0300)]
defs: add widen_to_ulong macro

This is similar to widen_to_long, but for unsigned values.

* defs.h (widen_to_ulong): New macro.

7 years agoprocess_vm: print pid argument as int
Eugene Syromyatnikov [Fri, 14 Oct 2016 15:42:36 +0000 (18:42 +0300)]
process_vm: print pid argument as int

* process_vm.c (SYS_FUNC(process_vm_readv),
SYS_FUNC(process_vm_writev)): Change conversion specifier for pid
argument from "%ld" to "%d".

7 years agoprocess_vm: remove syserror check for iovec printing
Eugene Syromyatnikov [Fri, 14 Oct 2016 23:57:47 +0000 (02:57 +0300)]
process_vm: remove syserror check for iovec printing

This check had been done by print_array inside tprint_iov anyway.

* process_vm.c (SYS_FUNC(process_vm_readv)): Use tprint_iov_upto for
printing local_iov; do not check for syserror, provide decode_iov
parameter to tprint_iov{,_upto} based on its value instead.

7 years agoio: use umoven_or_printaddr_ignore_syserror as umove function in tprint_iov_upto
Eugene Syromyatnikov [Fri, 14 Oct 2016 23:30:47 +0000 (02:30 +0300)]
io: use umoven_or_printaddr_ignore_syserror as umove function in tprint_iov_upto

This enables printing of iovec arrays even in case of failed syscall
(failed syscall doesn't mean that iovec itself is inaccessible and
useless).  One caveat here is that we should explicitly provide proper
IOV_DECODE_* value based on syserror value in case printing is performed
on exiting; we can't simply override it to IOV_DECODE_ADDR on exiting
when syserror is up, since this may be called by code which tries to
print iovec containing local data, which should be perfectly accessible
(on the other hand, there are no cases of such behaviour at the moment).

Since iovecs themselves are printed even if syscall has failed now,
preadv test is updated to reflect this.  It is notable, though, that this
is the only place where this case is checked.

* io.c (tprint_iov_upto): Specify umoven_or_printaddr_ignore_syserror
instead of umoven_or_printaddr as umoven_func parameter.
(SYS_FUNC(readv), do_preadv): Specify decode_iov parameter value
based on syserror(tcp) value.
* scsi.c: (print_sg_io_v3_res, print_sg_io_v4_res): Likewise.
* tests/preadv.c: Update expected output for the case when preadv
with singe-item iovec failed.

7 years agoMove umoven_or_printaddr_ignore_syserror to util.c
Eugene Syromyatnikov [Fri, 14 Oct 2016 23:27:21 +0000 (02:27 +0300)]
Move umoven_or_printaddr_ignore_syserror to util.c

* defs.h (umoven_or_printaddr_ignore_syserror): New prototype.
* v4l2.c (umoven_or_printaddr_ignore_syserror): Move ...
* util.c: ... here.

7 years agov4l2: check for verbose flag in umoven_or_printaddr_ignore_syserror
Eugene Syromyatnikov [Fri, 14 Oct 2016 22:56:10 +0000 (01:56 +0300)]
v4l2: check for verbose flag in umoven_or_printaddr_ignore_syserror

This change makes behaviour of umoven_or_printaddr_ignore_syserror in
line with umoven_or_printaddr when verbose flag is disabled.

* v4l2.c (umoven_or_printaddr_ignore_syserror): Simply call printaddr
when verbose flag is unset.

7 years agotests: check decoding of kcmp syscall
Eugene Syromyatnikov [Thu, 13 Oct 2016 17:16:24 +0000 (20:16 +0300)]
tests: check decoding of kcmp syscall

* tests/kcmp.c: New file.
* tests/kcmp.test: New test.
* tests/.gitignore: Add kcmp.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add kcmp.test.

7 years agokcmp: print index parameters of unknown commands as kernel_ulong_t
Dmitry V. Levin [Thu, 27 Oct 2016 22:44:08 +0000 (22:44 +0000)]
kcmp: print index parameters of unknown commands as kernel_ulong_t

* lookup_dcookie.c (SYS_FUNC(kcmp)): Use getarg_ull to retrieve idx1
and idx2, print them using %#llx format in case of unknown command.

7 years agotests: check decoding of inotify family syscalls
Eugene Syromyatnikov [Thu, 13 Oct 2016 10:15:32 +0000 (13:15 +0300)]
tests: check decoding of inotify family syscalls

* tests/inotify.c: New file.
* tests/inotify_init1.c: Likewise.
* tests/inotify.test: New test.
* tests/inotify_init1.test: Likewise.
* tests/.gitignore: Add inotify and inotify_init1.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add inotify.test and inotify_init1.test.

7 years agoxlat: use IN_* prefix for inotify_init1 flag constants
Eugene Syromyatnikov [Thu, 13 Oct 2016 07:50:40 +0000 (10:50 +0300)]
xlat: use IN_* prefix for inotify_init1 flag constants

* xlat/inotify_init_flags.in: Replace O_* prefix with IN_* prefix for
O_NONBLOCK and O_CLOEXEC constants, provide fallback definitions.

7 years agotests: check decoding of lookup_dcookie syscall
Eugene Syromyatnikov [Wed, 12 Oct 2016 07:36:28 +0000 (10:36 +0300)]
tests: check decoding of lookup_dcookie syscall

* tests/lookup_dcookie.c: New file.
* tests/lookup_dcookie.test: New test.
* tests/.gitignore: Add lookup_dcookie.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add lookup_dcookie.test.

7 years agolookup_dcookie: print len parameter as kernel_ulong_t
Eugene Syromyatnikov [Thu, 27 Oct 2016 07:24:21 +0000 (10:24 +0300)]
lookup_dcookie: print len parameter as kernel_ulong_t

It is size_t and without compat on x32/n32.

* lookup_dcookie.c (SYS_FUNC(lookup_dcookie)): Change conversion
specifier from "%lu" to "%llu", use getarg_ull for len argument
retrieval.

7 years agodefs.h: add offsetofend macro
Eugene Syromyatnikov [Sat, 3 Sep 2016 11:41:33 +0000 (14:41 +0300)]
defs.h: add offsetofend macro

Analogous to offsetof but returns structure offset after the specified
field.  Useful for checking whether specific field is present in obtained
data or specifying amount of data to copy based on the (last) field needed.

* defs.h (offsetofend): New macro.

7 years agotests: move ARG_STR and similar macros to tests.h
Eugene Syromyatnikov [Thu, 13 Oct 2016 07:26:07 +0000 (10:26 +0300)]
tests: move ARG_STR and similar macros to tests.h

* tests/add_key.c (_STR, ARG_STR): Move ...
* tests/tests.h: ... here.
(ARG_ULL_STR): New macro.
* tests/keyctl.c (ARG_STR): Remove.
* tests/quotactl.h (ARG_STR): Likewise.
* tests/request_key.c (ARG_STR): Likewise.

7 years agotests: move LL_PAIR and LL_VAL_TO_PAIR macros to tests.h
Eugene Syromyatnikov [Wed, 12 Oct 2016 07:24:00 +0000 (10:24 +0300)]
tests: move LL_PAIR and LL_VAL_TO_PAIR macros to tests.h

* tests/fadvise.h (LL_PAIR, LL_VAL_TO_PAIR): Move ...
* tests/tests.h: ... here.

7 years agotests: check decoding of ioprio_get and ioprio_set syscalls
Eugene Syromyatnikov [Tue, 4 Oct 2016 18:41:10 +0000 (21:41 +0300)]
tests: check decoding of ioprio_get and ioprio_set syscalls

* tests/ioprio.c: New file.
* tests/ioprio.test: New test.
* tests/.gitignore: Add ioprio.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add ioprio.test.

7 years agoxlat: provide fallback definitions for CLOCK_* constants
Eugene Syromyatnikov [Sun, 2 Oct 2016 21:55:34 +0000 (00:55 +0300)]
xlat: provide fallback definitions for CLOCK_* constants

Since new values have been added gradually over various kernel versions,
it's better to define them explicitly in order to avoid situations when
strace built with older kernel headers cannot decode some recently
defined values.

* xlat/clocknames.in: Add values for constants.

7 years agotests: move fill_memory and fill_memory_ex into a separate file
Eugene Syromyatnikov [Sun, 2 Oct 2016 20:39:11 +0000 (23:39 +0300)]
tests: move fill_memory and fill_memory_ex into a separate file

* tests/fill_memory.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
* tests/quotactl.h (fill_memory, fill_memory_ex): Move to fill_memory.c.
* tests/tests.h (fill_memory, fill_memory_ex): New prototypes.

7 years agotests: add period parameter to fill_memory_ex
Eugene Syromyatnikov [Fri, 30 Sep 2016 18:59:20 +0000 (21:59 +0300)]
tests: add period parameter to fill_memory_ex

* tests/quotactl.h (fill_memory_ex): Add period parameter,
use it as a divisor in non-constant part of value.
(fill_memory): Specify period of 0x80 to fill_memory_ex call.
* tests/quotactl-xfs.c (main): Likewise.

7 years agoPost-release administrivia
Dmitry V. Levin [Wed, 5 Oct 2016 06:19:41 +0000 (06:19 +0000)]
Post-release administrivia

* NEWS: Add a header line for the next release.
* debian/changelog.in: Add a changelog entry for 4.14-1.
* strace.spec.in: Likewise.

7 years agoPrepare for 4.14 release v4.14
Dmitry V. Levin [Tue, 4 Oct 2016 18:19:20 +0000 (18:19 +0000)]
Prepare for 4.14 release

* NEWS: Update for 4.14 release.

7 years agoGenerate SEN numbers in a locale independent order
Dmitry V. Levin [Tue, 4 Oct 2016 08:15:19 +0000 (08:15 +0000)]
Generate SEN numbers in a locale independent order

* generate_sen.sh: Sort SEN numbers using C collation rules.