Dmitry V. Levin [Sun, 5 Mar 2017 16:15:55 +0000 (16:15 +0000)]
install.texi: import from GNU Autoconf
install.texi from GNU Autoconf is the ultimate source of INSTALL file.
This edition of install.texi has been downloaded from
https://git.savannah.gnu.org/cgit/autoconf.git/plain/doc/install.texi?id=63f3c78cdb0ccc85751543e387ef2a7252d5f0a2
Dmitry V. Levin [Sun, 26 Feb 2017 23:23:31 +0000 (23:23 +0000)]
tests: transform print_time_t into print_time_t_nsec
* tests/print_time.c (print_time_t): Rename to print_time_t_nsec,
take second argument and print it.
* tests/tests.h (print_time_t): Rename to print_time_t_nsec,
add second argument.
* tests/utime.c (main): Use print_time_t_nsec instead of print_time_t.
* tests/xstatx.c (print_stat): Likewise. Pass nanoseconds
to print_time_t_nsec instead of printing them.
Dmitry V. Levin [Sat, 25 Feb 2017 15:55:31 +0000 (15:55 +0000)]
x32: fix decoding of flags argument of preadv2 and pwritev2 syscalls
x32 is the only linux architecture where preadv2 and pwritev2 syscalls
take 5 arguments instead of 6.
* io.c (PREADV2_PWRITEV2_FLAGS_ARG_NO): New macro.
(SYS_FUNC(preadv2), SYS_FUNC(pwritev2)): Use it.
* linux/x32/syscallent.h (preadv2, pwritev2): Change nargs to 5.
* NEWS: Mention this fix.
* tests/preadv2-pwritev2.c (main): Fix invocation of preadv2
and pwritev2 syscalls on x32.
Dmitry V. Levin [Mon, 20 Feb 2017 00:10:35 +0000 (00:10 +0000)]
tests: move get_sigset_size function to libtests
* tests/get_sigset_size.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
* tests/tests.h (get_sigset_size): New prototype.
* tests/ptrace.c: Do not check for __NR_rt_sigprocmask.
(main): Use get_sigset_size.
* tests/signalfd4.c: Do not check for __NR_rt_sigprocmask.
(get_sigset_size): Remove.
Dmitry V. Levin [Sun, 19 Feb 2017 00:31:40 +0000 (00:31 +0000)]
sched: enhance decoding of sched_setattr syscall
Implement read/write semantics of struct sched_attr.size argument
of sched_setattr syscall. Do not print members of struct sched_attr
besides sched_attr.size when the specified structure size is less than
the minimal size allowed by the kernel.
* sched.c (print_sched_attr): Fetch struct sched_attr.size and use it
as the structure size. Print struct sched_attr.size only when the
structure size is less than SCHED_ATTR_MIN_SIZE.
(SYS_FUNC(sched_setattr)): Call print_sched_attr with zero size
argument. Print struct sched_attr.size returned by the kernel
on exiting syscall in case of E2BIG. Print the last syscall argument
on exiting syscall.
(SYS_FUNC(sched_getattr)): Do not call print_sched_attr with zero size
argument.
* NEWS: Mention it.
* tests/sched_xetattr.c (main): Check it.
Dmitry V. Levin [Sat, 18 Feb 2017 09:58:52 +0000 (09:58 +0000)]
tests: check decoding of sched_[gs]etattr corner cases
* tests/sched_xetattr.c (main): Check that integer arguments
of sched_getattr and sched_setattr syscalls are decoded properly
by adding a few cases with filled higher 32 bits.
Check that pointer argument is decoded properly
on F8ILL_KULONG_SUPPORTED architectures.
Dmitry V. Levin [Sat, 18 Feb 2017 09:58:52 +0000 (09:58 +0000)]
Move definition of struct sched_attr to a separate header file
Avoid multiple defintions of struct sched_attr by creating a separate
header file with its definition and using it in other places.
* sched_attr.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* sched.c: Include it.
(print_sched_attr): Use it.
* tests/sched_xetattr.c: Include it.
(main): Use it.
Dmitry V. Levin [Sat, 18 Feb 2017 09:58:52 +0000 (09:58 +0000)]
tests: rewrite sched_xetattr.test from match_grep to match_diff
Unlike the previous edition of the test that was based on match_grep,
the new one is match_diff based and does more rigorous testing.
* tests/adjtimex.c: Include "xlat.h" and "xlat/schedulers.h",
(sys_sched_getattr, sys_sched_setattr): New functions.
(main): Use them. Update expected output.
* tests/adjtimex.test: Use run_strace_match_diff.
Dmitry V. Levin [Fri, 17 Feb 2017 00:05:00 +0000 (00:05 +0000)]
bpf: update BPF_PROG_ATTACH decoding
Implement decoding of BPF_F_ALLOW_OVERRIDE flag of BPF_PROG_ATTACH
command introduced by linux kernel commit v4.10-rc7-174-g7f67763.
* configure.ac: Check for union bpf_attr.attach_flags
instead of union bpf_attr.attach_type.
* xlat/bpf_attach_flags.in: New file.
* bpf.c: Include "xlat/bpf_attach_flags.h".
(bpf_prog_attach_detach): Rename print_attach_bpf_fd argument
to print_attach. Add attach_flags field to the structure,
print it in case of BPF_PROG_ATTACH.
* tests/bpf.c: Check for HAVE_UNION_BPF_ATTR_ATTACH_FLAGS
instead of HAVE_UNION_BPF_ATTR_ATTACH_TYPE.
(prog_cgroup): Initialize attach_flags field.
(main): Update expected output.
Dmitry V. Levin [Thu, 16 Feb 2017 21:02:44 +0000 (21:02 +0000)]
tests: rewrite adjtimex.test from match_grep to match_diff
Unlike the previous edition of the test that was based on match_grep,
the new one is match_diff based and does more rigorous testing.
* tests/adjtimex.c: Include "xlat.h", "xlat/adjtimex_state.h",
and "xlat/adjtimex_status.h".
(main): Update expected output.
* tests/adjtimex.test: Use run_strace_match_diff.
* capability.c (cap_user_header_t, cap_user_data_t): Remove.
(get_cap_header): Change return type
to "const struct user_cap_header_struct *".
(print_cap_header, print_cap_data): Change the type of last argument
to "const struct user_cap_header_struct * const".
(SYS_FUNC(capget)): Change type of "h" variable
to "const struct user_cap_header_struct *".
(SYS_FUNC(capset)): Change type of "h" variable
to "const struct user_cap_header_struct * const".
* tests/rt_tgsigqueueinfo.c (k_tgsigqueueinfo): Change the type of last
argument to "const void *const".
* tests/utime.c (main): Change the type of "tail_u" variable
to "const struct utimbuf *const".
* tests/waitid.c (do_waitid): Change the type of 3rd argument
to "const siginfo_t *const".
Dmitry V. Levin [Sun, 12 Feb 2017 14:12:41 +0000 (14:12 +0000)]
tests: rewrite pipe syscall decoding check from match_grep to match_diff
* configure.ac (AC_CHECK_FUNCS): Remove pipe2.
* tests/pipe.c: Include <asm/unistd.h>, skip the test if [!__NR_pipe]
instead of [!HAVE_PIPE2].
(main): Do not call pipe2.
* tests/pipe.test: Skip the test if libc pipe wrapper does not use
pipe syscall, rewrite from match_grep to match_diff.
* tests/pipe.expected: Update expected output.
Dmitry V. Levin [Fri, 10 Feb 2017 00:14:45 +0000 (00:14 +0000)]
tests: rewrite mq.test from match_grep to match_diff
Unlike the previous edition of the test that was based on match_grep,
the new one is match_diff based and does more rigorous testing.
* tests/mq.c: Include <stdio.h>.
(NAME): New macro.
(main): Use it. Print expected output.
* tests/mq.expected: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove mq.expected.
* tests/mq.test: Use run_strace_match_diff.
Dmitry V. Levin [Thu, 9 Feb 2017 22:26:14 +0000 (22:26 +0000)]
Simplify struct inject_opts.rval semantics
Drop use of INJECT_OPTS_RVAL_DISABLE special inject_opts.rval value,
INJECT_OPTS_RVAL_DEFAULT is enough.
* defs.h (INJECT_OPTS_RVAL_DISABLE): Remove.
* qualify.c (qualify_inject_common): Do not replace
INJECT_OPTS_RVAL_DEFAULT with INJECT_OPTS_RVAL_DISABLE
in inject_opts.rval.
* syscall.c (tamper_with_syscall_entering): Check
for INJECT_OPTS_RVAL_DEFAULT instead of INJECT_OPTS_RVAL_DISABLE.
Dmitry V. Levin [Thu, 9 Feb 2017 14:38:08 +0000 (14:38 +0000)]
Make symbolic errno values match case-insensitive
Follow the example of case-insensitive symbolic signal values in signal
and inject expressions and make symbolic errno values in inject
expressions case-insensitive.
* qualify.c (find_errno_by_name): Use strcasecmp instead of strcmp
to match symbolic errno values.
* tests/qual_fault.c (main): Likewise.
* tests/qual_fault.test: Test case-insensitive symbolic errno match.
Dmitry V. Levin [Wed, 8 Feb 2017 09:28:38 +0000 (09:28 +0000)]
Implement -e inject= option
Introduce -e inject= as a general injection option,
limit -e fault= option to syscall fault injection.
Change default return code of syscall fault injection to ENOSYS.
* qualify.c (parse_inject_token): Add fault_tokens_only argument,
do not accept retval= and signal= tokens when fault_tokens_only
is set to true.
(parse_inject_expression): Add fault_tokens_only argument,
forward it to parse_inject_token.
(qualify_inject_common): New function.
(qualify_fault): Use it.
(qualify_inject): New function.
(qual_options): New entry.
* strace.1: Describe -e inject= option.
* NEWS: Mention -e inject= option.
* tests/qual_fault-syntax.test: Test that -e fault= option does not
support retval=, signal=, and multiple error= tokens.
* tests/qual_fault.c (DEFAULT_ERRNO): Set to ENOSYS unconditionally.
* tests/qual_inject-retval.test: Replace -e fault= option
with -e inject= option.
* tests/qual_inject-syntax.test: New test.
* tests/Makefile.am (MISC_TESTS): Add it.
Dmitry V. Levin [Wed, 8 Feb 2017 09:28:07 +0000 (09:28 +0000)]
Prepare for introduction of -e inject= option
As -e fault= injection syntax has been extended to configure various
kinds of injections besides fault injection, the original option name
bacame too narrow.
This change renames internal constants, types, and functions from
"fault" to more generic inject/tamper ones.
* defs.h (fault_opts): Rename to inject_opts.
(FAULT_OPTS_RVAL_DEFAULT): Rename to INJECT_OPTS_RVAL_DEFAULT.
(FAULT_OPTS_RVAL_DISABLE): Rename to INJECT_OPTS_RVAL_DISABLE.
(struct tcb): Rename fault_vec field to inject_vec.
(TCB_FAULT_INJ): Rename to TCB_TAMPERED.
(QUAL_FAULT): Rename to QUAL_INJECT.
(fault_vec): Rename to inject_vec.
All users changed.
* qualify.c (fault_set): Rename to inject_set.
(parse_fault_token): Rename to parse_inject_token.
(parse_fault_expression): Rename to parse_inject_expression.
All callers changed.
* syscall.c (fault_vec): Rename to inject_vec.
(tcb_fault_opts): Rename to tcb_inject_opts.
(inject_syscall_fault_entering): Rename to tamper_with_syscall_entering.
(update_syscall_fault_exiting): Rename to tamper_with_syscall_exiting.
(syscall_fault_injected): Rename to syscall_tampered.
All callers changed.
Dmitry V. Levin [Sun, 29 Jan 2017 23:12:07 +0000 (23:12 +0000)]
tests: rewrite bpf.test from match_grep to match_diff
* tests/bpf.c (errstr): New variable.
(sys_bpf): New function.
(map_create, map_any, prog_load, obj_manage, prog_cgroup): Use it.
(main): Update expected output.
* tests/bpf.test: Use run_strace_match_diff.
Quentin Monnet [Thu, 26 Jan 2017 14:36:56 +0000 (15:36 +0100)]
Update bpf syscall decoding
Implement decoding of BPF_OBJ_PIN, BPF_OBJ_GET, BPF_PROG_ATTACH,
and BPF_PROG_DETACH commands.
* bpf.c: Include "xlat/bpf_attach_type.h".
(bpf_obj_manage, bpf_prog_attach, bpf_prog_detach): New functions.
(SYS_FUNC(bpf)): Use them.
* configure.ac: Check for union bpf_attr.bpf_fd and union
bpf_attr.attach_type.
* xlat/bpf_attach_type.in: New file.
* xlat/bpf_commands.in: Update list of BPF_* command constants.
* xlat/bpf_map_types.in: Update list of BPF_MAP_TYPE_* constants.
* xlat/bpf_prog_types.in: Update list of BPF_PROG_TYPE_* constants.
* tests/bpf.c [HAVE_UNION_BPF_ATTR_BPF_FD] (obj_manage): New function.
[HAVE_UNION_BPF_ATTR_ATTACH_TYPE] (prog_cgroup): Likewise.
(main): Use them.
Elvira Khabirova [Tue, 24 Jan 2017 23:59:16 +0000 (02:59 +0300)]
Implement success injection
This extends fault injection syntax with :retval= option.
When :retval=VALUE is specified, the syscall number is replaced by -1
and a bogus success VALUE is returned to the callee.
Dmitry V. Levin [Thu, 26 Jan 2017 23:57:17 +0000 (23:57 +0000)]
mips: rewrite configure check without sgidefs.h
Use builtin macros provided by gcc >= 3.4 instead of sgidefs.h macros.
* configure.ac <mips>: Do not include <asm/sgidefs.h>, use _ABIO32
instead of _MIPS_SIM_ABI32, _ABIN32 instead of _MIPS_SIM_NABI32,
and _ABI64 instead of _MIPS_SIM_ABI64.
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>
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.
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.
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.
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.
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>
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.
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.
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.
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.
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.