Commit Graph

7121 Commits

Author SHA1 Message Date
860ccdefea net: enhance decoding of getsockopt(PACKET_STATISTICS)
* net.c (print_tpacket_stats): Change decoder to match the kernel
behaviour: getsockopt syscall accepts any non-negative *optlen and
writes either MIN(sizeof(struct tpacket_stats), *optlen) or
MIN(sizeof(struct tpacket_stats_v3), *optlen) bytes of data.
2018-07-18 20:03:18 +00:00
ad2c9352a6 net: compile SO_PEERCRED/SO_ATTACH_FILTER/SO_ATTACH_REUSEPORT_CBPF code unconditionally
* net.c: Remove checks for SO_PEERCRED, SO_ATTACH_FILTER, and
SO_ATTACH_REUSEPORT_CBPF macros as they are defined unconditionally
since commit v4.23~199.
2018-07-18 20:03:18 +00:00
6fd0508195 net: enhance decoding of getsockopt(SO_PEERCRED)
* net.c (print_ucred): Rename to print_get_ucred, change decoder
to match the kernel behaviour: getsockopt syscall accepts any
non-negative *optlen and writes MIN(sizeof(struct ucred), *optlen)
bytes of data.
(print_getsockopt): Replace print_ucred with print_get_ucred.
* tests/so_percred.c: Include <string.h>.
(main): Update expected output.
2018-07-18 20:03:18 +00:00
9ccd194f1d net: enhance decoding of getsockopt(SO_LINGER)
* net.c (print_get_linger): Change decoder to match the kernel
behaviour: getsockopt syscall accepts any non-negative *optlen
and writes MIN(sizeof(struct linger), *optlen) bytes of data.
(print_set_linger): Move after definition of SYS_FUNC(getsockopt).
* tests/so_linger.c: Include <stddef.h> and <string.h>.
(main): Update expected output.
2018-07-18 19:25:52 +00:00
27aa9e77df net: generalize getsockopt length check
* net.c (print_getsockopt): Apply (ulen < 0 || rlen < 0) check for all
cases.  As the kernel neither accepts nor returns a negative length
in case of successful getsockopt syscall invocation, these negative
values must have been forged by userspace.
2018-07-18 19:25:52 +00:00
3dbffb74cc tests: fix build with fresh glibc
Workaround additional incompatibility between <sys/stat.h> and
<asm/stat.h> introduced by glibc-2.27.9000-566-gfd70af4.

* tests/xstatx.c (statx, statx_timestamp): Redefine before the inclusion
of <sys/stat.h> to avoid conflicts between definitions provided by the
linux kernel headers and the GNU libc.
2018-07-15 22:14:29 +00:00
Eugene Syromyatnikov
2b96d4c477 tests/quotactl.h: document check_quota
* tests/quotactl.h (check_quota): Add a comment describing the function
usage.
2018-07-15 18:51:09 +00:00
Zhibin Li
15dad53761 tests/quotactl-xfs.c: fix indentation 2018-07-15 18:51:09 +00:00
Zhibin Li
7a4582e357 tests: use check_quota for invalid quotactl commands
Use check_quota function for invalid commands instead of manual quotactl
syscall invocations. In this way successful injection can also be checked
for these commands in the next commit.

