]> granicus.if.org Git - strace/log
strace
7 years ago.gitignore: add missing files that should be ignored
Elvira Khabirova [Fri, 20 Jan 2017 18:21:02 +0000 (21:21 +0300)]
.gitignore: add missing files that should be ignored

* .gitignore: Add /ioctl_iocdef.[ih].

Fixes: 5679fad ("ioctlsort: get ioctl definitions from host, not build")
7 years agomips: use <asm/sgidefs.h>
Andre McCurdy [Fri, 5 Feb 2016 22:00:00 +0000 (14:00 -0800)]
mips: use <asm/sgidefs.h>

Build fix for MIPS with musl libc.

The MIPS specific header <sgidefs.h> is provided by glibc and uclibc
but not by musl. Regardless of the libc, the kernel headers provide
<asm/sgidefs.h> which provides the same definitions, so use that
instead.

* configure.ac: Replace <sgidefs.h> with <asm/sgidefs.h>.

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agoImplement decoding of ustat syscall
JingPiao Chen [Tue, 17 Jan 2017 07:55:58 +0000 (15:55 +0800)]
Implement decoding of ustat syscall

* configure.ac (AC_CHECK_HEADERS): Add ustat.h.
* ustat.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/dummy.h: Remove sys_ustat.
* tests/ustat.c: New file.
* tests/ustat.test: New test.
* tests/.gitignore: Add ustat.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add ustat.test.

7 years agoMakefile.am: allow indented DEF_MPERS_TYPE includes
JingPiao Chen [Thu, 19 Jan 2017 06:59:51 +0000 (14:59 +0800)]
Makefile.am: allow indented DEF_MPERS_TYPE includes

* Makefile.am (m%_type_defs.h): Change sed regular expression to allow
arbitrary number of whitespace characters between "#" symbol
and "include" directive.

7 years agostrace.1: fix formatting
JingPiao Chen [Tue, 17 Jan 2017 07:55:59 +0000 (15:55 +0800)]
strace.1: fix formatting

* strace.1: Remove misplaced .TP macros.

7 years agotests: drop non-USE_ASM_STAT case support
Dmitry V. Levin [Fri, 13 Jan 2017 20:07:09 +0000 (20:07 +0000)]
tests: drop non-USE_ASM_STAT case support

With the switch of fstatat family tests to USE_ASM_STAT variant,
there are no non-USE_ASM_STAT users left.  Remove support of unused
non-USE_ASM_STAT case.

* configure.ac (AC_CHECK_MEMBERS): Remove struct stat.st_mtim.tv_nsec.
* tests/fstatat.c (USE_ASM_STAT): Remove.
* tests/fstatx.c: Likewise.
* tests/lstatx.c: Likewise.
* tests/xstatx.c: Assume USE_ASM_STAT.
[!USE_ASM_STAT]: Remove.

7 years agotests: call newfstatat and fstatat64 syscalls directly
Dmitry V. Levin [Fri, 13 Jan 2017 19:54:57 +0000 (19:54 +0000)]
tests: call newfstatat and fstatat64 syscalls directly

Do not use glibc wrappers to call newfstatat and fstatat64.
These wrappers have various problems, e.g. they segfault on sparc64
and mips64 if BOGUS_STRUCT_STAT is not disabled, and they do wrong
conversion of timestamps on mips64.

* tests/fstatat.c (TEST_SYSCALL_INVOKE): Invoke the relevant syscall
directly.
(USE_ASM_STAT): Define.
* tests/fstatat64.c (TEST_BOGUS_STRUCT_STAT): Remove.
(STRUCT_STAT, STRUCT_STAT_STR, STRUCT_STAT_IS_STAT64): Define.

Based on patch by James Cowgill <james410@cowgill.org.uk>.

7 years agotests: remove redundant SAMPLE_SIZE definitions
Dmitry V. Levin [Fri, 13 Jan 2017 19:39:18 +0000 (19:39 +0000)]
tests: remove redundant SAMPLE_SIZE definitions

Remove all definitions of SAMPLE_SIZE that are identical to the fallback
definition in tests/xstatx.c.

* tests/fstat64.c (SAMPLE_SIZE): Remove.
* tests/lstat64.c (SAMPLE_SIZE): Remove.
* tests/stat64.c (SAMPLE_SIZE): Remove.

7 years agotests: change SAMPLE_SIZE type to libc_off_t
Dmitry V. Levin [Fri, 13 Jan 2017 19:31:30 +0000 (19:31 +0000)]
tests: change SAMPLE_SIZE type to libc_off_t

As ftruncate libc function and our create_sample function that calls
ftruncate both take size argument of type libc_off_t, change the type
of SAMPLE_SIZE constant to libc_off_t.

* tests/fstat.c (SAMPLE_SIZE): Cast to libc_off_t.
* tests/lstat.c (SAMPLE_SIZE): Likewise.
* tests/oldfstat.c (SAMPLE_SIZE): Likewise.
* tests/oldlstat.c (SAMPLE_SIZE): Likewise.
* tests/oldstat.c (SAMPLE_SIZE): Likewise.
* tests/stat.c (SAMPLE_SIZE): Likewise.
* tests/xstatx.c (SAMPLE_SIZE): Likewise.

7 years agoioctlsort: get ioctl definitions from host, not build
Alexey Neyman [Thu, 12 Jan 2017 21:15:59 +0000 (13:15 -0800)]
ioctlsort: get ioctl definitions from host, not build

When cross-compiling, ioctlsort must obtain _IOC_* values from the
host, build's values may be incompatible.

* ioctl_iocdef.c: New file.
* Makefile.am (EXTRA_DIST): Add it.
(ioctl_iocdef.i, ioctl_iocdef.h): New rules.
(ioctlsort%.o): Depend on ioctl_iocdef.h.
(CLEANFILES): Add ioctl_iocdef.h and ioctl_iocdef.i.
* ioctlsort.c: Include "ioctl_iocdef.h" instead of <linux/ioctl.h>.

Signed-off-by: Alexey Neyman <stilor@att.net>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agotests: treat struct stat mismatch as an error
Dmitry V. Levin [Fri, 13 Jan 2017 01:14:51 +0000 (01:14 +0000)]
tests: treat struct stat mismatch as an error

If the test detects struct stat mismatch, this is likely an error
in definitions of a stat structure that might affect strace as well.
Fail the test instead of skipping it to attract more attention.

* tests/xstatx.c (main): Return 1 instead of 77
in case of struct stat mismatch.

7 years agotests: rewrite diagnostics about struct stat mismatch
Dmitry V. Levin [Thu, 12 Jan 2017 23:01:32 +0000 (23:01 +0000)]
tests: rewrite diagnostics about struct stat mismatch

* tests/xstatx.c (LOG_STAT_OFFSETOF_SIZEOF): New macro.
(main): Use it to print struct stat mismatch details.

7 years agotests: fix typo in tests/xstatx.c
Dmitry V. Levin [Thu, 12 Jan 2017 22:52:17 +0000 (22:52 +0000)]
tests: fix typo in tests/xstatx.c

* tests/xstatx.c [!IS_FSTAT]: Define IS_FSTAT instead of IS_STAT.

7 years agotests: fix typo in mlock.c
JingPiao Chen [Thu, 12 Jan 2017 13:56:07 +0000 (21:56 +0800)]
tests: fix typo in mlock.c

* tests/mlock.c [!(__NR_mlock && __NR_munlock)]: Fix spelling
of SKIP_MAIN_UNDEFINED.

7 years agostrace: move description of -k option to the appropriate place
JingPiao Chen [Fri, 6 Jan 2017 07:16:27 +0000 (15:16 +0800)]
strace: move description of -k option to the appropriate place

Follow the example of strace.1 and put the description of -k option
into the  output format group.

* strace.c (usage): Move description of -k option to the output
format group.

7 years agoRemove redundant commas at the end of structure initializers
Dmitry V. Levin [Wed, 11 Jan 2017 23:48:41 +0000 (23:48 +0000)]
Remove redundant commas at the end of structure initializers

Automatically remove redundant commas using the following
sed expression:

git grep -El ',[[:space:]]+}' |xargs sed -ri 's/,([[:space:]]+\})/\1/'

* linux/32/syscallent.h: Remove redundant commas at the end of structure
initializers.
* linux/64/syscallent.h: Likewise.
* linux/alpha/syscallent.h: Likewise.
* linux/arm/syscallent.h: Likewise.
* linux/avr32/syscallent.h: Likewise.
* linux/bfin/syscallent.h: Likewise.
* linux/crisv10/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/microblaze/userent.h: Likewise.
* linux/mips/syscallent-n32.h: Likewise.
* linux/mips/syscallent-n64.h: Likewise.
* linux/mips/syscallent-o32.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/powerpc64/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* linux/xtensa/syscallent.h: Likewise.
* tests/kexec_file_load.c: Likewise.

Reported-by: Eugene Syromyatnikov <evgsyr@gmail.com>
7 years agotests: check decoding of scsi ioctl commands
Dmitry V. Levin [Tue, 10 Jan 2017 00:05:17 +0000 (00:05 +0000)]
tests: check decoding of scsi ioctl commands

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

7 years agoscsi: implement decoding of all SG_* ioctl commands
Dmitry V. Levin [Mon, 9 Jan 2017 16:01:08 +0000 (16:01 +0000)]
scsi: implement decoding of all SG_* ioctl commands

* print_sg_req_info.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/sg_scsi_reset.in: New file.
* scsi.c: Include "xlat/sg_scsi_reset.h".
(scsi_ioctl): Implement decoding of all SG_* ioctl commands.

7 years agoscsi: prepare for decoding of other SG_* ioctl commands
Dmitry V. Levin [Mon, 9 Jan 2017 13:53:27 +0000 (13:53 +0000)]
scsi: prepare for decoding of other SG_* ioctl commands

* scsi.c (scsi_ioctl): Introduce a switch statement.

7 years agotests: check decoding of ioctl SG_IO v3 commands
Dmitry V. Levin [Mon, 9 Jan 2017 00:22:42 +0000 (00:22 +0000)]
tests: check decoding of ioctl SG_IO v3 commands

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

7 years agotests: check decoding of ioctl SG_IO v4 commands
Dmitry V. Levin [Mon, 9 Jan 2017 00:22:42 +0000 (00:22 +0000)]
tests: check decoding of ioctl SG_IO v4 commands

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

7 years agoscsi: add fallback definitions for SG_* ioctl command constants
Dmitry V. Levin [Mon, 9 Jan 2017 02:40:08 +0000 (02:40 +0000)]
scsi: add fallback definitions for SG_* ioctl command constants

Unfortunately, <scsi/sg.h> from libc does not provide all constants
recognized by the kernel.

* xlat/scsi_sg_commands.in: New file.
* scsi.c: Include "xlat/scsi_sg_commands.h" instead of providing
a fallback definition of SG_IO.

7 years agoxlat: provide fallback definitions for BSG_FLAG_* constants
Dmitry V. Levin [Mon, 9 Jan 2017 00:13:58 +0000 (00:13 +0000)]
xlat: provide fallback definitions for BSG_FLAG_* constants

BSG_FLAG_* constants were introduced later than the header file where
they are defined.

* xlat/bsg_flags.in: Add default values for constants.

7 years agoxlat: provide fallback definitions for SG_FLAG_* constants
Dmitry V. Levin [Mon, 9 Jan 2017 00:13:58 +0000 (00:13 +0000)]
xlat: provide fallback definitions for SG_FLAG_* constants

Unfortunately, <scsi/sg.h> from libc does not provide all constants
recognized by the kernel.

* xlat/sg_io_flags.in: Add default values for constants.

7 years agosg_io_v4: print din_resid and dout_resid fields as signed integers
Dmitry V. Levin [Sun, 8 Jan 2017 21:43:41 +0000 (21:43 +0000)]
sg_io_v4: print din_resid and dout_resid fields as signed integers

* sg_io_v4.c (decode_response): Print din_resid and dout_resid fields
using %d format.

7 years agosg_io: cleanup printing of sg_io buffers
Dmitry V. Levin [Sun, 8 Jan 2017 18:31:51 +0000 (18:31 +0000)]
sg_io: cleanup printing of sg_io buffers

Turn print_sg_io_buffer into a universal sg_io buffer printer.

* sg_io_v3.c (print_sg_io_buffer): Add iovec_count argument.
Call tprint_iov_upto when iovec_count is non-zero.
(decode_request, decode_response): Do not call tprint_iov_upto directly,
use print_sg_io_buffer instead.
* sg_io_v4.c: Likewise.

7 years agosg_io: decode structures on exiting syscall in case of syserror
Dmitry V. Levin [Sun, 8 Jan 2017 17:43:21 +0000 (17:43 +0000)]
sg_io: decode structures on exiting syscall in case of syserror