* tests/quotactl.c (main): Add invalid_cmd_str and invalid_id_str local
variables, remove unused variable rc, use check_quota instead of manual
quotactl syscall invocations.
* tests/quotaclt.c (main): Add invalid_cmd_str variable, remove unused
variable rc, use check_quota instead of manual quotactl syscall invocations.
2018-07-15 18:51:09 +00:00
Zhibin Li
f23ff6cebf tests: enhance test coverage of quotactl syscall parser
* tests/quotactl.c (print_dqfmt): New function.
(main): Use print_dqfmt to print flags of quota format, improve existing
tests and add more tests for Q_GETFMT.
* tests/quotactl-xfs.c: Improve existing tests and add more tests for
Q_XGETQSTAT and Q_XGETQSTATV.
2018-07-15 18:51:09 +00:00
Zhibin Li
965e18c407 tests/quotactl-xfs.c: fix typos in QCMD
* tests/quotactl-xfs.c (main): fix typos of sub-commands in QCMD.
2018-07-15 18:51:09 +00:00
Zhibin Li
de6e322986 Mpersify decoder of struct xfs_dqstats
* xfs_quota_stat.h: New file.
* fetch_struct_xfs_quotastat.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* quota.c: Include xfs_quota_stat.h
(struct fs_qfilestat, struct xfs_dqstats): Moved to xfs_quota_stat.h.
(decode_cmd_data) <case Q_XGETQSTAT>: Use fetch_struct_quotastat.
2018-07-15 18:51:09 +00:00
Zhibin Li
44a99c878b quota: fix disorder of PRINT_FIELD invocations
* quota.c (decode_cmd_data) <case Q_XGETQSTAT>: Print fields
of struct xfs_dqstats in the structure order.
2018-07-15 18:51:09 +00:00
Zhibin Li
fd5765aad8 tests: extend coverage for other fcntl flags
* tests/fcntl-common.c: Include <assert.h>.
(struct fcntl_cmd_check): New structure.
(print_retval_flags, test_other_set_cmd, test_other_get_cmd,
print_flags_getfd, print_flags_getsig, print_flags_getlease,
test_fcntl_others): New functions.
(main): Use test_fcntl_others.
2018-07-12 08:51:04 +00:00
048d1885fa Implement -e kvm= option on all architectures
Make -e kvm= interface available on all architectures by adding a stub
on those architectures that do not have <linux/kvm.h>.