The SCSI driver, starting with kernel commit v2.6.25-rc1~1230^2~78,
translates its "struct request.errors" to ioctl errors after
filling in all the output members of the SG_IO header structure.

As there is no easy way to tell SCSI layer errors from other syscall
errors, decode the structure on exiting syscall in case of syserror,
too.

* scsi.c (scsi_ioctl): Do not call set_tcb_priv_ulong, use
get_tcb_priv_data instead of get_tcb_priv_ulong, call decode_sg_io
unconditionally.
* sg_io_v3.c (decode_request): Save a copy of struct_sg_io_hdr using
set_tcb_priv_data.
(decode_response): Restore it using get_tcb_priv_data.  Print its i/o
fields when umove call fails.  Pass IOV_DECODE_STR to tprint_iov_upto
unconditionally.
* sg_io_v4.c (decode_request): Save a copy of struct sg_io_v4 using
set_tcb_priv_data.
(decode_response): Restore it using get_tcb_priv_data.  Print its i/o
fields when umove call fails.  Pass IOV_DECODE_STR to tprint_iov_upto
unconditionally.

7 years agosg_io: reorder printing of fields to follow structure order
Dmitry V. Levin [Sun, 8 Jan 2017 16:55:48 +0000 (16:55 +0000)]
sg_io: reorder printing of fields to follow structure order

* sg_io_v4.c (decode_request): Print timeout, flags, and usr_ptr fields
after dout_xferp field.

7 years agosg_io_v3: print sg_io_hdr.duration field as unsigned integer
Dmitry V. Levin [Sun, 8 Jan 2017 16:53:53 +0000 (19:53 +0300)]
sg_io_v3: print sg_io_hdr.duration field as unsigned integer

* sg_io_v3.c (decode_response): Print duration field using %u format.

7 years agosg_io_v3: print msg_status field
Dmitry V. Levin [Sun, 8 Jan 2017 16:52:05 +0000 (19:52 +0300)]
sg_io_v3: print msg_status field

* sg_io_v3.c (decode_response): Print msg_status field.

7 years agosg_io: print names of array fields and corresponding length fields
Dmitry V. Levin [Sun, 8 Jan 2017 16:00:01 +0000 (16:00 +0000)]
sg_io: print names of array fields and corresponding length fields

* sg_io_v3.c (decode_request): Print names of cmd_len, cmdp,
and dxferp fields.
(decode_response): Print names of dxferp, sb_len_wr, and sbp fields.
* sg_io_v4.c (decode_request): Print names of request_len, request,
dout_xfer_len, and dout_xferp fields.
(decode_response): Print names of response_len, response,
and din_xferp fields.

7 years agosg_io_v3: print status fields using %#x format specifier
Dmitry V. Levin [Sun, 8 Jan 2017 15:43:40 +0000 (15:43 +0000)]
sg_io_v3: print status fields using %#x format specifier

The formerly used format string %02x led to misleading output as there
was no clear indication sometimes whether the printed integer was
decimal or hexadecimal.

* sg_io_v3.c (decode_response): Print status and masked_status fields
using %#x format specifier instead of %02x.

7 years agosg_io_v4: print status fields in a hexadecimal form
Dmitry V. Levin [Sun, 8 Jan 2017 15:41:06 +0000 (15:41 +0000)]
sg_io_v4: print status fields in a hexadecimal form

The tradition is to print scsi status codes in a hexadecimal form.

* sg_io_v4.c (decode_response): Print driver_status, transport_status,
and device_status fields using %#x format specifier instead of %u.

7 years agosg_io_v4: print request_tag and generated_tag fields in hex
Dmitry V. Levin [Sun, 8 Jan 2017 15:36:42 +0000 (15:36 +0000)]
sg_io_v4: print request_tag and generated_tag fields in hex

The tradition is to print scsi tags in a hexadecimal form.

* sg_io_v4.c (decode_request): Print request_tag field
using ("%#" PRI__x64) format string.
(decode_response): Print generated_tag field using ("%#" PRI__x64)
format string.

7 years agosg_io_v4: print usr_ptr field in a hexadecimal form
Dmitry V. Levin [Sun, 8 Jan 2017 15:36:42 +0000 (15:36 +0000)]
sg_io_v4: print usr_ptr field in a hexadecimal form

As the nature of this field is pointer-like, print it
in a hexadecimal form.

* sg_io_v4.c (decode_request): Print usr_ptr field
using ("%#" PRI__x64) format string.

7 years agosg_io_v4: do not print spare_in and spare_out fields
Dmitry V. Levin [Sun, 8 Jan 2017 15:33:30 +0000 (15:33 +0000)]
sg_io_v4: do not print spare_in and spare_out fields

As the kernel does not touch these fields, there is no use
to print them.

* sg_io_v4.c (decode_request): Do not print spare_in field.
(decode_response): Do not print spare_out field.

7 years agosg_io: decode struct sg_io_hdr.info and struct sg_io_v4.info
Dmitry V. Levin [Sun, 8 Jan 2017 03:27:18 +0000 (03:27 +0000)]
sg_io: decode struct sg_io_hdr.info and struct sg_io_v4.info

Print struct sg_io_hdr.info and struct sg_io_v4.info using printflags.

* xlat/sg_io_info.in: New file.
* defs.h (sg_io_info): New xlat prototype.
* sg_io_v3.c: Include "xlat/sg_io_info.h".
(decode_response): Print struct_sg_io_hdr.info using printflags.
* sg_io_v4.c: (decode_response): Print struct sg_io_v4.info
using printflags.

7 years agosg_io: decode struct sg_io_hdr.flags and struct sg_io_v4.flags
Dmitry V. Levin [Sun, 8 Jan 2017 01:20:59 +0000 (01:20 +0000)]
sg_io: decode struct sg_io_hdr.flags and struct sg_io_v4.flags

Print struct sg_io_hdr.flags and struct sg_io_v4.flags using printflags.

* xlat/sg_io_flags.in: New file.
* sg_io_v3.c: Include "xlat/sg_io_flags.h".
(decode_request): Print struct_sg_io_hdr.flags using printflags.
* xlat/bsg_flags.in: New file.
* sg_io_v4.c: Include "xlat/bsg_flags.h".
(decode_request): Print struct sg_io_v4.flags using printflags.

7 years agoMpersify struct sg_io_hdr
Dmitry V. Levin [Sun, 8 Jan 2017 00:26:36 +0000 (00:26 +0000)]
Mpersify struct sg_io_hdr

struct sg_io_hdr contains pointers and therefore has to be mpersified.

* defs.h (decode_sg_io_v3): Remove prototype.
* sg_io_v3.c (struct_sg_io_hdr): Typedef to struct sg_io_hdr.
Mpersify it.
(decode_sg_io_v3): Wrap into MPERS_PRINTER_DECL.

7 years agoSplit scsi.c
Dmitry V. Levin [Sun, 8 Jan 2017 00:01:03 +0000 (00:01 +0000)]
Split scsi.c

Move decoders of SG_IO v3 and v4 APIs into separate files,
compile generic SG_IO decoder unconditionally.

* sg_io_v3.c: New file.
* sg_io_v4.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* defs.h (decode_sg_io_v3, decode_sg_io_v4): New prototypes.
* ioctl.c (ioctl_decode): Remove [HAVE_SCSI_SG_H] condition.
* scsi.c: (print_sg_io_res): Remove.
(print_sg_io_req): Rename to decode_sg_io, replace print_sg_io_v3_req
with decode_sg_io_v3, replace print_sg_io_v4_req with decode_sg_io_v4,
compile uncoditionally.
(scsi_ioctl): Replace print_sg_io_req and print_sg_io_res
with decode_sg_io, compile uncoditionally.
Move [HAVE_SCSI_SG_H] code to sg_io_v3.c.
Move [HAVE_LINUX_BSG_H] code to sg_io_v4.c.

7 years agoscsi: detect and print changes of interface id
Dmitry V. Levin [Sat, 7 Jan 2017 19:09:37 +0000 (19:09 +0000)]
scsi: detect and print changes of interface id

* scsi.c (print_sg_io_v3_res): Detect and print changes
of struct sg_io_hdr.interface_id field between entering and exiting
syscall.
(print_sg_io_v4_res): Detect and print changes of struct sg_io_v4.guard
field between entering and exiting syscall.

7 years agoscsi: print field names of all fields being printed
Dmitry V. Levin [Sat, 7 Jan 2017 19:01:27 +0000 (22:01 +0300)]
scsi: print field names of all fields being printed

* scsi.c (print_sg_io_v3_req): Always print the name
of struct sg_io_hdr.interface_id field.
(print_sg_io_v4_req): Always print the name of struct sg_io_v4.guard
field.
(print_sg_io_req): Print unknown interface id as an integer.
(scsi_ioctl): Save interface id on entering syscall and use it
on exiting syscall.

7 years agoscsi: print struct sg_io_hdr.dxfer_direction field name
Dmitry V. Levin [Sat, 7 Jan 2017 18:55:40 +0000 (21:55 +0300)]
scsi: print struct sg_io_hdr.dxfer_direction field name

* scsi.c (print_sg_io_v3_req): Print struct sg_io_hdr.dxfer_direction
field name.

7 years agoscsi: print "protocol" and "subprotocol" field names of struct sg_io_v4
Dmitry V. Levin [Sat, 7 Jan 2017 18:45:48 +0000 (21:45 +0300)]
scsi: print "protocol" and "subprotocol" field names of struct sg_io_v4

* scsi.c (print_sg_io_v4_req): Print field names
of struct sg_io_v4.protocol and struct sg_io_v4.subprotocol.

7 years agoPrint hexadecimal integer in error diagnostics using %#x
Dmitry V. Levin [Sat, 7 Jan 2017 16:44:44 +0000 (16:44 +0000)]
Print hexadecimal integer in error diagnostics using %#x

The formerly used format string %x led to misleading output as there was
no clear indication sometimes whether the printed integer was decimal or
hexadecimal.

* aio.c (startup_child, test_ptrace_seize): Print status
using %#x format specifier instead of %x.

7 years agoaio: print hexadecimal integer using %#x
Dmitry V. Levin [Sat, 7 Jan 2017 16:44:44 +0000 (16:44 +0000)]
aio: print hexadecimal integer using %#x

The formerly used format string %x led to misleading output as there was
no clear indication sometimes whether the printed integer was decimal or
hexadecimal.

* aio.c (print_common_flags): Print struct iocb.aio_flags using %#x
format specifier instead of %x.
* tests/aio.c (main): Likewise.

7 years agoscsi: rewrite print_sg_io_buffer using printstr_ex(QUOTE_FORCE_HEX)
Dmitry V. Levin [Fri, 6 Jan 2017 16:31:35 +0000 (16:31 +0000)]
scsi: rewrite print_sg_io_buffer using printstr_ex(QUOTE_FORCE_HEX)

As printstr_ex has got QUOTE_FORCE_HEX flag support, there is no need
to implement it manually any longer.

* scsi.c (print_uchar): Remove.
(print_sg_io_buffer): Rewrite using printstr_ex(QUOTE_FORCE_HEX).

7 years agogetrandom: print string as hex-escaped
Eugene Syromyatnikov [Fri, 6 Jan 2017 08:57:42 +0000 (09:57 +0100)]
getrandom: print string as hex-escaped

Since there is no reason to interpret the value returned by getrandom as
ASCII string, it makes sense to always print it as a hex-escaped string.

* getrandom.c (SYS_FUNC(getrandom)): Use printstr_ex instead
of printstrn, set QUOTE_FORCE_HEX in user_style parameter in order
to force hex-escaped string formatting.
* tests/getrandom.test: Remove no longer needed -xx flag as the string
is always printed in hexadecimal format now.

Suggested-by: JingPiao Chen <chenjingpiao@gmail.com>
7 years agoutil: add support for forcing printing string as hex-escaped
Eugene Syromyatnikov [Fri, 6 Jan 2017 08:55:30 +0000 (09:55 +0100)]
util: add support for forcing printing string as hex-escaped

This could be useful in cases when some binary data should not be
interpreted as an ASCII string, but rather as an array of byte values.

* defs.h (QUOTE_FORCE_HEX): New macro constant.
* util.c (quote_string): Enable use_hex when QUOTE_FORCE_HEX is set
in user_style parameter.

7 years agoterm: do not abort decoding in case of non-verbose output
Eugene Syromyatnikov [Sun, 1 Jan 2017 18:46:42 +0000 (21:46 +0300)]
term: do not abort decoding in case of non-verbose output