* filter_qualify.c (qualify_kvm): Define unconditionally.
(qual_options): Define qualify_kvm entry unconditionally.
* strace.c (usage): Mention kvm argument of -e option unconditionally.
2018-07-11 00:00:57 +00:00
Eugene Syromyatnikov
7374607613 xlat: update bpf(2)-related constants
* xlat/bpf_attach_type.in (BPF_CGROUP_UDP4_SENDMSG,
BPF_CGROUP_UDP6_SENDMSG): New constant, introduced by Linux commit
v4.18-rc1~114^2~9^2~20^2~4.
(BPF_LIRC_MODE2): New constant, introduced by Linux commit
v4.18-rc1~114^2~9^2~15^2~1.
* xlat/bpf_commands.in (BPF_BTF_LOAD): New constant, introduced by Linux
commit v4.18-rc1~114^2~417^2~1^2~5.
(BPF_BTF_GET_FD_BY_ID): New constant, introduced by Linux commit
v4.18-rc1~114^2~223^2~21^2~4.
(BPF_TASK_FD_QUERY): New constant, introduced by Linux commit
v4.18-rc1~114^2~148^2~1^2~5.
* xlat/bpf_map_types.in (BPF_MAP_TYPE_XSKMAP): New constant, introduced
by Linux commit v4.18-rc1~114^2~304^2~4^2~8.
(BPF_MAP_TYPE_SOCKHASH): New constant, introduced by Linux commit
v4.18-rc1~114^2~223^2~5^2~2.
* xlat/bpf_prog_types.in (BPF_PROG_TYPE_LWT_SEG6LOCAL): New constant,
introduced by Linux commit v4.18-rc1~114^2~148^2~2^2~1.
(BPF_PROG_TYPE_LIRC_MODE2): New constant, introduced by Linux commit
v4.18-rc1~114^2~9^2~15^2~1.
* tests/bpf.c: Update expected output.
2018-07-11 00:00:57 +00:00
Eugene Syromyatnikov
2756a36f25 Wire up io_pgetevents and rseq on hppa, microblaze, mips, powerpc, and s390
* linux/hppa/syscallent.h ([350]): Wire up io_pgetevents syscall
introduced by Linux commit v4.18-rc3~7^2~2.
* linux/microblaze/syscallent.h ([399], [400]): Wire up io_pgetevents
and rseq syscalls introduced by Linux commit v4.18-rc3~33^2~2.
* linux/mips/syscallent-n32.h ([6331], [6332]): Wire up rseq and
io_pgetevents syscalls introduced by Linux commits v4.18-rc2~11^2~2
and v4.18-rc2~11^2, respectively.
* linux/mips/syscallent-n64.h ([5327], [5328]): Likewise.
* linux/mips/syscallent-o32.h ([4367], [4368]): Likewise.
* linux/powerpc/syscallent.h ([388]): Wire up io_pgetevents syscall
introduced by Linux commit v4.18-rc3~14^2~2.
* linux/powerpc64/syscallent.h ([388]): Likewise.
* linux/s390/syscallent.h ([382], [383]): Wire up io_pgetevents
and rseq syscalls introduced by Linux commits v4.18-rc4~18^2~1
and v4.18-rc4~18^2, respectively.
* linux/s390x/syscallent.h([382], [383]): Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-07-11 00:00:57 +00:00
Eugene Syromyatnikov
06de4ac148 maint: improve the tag message
* maint/gen-tag-message.sh: Align the wording of the changes section
header with the one used in NEWS, add a reference to CREDITS in
"Contributors" section.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-07-11 00:00:57 +00:00
b39cb830af Upgrade invalid -e kvm= argument to a fatal error
* filter_qualify.c (qualify_kvm): Call error_msg_and_die instead of
error_msg in case of invalid -e kvm= argument.
* tests/options-syntax.test: Check it.
2018-07-10 16:10:38 +00:00
4a48f6b3e8 Mention -e inject option in "strace -h" output
* strace.c (usage): Mention inject argument of -e option.
2018-07-10 16:10:38 +00:00
Masatake YAMATO
8ca67afef8 tests: check decoding of vcpu auxstr
* tests/ioctl_kvm_run_common.c: Rename from ioctl_kvm_run.c.
(run_kvm): Parametrize printing of KVM_RUN ioctl with print_KVM_RUN
invocation.
(main): Invoke optional KVM_NO_CPUID_CALLBACK macro when the old kernel
behavior is detected.
* tests/Makefile.am (EXTRA_DIST): Add ioctl_kvm_run_common.c.
* tests/ioctl_kvm_run.c: New file, a wrapper around
ioctl_kvm_run_common.c.
* ioctl_kvm_run_auxstr_vcpu.c: Likewise.
* tests/gen_tests.in (ioctl_kvm_run_auxstr_vcpu): New test.
* tests/pure_executables.list: Add ioctl_kvm_run_auxstr_vcpu.
* tests/.gitignore: Likewise.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-07-07 10:29:02 +00:00
Masatake YAMATO
03d4f01e31 strace.1.in: document -e kvm=vcpu option
* strace.1.in (-e kvm=vcpu): Document new option.
* NEWS: Mention -e kvm=vcpu option.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-07-07 10:29:02 +00:00
Masatake YAMATO
b7416438b8 kvm: attach the exit reason of vcpu as auxstr to KVM_RUN output
In KVM, a virtual machine implementation like Qemu can access a vcpu
via ioctl.  KVM_RUN is an ioctl command to enter vcpu.  The command
returns control for various reasons: needs of device emulation or
consuming time slices are the typical ones.  The vmi takes a different
action for the reason.

We, strace users, want to know the reason to understand kvm.  This
change prints the reason as auxstr if "-e kvm=vcpu" option is given,
and if strace runs on Linux 4.16.0 or higher, which includes commit
e46b469278a59781f9b25ff608af84892963821b, "kvm: embed vcpu id to dentry
of vcpu anon inode."

The way to get the reason is a bit complicated because the ioctl does
not return it to the userspace directly.  Instead, the vmi and kvm
communicate via an area of the process virtual memory where the fd of
vcpu is mmap'ed.  strace must peek the area to know the reason.

The change does three things: (1) recording the area for the given vcpu
when the target calls VCPU_CREATE to vcpu_info_list per tcb data field,
(2) verifying the data recorded in vcpu_info_list before doing (3), and
(3) decoding the exit reason field of the area.

The change is complicated because there is a case that strace
does not have a chance to do (1) if -p option is used.
In this case, vcpu_info data created in the step (2).

The area has more fields than "exit reason",
dumping them may be implemented in the future.

* defs.h (struct tcb) [HAVE_LINUX_KVM_H]: Add vcpu_info_list field.
[HAVE_LINUX_KVM_H]: (kvm_run_structure_decoder_init,
kvm_vcpu_info_free): New declarations.
* strace.c (usage): Add "kvm" as a new expression for -e option.
(droptcb): Call kvm_vcpu_info_free.
* filter_qualify.c (qualify_kvm): New function calling
kvm_run_structure_decoder_init to enable for attaching the exit
reason to auxstr.
(qual_options): Add "kvm" as an entry.
* xlat/kvm_exit_reason.in: New file.
* kvm.c: Include xmalloc.h and mmap_cache.h.
(dump_kvm_run_structure): New static variable.
(kvm_run_structure_decoder_init): New function.
(vcpu_info): New struct definition representing the 3-tuple: vcpu file
descriptor, id of the vcpu, and mmap'ed entry.
(vcpu_find, vcpu_alloc, vcpu_register, vcpu_getinfo,
kvm_vcpu_info_free): New functions to access tcb's vcpu_info_list
field and vcpu_info data type.
(is_map_for_file, map_len): New helper functions.
(kvm_ioclt_run_attach_auxstr, kvm_ioctl_decode_run): New functions
decoding vcpu exit reason and attaching the decoded data to auxstr
field of tcb.
(kvm_ioctl_create_vcpu): Call vcpu_register to make an entry mapping
a file descriptor and the vcpu id associated with the fd.
(kvm_ioctl): Call kvm_ioctl_decode_run.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-07-07 10:29:02 +00:00
Masatake YAMATO
ba5656519f mmap_cache: add customizable search function
* mmap_cache.c (mmap_cache_search_custom): New function.
* mmap_cache.h (mmap_cache_search_fn): New type.
(mmap_cache_search_custom): New function prototype.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2018-07-07 10:29:02 +00:00
Pierre Marsais
ba9d45c374 tests: check verbose decoding of kvm ioctl
* tests/ioctl_kvm_run-v.c: New file.
* tests/ioctl_kvm_run.c: Include xlat.h and xlat/kvm_cpuid_flags.h.
(print_kvm_segment, print_kvm_sregs, print_kvm_regs): New functions.
(run_kvm): Use them.
(print_cpuid_ioctl) [VERBOSE]: Print verbose ioctl decoding.
* tests/gen_tests.in (ioctl_kvm_run-v): New entry.
* tests/pure_executables.list: Add ioctl_kvm_run-v.
* tests/.gitignore: Likewise.

Signed-off-by: Pierre Marsais <pierre.marsais@lse.epita.fr>
2018-07-07 10:29:02 +00:00
Pierre Marsais
028d869b95 tests: check decoding of kvm ioctls related to struct kvm_cpuid2
* tests/ioctl_kvm_run.c [!HAVE_STRUCT_KVM_CPUID2]: Skip the test.
(KVM_MAX_CPUID_ENTRIES): New macro.
(print_cpuid_ioctl): New function.
(main): Add tests for cpuid related ioctl.