The case of unset verbose is handled by umoven_or_printaddr, moreover,
exiting at this point is plain wrong and leads to last argument not
being printed while it should be.

* term.c (decode_termios, decode_termio, decode_winsize, decode_ttysize,
decode_modem_flags): Do not check verbose flags explicitly and do not
exit early if it is not set.

7 years agotests: skip fault injection tests on hppa if the kernel is too old
Dmitry V. Levin [Thu, 5 Jan 2017 20:46:48 +0000 (20:46 +0000)]
tests: skip fault injection tests on hppa if the kernel is too old

* tests/fault_injection.sh: Add the minimal kernel version for hppa.

7 years agotests: skip readahead.test on MIPS n64 when built with glibc < 2.25
Dmitry V. Levin [Thu, 5 Jan 2017 18:20:57 +0000 (18:20 +0000)]
tests: skip readahead.test on MIPS n64 when built with glibc < 2.25

Due to a bug in glibc readahead syscall wrapper on MIPS n64,
this wrapper cannot be used in readahead.test.

* tests/readahead.c [HAVE_READAHEAD && LINUX_MIPSN64 && glibc < 2.25]:
Undefine HAVE_READAHEAD.

Reported-by: James Cowgill <james410@cowgill.org.uk>
7 years agotests: replace init_magic with fill_memory
Dmitry V. Levin [Thu, 5 Jan 2017 01:34:24 +0000 (01:34 +0000)]
tests: replace init_magic with fill_memory

Use the same fill_memory/fill_memory_ex interface in all affected tests.

* tests/ioctl_block.c (init_magic): Remove.
(main): Replace init_magic with fill_memory.
* tests/ioctl_evdev.c: Likewise.
* tests/ioctl_v4l2.c: Likewise.
* tests/ioctl_mtd.c (magic, init_magic): Remove.
(main): Replace init_magic with fill_memory.
* tests/ioctl_rtc.c: Likewise.

7 years agotests: rewrite ioctl_v4l2 test without reliance on init_magic
Dmitry V. Levin [Thu, 5 Jan 2017 01:34:24 +0000 (01:34 +0000)]
tests: rewrite ioctl_v4l2 test without reliance on init_magic

* tests/ioctl_v4l2.c (cc0, cc1, cc2, cc3, fourcc): New macros.
(main): Use them.  Rewrite expected output without assumptions
on any particular magic data.

7 years agotests: remove redundant casts in fill_memory{,_ex} invocations
Dmitry V. Levin [Wed, 4 Jan 2017 22:17:26 +0000 (22:17 +0000)]
tests: remove redundant casts in fill_memory{,_ex} invocations

* tests/ioctl_loop.c (main): Remove redundant casts of fill_memory
first argument.
* tests/kexec_load.c (main): Likewise.
* tests/perf_event_open.c (main): Likewise.
* tests/quotactl.c (main): Likewise.
* tests/mq_sendrecv.c (main): Remove redundant casts of fill_memory_ex
first argument.
* tests/quotactl-xfs.c (main): Likewise.

7 years agotests: change the type of fill_memory{,_ex} first argument to void *
Dmitry V. Levin [Wed, 4 Jan 2017 22:08:32 +0000 (22:08 +0000)]
tests: change the type of fill_memory{,_ex} first argument to void *

As these functions behave like memset, it's more convenient to have
the first argument of type void * like memset.

* tests/fill_memory.c (fill_memory, fill_memory_ex): Change the type
of first argument from "char *" to "void *".
* tests/tests.h (fill_memory, fill_memory_ex): Likewise.

7 years agotests: check non-verbose decoding of LOOP_* ioctls
Eugene Syromyatnikov [Sun, 1 Jan 2017 19:43:09 +0000 (22:43 +0300)]
tests: check non-verbose decoding of LOOP_* ioctls

* tests/ioctl_loop-nv.c: New file.
* tests/ioctl_loop-nv.test: New test.
* tests/ioctl_loop.c [!ABBREV] (ABBREV): Define to 0.
(print_loop_info, print_loop_info64): Handle [ABBREV != 0] case.
* tests/.gitignore: Add ioctl_loop-nv.
* tests/Makefile.am (check_PROGRAMS): Likewise.

7 years agotests: add more checks of LOOP_* ioctls decoding
Eugene Syromyatnikov [Sun, 1 Jan 2017 19:29:56 +0000 (22:29 +0300)]
tests: add more checks of LOOP_* ioctls decoding

* tests/ioctl_loop.c: Include <linux/ioctl.h>.
(magic, lmagic): Move static constants ...
(main): ... here.  Change types of magic constants to kernel_ulong_t.
Add more checks.

7 years agotests: check decoding of LOOP_* ioctls
JingPiao Chen [Tue, 27 Dec 2016 03:43:30 +0000 (11:43 +0800)]
tests: check decoding of LOOP_* ioctls

* tests/ioctl_loop.c: New file.
* tests/ioctl_loop-v.c: Likewise.
* tests/ioctl_loop.test: New test.
* tests/ioctl_loop-v.test: Likewise.
* tests/.gitignore: Add ioctl_loop and ioctl_loop-v.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add ioctl_loop.test and ioctl_loop-v.test.

Co-authored-by: Eugene Syromyatnikov <evgsyr@gmail.com>
7 years agoDrop vsprintf.c
Dmitry V. Levin [Wed, 4 Jan 2017 13:22:19 +0000 (13:22 +0000)]
Drop vsprintf.c

Drop custom vfprintf implementation that was disabled by default.
Apparently nobody tests strace with this vfprintf enabled, otherwise
multiple uses of format specifiers not supported by this custom vfprintf
would not left unnoticed.

The GNU C library is not the only libc available, so those who want
faster implementations of libc functions are encouraged to try building
strace with other libc implementations.

* vsprintf.c: Remove.
* Makefile.am (strace_SOURCES): Remove vsprintf.c.
* defs.h (USE_CUSTOM_PRINTF, strace_vfprintf): Remove.
* strace.c (tprintf): Replace strace_vfprintf with vfprintf.

7 years agoloop: remove unnecessary verbose check
Eugene Syromyatnikov [Sun, 1 Jan 2017 19:40:34 +0000 (22:40 +0300)]
loop: remove unnecessary verbose check

The verbose flag is responsible for dereferencing of addresses, and it
is perfectly handled by umove_or_printaddr; moreover, this early exit
leads to incorrect formatting of last argument.