Signed-off-by: Pierre Marsais <pierre.marsais@lse.epita.fr>
2018-07-07 10:29:02 +00:00
Pierre Marsais
546181b267 kvm: decode the argument of KVM_SET_CPUID2 and KVM_GET_*_CPUID ioctl commands
* configure.ac (AC_CHECK_TYPES): Add struct kvm_cpuid2.
* xlat/kvm_cpuid_flags.in: New file.
* kvm.c [HAVE_STRUCT_KVM_CPUID2]: Include "xlat/kvm_cpuid_flags.h".
[HAVE_STRUCT_KVM_CPUID2] (print_kvm_cpuid_entry, kvm_ioctl_decode_cpuid2):
New functions.
(kvm_ioctl) [HAVE_STRUCT_KVM_CPUID2]: Use kvm_ioctl_decode_cpuid2.
* NEWS: Mention this improvement.

Signed-off-by: Pierre Marsais <pierre.marsais@lse.epita.fr>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-07-07 10:29:02 +00:00
Zhibin Li
da5dbc6b1f net: fix a typo in print_tpacket_stats 2018-07-07 10:29:02 +00:00
3c4e4cdab9 tests: fix race condition in aio.test
* tests/aio.c (main): Print aio_key fields before the io_submit syscall
invocation to avoid races with the kernel.
2018-07-03 16:51:49 +00:00
610a776a74 ci: robustify network-related operations
Reduce false positives by wrapping network-related operations into a loop.

* ci/install-dependencies.sh (retry_if_failed): New function.
Use it to invoke apt-get update, apt-get install, git clone,
add-apt-repository, and pip install.
2018-07-03 13:23:19 +00:00
Zhibin Li
fbb176a7ca .gitignore: ignore linux/linux
Ignore directory linux/linux created by workaround from commit
v4.23-11-g15003d4.

* .gitignore: Add /linux/linux.
2018-06-29 17:56:41 +00:00
15003d43d0 Fix build on systems where libc relies on <linux/signal.h>
Commit v4.23~10 has broken the build with Android's libc because it
relies on the UAPI headers (such as <linux/signal.h>) to define various
types, rather than copying them into the libc headers (such as <signal.h>)
like most other Linux C libraries.

* linux/linux/signal.h: Rename to linux/signal.h.in.
* Makefile.am (strace_SOURCES): Remove linux/linux/signal.h.
(EXTRA_DIST): Add linux/signal.h.in.
(DISTCLEANFILES): Add linux/linux/signal.h.
* configure.ac (AC_CACHE_CHECK): Check whether <linux/signal.h>
can be used along with <signal.h>, install linux/linux/signal.h
workaround if they cannot be used together.

Reported-by: Elliott Hughes <enh@google.com>
Closes: https://github.com/strace/strace/issues/72
2018-06-18 22:59:38 +00:00
Eugene Syromyatnikov
a219217119 xlat: add AUDIT_INTEGRITY_EVM_XATTR to nl_audit_types
* xlat/nl_audit_types.in (AUDIT_INTEGRITY_EVM_XATTR): New constant,
introduced by Linux commit v4.18-rc1~100^2~9.
2018-06-18 18:58:01 +02:00
Eugene Syromyatnikov
14e385877d xlat: add UDP_SEGMENT to sock_udp_options
* xlat/sock_udp_options.in (UDP_SEGMENT): New constant, introduced by
Linux commit v4.18-rc1~114^2~377^2~8.
2018-06-18 18:58:01 +02:00
de412d1f2a Remove redundant range initializers in syscallent files
* linux/aarch64/syscallent.h: Remove redundant range initializers.
* linux/x32/syscallent.h: Likewise.
2018-06-17 23:02:51 +00:00
Chen Jingpiao
34c47e1d1d x32: move rseq syscall entry to a suitable place
As rseq syscall is not x32-specific, move it after the previous one
that is not x32-specific.  Fix the unused syscall number range.