* loop.c (loop_ioctl): Do not check verbose flag explicitly and do not
exit early if it is not set.

7 years agoloop: fix lo_encrypt_key field output
Eugene Syromyatnikov [Sun, 1 Jan 2017 19:26:30 +0000 (22:26 +0300)]
loop: fix lo_encrypt_key field output

lo_encrypt_key is a sized string with its size specified by
lo_encrypt_key_size field, so take lo_encrypt_key_size into account.

* loop.c (decode_loop_info, decode_loop_info64): Use minimum of
LO_KEY_SIZE and lo_encrypt_key_size field value as lo_encrypt_key size.

7 years agoloop: print lo_encrypt_key_size field of struct loop_info as unsigned
Eugene Syromyatnikov [Sun, 1 Jan 2017 19:19:18 +0000 (22:19 +0300)]
loop: print lo_encrypt_key_size field of struct loop_info as unsigned

It is converted to an unsigned value in kernel (see loop_info64_from_old
in drivers/block/loop.c), so let's print it that way despite its type.

* loop.c (decode_loop_info): Print lo_encrypt_key_size as an uint32_t
value.

7 years agotests: add more checks of unknown ioctl command formatting
Eugene Syromyatnikov [Sun, 1 Jan 2017 18:59:12 +0000 (21:59 +0300)]
tests: add more checks of unknown ioctl command formatting

* tests/ioctl.c (main): Additional check for unknown ioctl command
decoding.
* tests/ioctl_evdev.c (main): Likewise.
* tests/ioctl_dm.c: Include <linux/ioctl.h> for _IOC_SIZE and _IOC_NR.
(main) <dummy_dm_ioctl1, dummy_dm_ioctl2, dummy_dm_arg>: New constants.
Add more checks for unknown command formatting.

7 years agoioctl: do not print explicit 0x prefix and do not specify minimum width
Eugene Syromyatnikov [Sun, 1 Jan 2017 18:53:48 +0000 (21:53 +0300)]
ioctl: do not print explicit 0x prefix and do not specify minimum width

Specifying output width for size argument is rather misleading - it can
be up to 14 bits in size.  The use of explicit "0x" prefix is
discouraged because 0x0 looks ugly.  Usage of width specification along
with alternate form flag leads to inconsistent output for 0.
Let's use just plain %#x qualifiers instead.

* ioctl.c (ioctl_print_code): Change printf qualifiers for ioctl command
type, number and size to "%#x".
* tests/ioctl.c (main): Update expected test output.
* tests/ioctl_dm.c (main): Likewise.
* tests/ioctl_evdev.c (main): Likewise.

7 years agoloop: fix printing of the reserved field array items
Eugene Syromyatnikov [Sun, 1 Jan 2017 18:13:07 +0000 (21:13 +0300)]
loop: fix printing of the reserved field array items

They are of char type, so "hh" length modifier should be used (otherwise
they are printed incorrectly as they are sign extended implicitly when
passed as printf arguments in case char is a signed type which is true
for most compilers).

* loop.c (decode_loop_info): Change "%#x" printf qualifier to "%#hhx"
in printing routine for array elements of the "reserved" field of
loop_info structure.

7 years agotests: check ioctl(SIOCGIFCONF) decoding
Eugene Syromyatnikov [Sat, 24 Dec 2016 16:18:51 +0000 (19:18 +0300)]
tests: check ioctl(SIOCGIFCONF) decoding

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

7 years agodm.c: add copyright notice
Eugene Syromyatnikov [Mon, 26 Dec 2016 12:24:45 +0000 (15:24 +0300)]
dm.c: add copyright notice

7 years agoAdd scno.h and syscallent.i to .gitignore files
Dmitry V. Levin [Wed, 4 Jan 2017 11:29:32 +0000 (11:29 +0000)]
Add scno.h and syscallent.i to .gitignore files

* .gitignore: Add /scno.h and /syscallent.i.
* tests/.gitignore: Add scno.h and syscallent.i.

7 years agotests/.gitignore: add generated files that should be ignored
JingPiao Chen [Tue, 27 Dec 2016 03:43:28 +0000 (11:43 +0800)]
tests/.gitignore: add generated files that should be ignored

* tests/.gitignore: Replace addkey with add_key, add attach-f-p-cmd.

7 years agoRemove checks of __NR_* availability from strace source code
Dmitry V. Levin [Tue, 3 Jan 2017 13:46:26 +0000 (13:46 +0000)]
Remove checks of __NR_* availability from strace source code

* strace.c: Remove __NR_tkill checks, assume it is always defined.
* util.c: Remove __NR_process_vm_readv checks and fallback definitions,
assume it is always defined.

7 years agoInclude "scno.h" in files that check __NR_* constants
Dmitry V. Levin [Mon, 2 Jan 2017 22:37:57 +0000 (22:37 +0000)]
Include "scno.h" in files that check __NR_* constants

* strace.c: Include "scno.h".
* util.c: Likewise.

7 years agoGenerate scno.h for use during the build of strace itself
Dmitry V. Levin [Mon, 2 Jan 2017 21:27:42 +0000 (21:27 +0000)]
Generate scno.h for use during the build of strace itself

* Makefile.am: Include scno.am.
($(strace_OBJECTS)): New rule.

7 years agoGenerate scno.h without invoking a generated executable helper
Dmitry V. Levin [Sun, 1 Jan 2017 20:59:11 +0000 (20:59 +0000)]
Generate scno.h without invoking a generated executable helper

Generate scno.h using only those tools that are available for cross
build.  This allows to use scno.h during the build of strace itself.

* scno.am: New file.
* scno.head: New file.
* Makefile.am (EXTRA_DIST): Add it.
* tests/generate_scno.c: Remove.
* tests/.gitignore: Remove generate_scno.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(CLEANFILES): Remove scno.h.
(scno.h, $(scno_dependants)): Remove rules.
(scno_dependants): Remove.
($(objects)): New rule.
Include ../scno.am.

7 years agoUpdate all publicly shown copyright year number ranges
Dmitry V. Levin [Sun, 1 Jan 2017 11:33:40 +0000 (11:33 +0000)]
Update all publicly shown copyright year number ranges

* COPYING: Update copyright year number range.
* configure.ac: Likewise.
* strace.c: Likewise.
* tests/strace-V.test: Use the current year for the check.

7 years agodefs.h: stop including <asm/unistd.h>
Dmitry V. Levin [Sat, 31 Dec 2016 22:12:08 +0000 (22:12 +0000)]
defs.h: stop including <asm/unistd.h>