* linux/x32/syscallent.h ([334]): Move it after [333].
([335 ... 511]): Update the range.
2018-06-17 23:02:13 +00:00
Eugene Syromyatnikov
bc8a91c115 aio: make iocb array output more strucutred
* aio.c (print_iocb): Print curly brackets.
(print_iocbp): Do not print curly brackets.
* tests/aio.c: Update expected output.
2018-06-18 01:02:13 +02:00
Eugene Syromyatnikov
b54134352a aio: print IOCB_CMD_* using xlat
* xlat/aio_cmds.in: New file.
* aio.c (tprint_lio_opcode): Change array of structs "cmds" to array of
enums "subs", use printxval_indexn_ex for printing cmd, return sub type
using subs array.
2018-06-18 01:02:13 +02:00
Eugene Syromyatnikov
59974bed26 xlat/sock_tcp_options.in: add #value_indexed
* xlat/sock_tcp_options.in: Add #value_indexed, provide fallback
definitions.
* net.c (print_sockopt_fd_level_name) <case SOL_TCP>: Use
printxval_index instead of printxval.
2018-06-18 01:02:13 +02:00
Eugene Syromyatnikov
af4146c06e xlat/sock_tcp_options.in: update
* xlat/sock_tcp_options.in (TCP_ZEROCOPY_RECEIVE): New constant,
introduced by Linux commit v4.18-rc1~114^2~351^2~1.
(TCP_INQ): New constant, introduced by Linux commit v4.18-rc1~114^2~330.
2018-06-18 01:02:13 +02:00
Eugene Syromyatnikov
a7e1c1a8ca xlat/sigtrap_codes.in: add TRAP_UNK
* xlat/sigtrap_codes.in (TRAP_UNK): New constant, introduced by Linux
commit v4.17-rc1-15-gdb78e6a.
2018-06-18 01:02:13 +02:00
490194a7df Post-release administrivia
* NEWS: Add a header line for the next release.
* debian/changelog.in: Add a changelog entry for 4.23-1.
* strace.spec.in: Likewise.
2018-06-15 17:52:14 +00:00
9a7661cc62 Prepare for 4.23 release
* NEWS: Update for 4.23 release.
2018-06-14 11:00:00 +00:00
2b6e074846 Update copyright headers
Headers updated automatically using maint/update_copyright_years.sh
script.
2018-06-14 11:00:00 +00:00
3afef04492 tests: add missing copyright headers
* tests/prctl-spec-inject.test: Add copyright header.
* tests/qualify_personality.sh: Likewise.
2018-06-14 11:00:00 +00:00
f52ff7d49c maint: document release procedure
* maint/README-release: New file.
* maint/gen-release-notes.sh: Likewise.
* maint/gen-release-github.sh: Likewise.
* maint/gen-release-gitlab.sh: Likewise.
2018-06-14 11:00:00 +00:00
6ef3718d6b maint: prepend contributor names in tag messages with an asterisk
* maint/gen-tag-message.sh: Prepend every line of
gen-contributors-list.sh output with an asterisk.
2018-06-14 11:00:00 +00:00
Eugene Syromyatnikov
451c269e80 Update NEWS 2018-06-14 12:16:04 +02:00
dea01d8d83 Wire up rseq syscall
This new syscall was introduced by Linux commit v4.17-1308-gd7822b1.

* linux/dummy.h (sys_rseq): New macro.
* linux/arm/syscallent.h (398): Add rseq entry.
* linux/i386/syscallent.h (386): Likewise.
* linux/powerpc/syscallent.h (387): Likewise.
* linux/powerpc64/syscallent.h (387): Likewise.
* linux/x32/syscallent.h (334): Likewise.
* linux/x86_64/syscallent.h (334): Likewise.
2018-06-13 23:51:31 +00:00
Eugene Syromyatnikov
2cc81216cb tests: check decoding of io_pgetevents syscall
* configure.ac (AC_CHECK_TYPES): Check for struct __aio_sigset
in <linux/aio_abi.h>.
* tests/aio_pgetevents.c: New file.
* tests/.gitignore: Add aio_pgetevents.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (aio_pgetevents): New test.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-06-13 16:18:38 +00:00