Limit the number of files where <asm/unistd.h> is included
to only those few that need it.

* defs.h: Do not include <asm/unistd.h>.
* clone.c: Include <asm/unistd.h>.
* strace.c: Likewise.
* syscall.c: Likewise.
* util.c: Likewise.

7 years agotests: do not use BUILT_SOURCES
Dmitry V. Levin [Fri, 30 Dec 2016 11:16:56 +0000 (11:16 +0000)]
tests: do not use BUILT_SOURCES

* tests/Makefile.am (ksysent.$(OBJEXT)): New rule.
(BUILT_SOURCES): Remove.

7 years agoFix cross build
Dmitry V. Levin [Fri, 30 Dec 2016 07:20:25 +0000 (07:20 +0000)]
Fix cross build

This fixes cross build regression introduced by commit
v4.15-39-g605a705a63d533dceb3c2d489468fcd3aed3963c.

* tests/Makefile.am (BUILT_SOURCES): Remove scno.h
(objects, scno_dependants): New variables.
($(scno_dependants)): New rule.

Reported-by: Joakim Bech <joakim.bech@linaro.org>
7 years agotests: do not use defs.h and syscall.h
Dmitry V. Levin [Fri, 30 Dec 2016 09:43:12 +0000 (09:43 +0000)]
tests: do not use defs.h and syscall.h

* tests/generate_scno.c: Include "tests.h", "sysent.h", <stdio.h>,
<string.h>, and <asm/unistd.h> instead of "defs.h" and "syscall.h".
* tests/ksysent.c: Likewise.
* tests/nsyscalls.c: Include "tests.h", "sysent.h", <errno.h>,
<stdio.h>, and <unistd.h> instead of "defs.h" and "syscall.h".

7 years agoMove definition of struct sysent and trace flags to a separate file
Dmitry V. Levin [Fri, 30 Dec 2016 09:40:37 +0000 (09:40 +0000)]
Move definition of struct sysent and trace flags to a separate file

* sysent.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h: Include it.
(struct sysent, TRACE_FILE, TRACE_IPC, TRACE_NETWORK, TRACE_PROCESS,
TRACE_SIGNAL, TRACE_DESC, TRACE_MEMORY, SYSCALL_NEVER_FAILS,
STACKTRACE_INVALIDATE_CACHE, STACKTRACE_CAPTURE_ON_ENTER,
TRACE_INDIRECT_SUBCALL, COMPAT_SYSCALL_TYPES): Remove.

7 years agoMpersify SIOC* ioctls
Eugene Syromyatnikov [Mon, 26 Dec 2016 14:07:24 +0000 (17:07 +0300)]
Mpersify SIOC* ioctls

struct ifreq and struct ifconf are ABI-dependent and should have been
mpersified.

* defs.h (sock_ioctl): Remove prototype.
* sock.c (struct_ifconf, struct_ifreq): New typedefs.
(DEF_MPERS_TYPE(struct_ifconf), DEF_MPERS_TYPE(struct_ifreq),
MPERS_DEFS): New includes.
(print_ifreq, print_ifc_len, print_ifconf_ifreq): Replace struct ifreq
with struct_ifreq.
(decode_ifconf): Replace struct ifconf with struct_ifconf, struct ifreq
with struct_fireq.
(sock_ioctl): Wrap into MPERS_PRINTER_DECL.

7 years agosock: rewrite decode_ifconf
Eugene Syromyatnikov [Fri, 23 Dec 2016 19:53:22 +0000 (22:53 +0300)]
sock: rewrite decode_ifconf

* sock.c (decode_ifconf): Rewrite.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agoxlat: update LOOP_* ioctl flags constants
Eugene Syromyatnikov [Mon, 26 Dec 2016 17:42:18 +0000 (20:42 +0300)]
xlat: update LOOP_* ioctl flags constants

* configure.ac (AC_CHECK_DECLS): Add LO_FLAGS_USE_AOPS
and LO_FLAGS_DIRECT_IO.
* xlat/loop_flags_options.in: Likewise.  Add default values
for constants.

7 years agoloop: add fallback definitions for LOOP_* ioctl command constants
Eugene Syromyatnikov [Mon, 19 Dec 2016 00:11:18 +0000 (03:11 +0300)]
loop: add fallback definitions for LOOP_* ioctl command constants

Since these are architecture-independent and have been added over the
kernel's lifetime, it makes sense to have these definitions in strace
itself.

* xlat/loop_cmds.in: New file.
* loop.c: Include "xlat/loop_cmds.h".
(loop_ioctl): Eliminate conditional compilation based on availability
of LOOP_* constant definitions.

7 years agoxlat: extend syntax
Dmitry V. Levin [Thu, 29 Dec 2016 00:30:26 +0000 (00:30 +0000)]
xlat: extend syntax

* xlat/gen.sh: Implement #stop directive that stops preprocessor
at the line it has been encountered during the first pass.  This could
be used, for example, to provide fallback definitions for constants
without defining xlat tables.

7 years agoloop: mpersify struct loop_info and loop_ioctl function
Eugene Syromyatnikov [Mon, 19 Dec 2016 00:15:27 +0000 (03:15 +0300)]
loop: mpersify struct loop_info and loop_ioctl function

struct loop_info contains fields of type long, so it definitely should
have been mpersified.

* defs.h (loop_ioctl): Remove prototype.
* loop.c (struct_loop_info): New typedef.
Include DEF_MPERS_TYPE(struct_loop_info) and MPERS_DEFS.
(decode_loop_info): Replace struct loop_info with struct_loop_info.
Cast lo_inode, lo_init[0], and lo_init[1] to kernel_ulong_t and print
them using appropriate format specifiers.
(loop_ioctl): Wrap into MPERS_PRINTER_DECL.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agoloop: print lo_device and lo_rdevice fields using print_dev_t
Eugene Syromyatnikov [Mon, 26 Dec 2016 16:36:37 +0000 (19:36 +0300)]
loop: print lo_device and lo_rdevice fields using print_dev_t

* loop.c (decode_loop_info, decode_loop_info64): Use print_dev_t
for printing lo_device and lo_rdevice fields.

7 years agoMove device number printing code into a separate routine
Eugene Syromyatnikov [Mon, 26 Dec 2016 12:25:35 +0000 (15:25 +0300)]
Move device number printing code into a separate routine

* print_dev_t.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (print_dev_t): New prototype.
* dm.c: Do not include <sys/sysmacros.h>.
(dm_decode_device, dm_print_dev, dm_decode_dm_name_list): Use
print_dev_t function for printing device numbers.
* mknod.c: Do not include <sys/sysmacros.h>.
(decode_mknod): Use print_dev_t function for printing device number.
* print_struct_stat.c: Do not include <sys/sysmacros.h>.
(print_struct_stat): Use print_dev_t function for printing device
numbers.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agotests: enhance invalid address decoding check in seccomp-strict.test
Dmitry V. Levin [Wed, 28 Dec 2016 22:33:38 +0000 (22:33 +0000)]
tests: enhance invalid address decoding check in seccomp-strict.test

* tests/seccomp-strict.c (main): Change the type of addr variable
containg the invalid address from unsigned long to kernel_ulong_t,
print it using %#llx format.

7 years agotests: check decoding of prctl PR_GET_TID_ADDRESS operation
Eugene Syromyatnikov [Sun, 11 Dec 2016 21:26:07 +0000 (00:26 +0300)]
tests: check decoding of prctl PR_GET_TID_ADDRESS operation

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

7 years agoUpdate the publicly shown copyright information
Dmitry V. Levin [Wed, 28 Dec 2016 17:09:05 +0000 (17:09 +0000)]
Update the publicly shown copyright information

Set the publicly shown copyright holder to "The strace developers.".

* COPYING: Update copyright information.
* configure.ac: Add AC_COPYRIGHT.
* strace.c (print_version): New function.
(init): Use it.
* tests/strace-V.test: Update expected output.

7 years agoconfigure: specify project URL
Dmitry V. Levin [Wed, 28 Dec 2016 16:54:14 +0000 (16:54 +0000)]
configure: specify project URL

* configure.ac (AC_INIT): Add URL.

7 years agoDocument signal injection
Seraphime Kirkovski [Tue, 27 Dec 2016 11:14:36 +0000 (12:14 +0100)]
Document signal injection

* strace.1: Describe :signal=SIG option of the fault injection syntax.
* NEWS: Mention signal injection.

Signed-off-by: Seraphime Kirkovski <kirkseraph@gmail.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agoImplement signal injection
Seraphime Kirkovski [Tue, 27 Dec 2016 11:14:06 +0000 (12:14 +0100)]
Implement signal injection

This extends the fault injection capability with :signal=SIG option
which injects a signal on entering each syscall from the specified set.

:signal and :error options are complementary, if they are both specified
the syscall will be fault injected as usual and the specified signal
will be delivered to the tracee.

* defs.h (struct fault_opts): Change the type of err field to int16_t,
add signo field.
(trace_syscall): Add a pointer argument.
* qualify.c: Include "nsig.h".
(parse_fault_token): Handle signal= option.
(qualify_fault): Update default fault_opts.
* strace.c (trace): Forward signal number from trace_syscall
to ptrace_restart(PTRACE_SYSCALL).
* syscall.c (inject_syscall_fault_entering): Add pointer argument,
save there the signal number specified by fault options.  Do not inject
a syscall fault unless instructed by fault options.
(update_syscall_fault_exiting): Update the error code injection check.
(trace_syscall_entering): Add pointer argument, forward it to
inject_syscall_fault_entering.
(trace_syscall): Add pointer argument, forward it to
trace_syscall_entering.

Signed-off-by: Seraphime Kirkovski <kirkseraph@gmail.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agoUpdate README.md
Dmitry V. Levin [Wed, 28 Dec 2016 11:39:00 +0000 (11:39 +0000)]
Update README.md

* README.md: Update homepage URL, mention command-line interface
and tampering capabilities in the description.

7 years agotests: robustify prctl-arg2-intptr.test
Dmitry V. Levin [Wed, 28 Dec 2016 01:24:31 +0000 (01:24 +0000)]
tests: robustify prctl-arg2-intptr.test

Robustify prctl-arg2-intptr.test against unrelated prctl invocations.

* tests/prctl-arg2-intptr.test: Filter out unrelated PR_GET_*
and PR_SET_* prctl calls.

7 years agosignal: remove redundant checks around NSIG
Dmitry V. Levin [Tue, 27 Dec 2016 23:41:22 +0000 (23:41 +0000)]
signal: remove redundant checks around NSIG

* signal.c (struct old_sigaction, struct new_sigaction,
struct new_sigaction32): Remove safety checks for NSIG >= sizeof(long).

7 years agoIntroduce NSIG_BYTES
Dmitry V. Levin [Tue, 27 Dec 2016 23:32:44 +0000 (23:32 +0000)]
Introduce NSIG_BYTES

* nsig.h (NSIG_BYTES): New macro.
* desc.c: Use it in comments instead of NSIG.
* epoll.c: Likewise.
* poll.c: Likewise.
* signalfd.c: Likewise.
* signal.c: Likewise.
(sprintsigmask_n, print_sigset_addr_len_limit): Use it instead of NSIG.
* linux/alpha/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/arm/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/crisv10/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/ia64/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/m68k/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/microblaze/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/mips/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/powerpc/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/s390/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/sparc/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/tile/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/x86_64/arch_sigreturn.c (arch_sigreturn): Likewise.
* tests/pselect6.c (main): Likewise.

7 years agoMove NSIG ifdefery to a separate header file
Dmitry V. Levin [Tue, 27 Dec 2016 23:18:21 +0000 (23:18 +0000)]
Move NSIG ifdefery to a separate header file

* nsig.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* signal.c: Include "nsig.h" instead of <signal.h>, remove
NSIG workarounds.
* sigreturn.c: Likewise.
* syscall.c: Likewise.
* tests/pselect6.c: Likewise.

7 years agoIntroduce ANY_WORDSIZE_LESS_THAN_KERNEL_LONG macro
Dmitry V. Levin [Mon, 26 Dec 2016 20:12:23 +0000 (20:12 +0000)]
Introduce ANY_WORDSIZE_LESS_THAN_KERNEL_LONG macro

* defs.h (ANY_WORDSIZE_LESS_THAN_KERNEL_LONG): New macro.
(truncate_klong_to_current_wordsize,
truncate_kulong_to_current_wordsize): Use it.
* mem.c (SYS_FUNC(old_mmap)): Likewise.
* util.c (umoven, umovestr, dumpiov_upto): Likewise.
* syscall.c (trace_syscall_exiting): Likewise.