]> granicus.if.org Git - strace/log
strace
5 years agosyscall.c: set MEMORY_MAPPING_CHANGE in stub sysent
Eugene Syromyatnikov [Tue, 29 Jan 2019 14:35:00 +0000 (15:35 +0100)]
syscall.c: set MEMORY_MAPPING_CHANGE in stub sysent

As unknown syscalls may incur unknown side effects.

* syscall.c (stub_sysent): Set sys_flags to MEMORY_MAPPING_CHANGE.

5 years agoUse accessors for tcp->s_ent, return a stub struct if it is NULL
Eugene Syromyatnikov [Tue, 29 Jan 2019 13:40:11 +0000 (14:40 +0100)]
Use accessors for tcp->s_ent, return a stub struct if it is NULL

Since code paths are non-trivial, it's an attempt to future-proof
and prevent improper access of tcp->s_ent fields.

* defs.h (struct tcb): Update the description of s_ent field.
(stub_sysent): New declaration.
(tcp_sysent, n_args): New macro functions.
(indirect_ipccall): Use tcp_sysent() instead of tcp->s_ent.
* ipc.c (SYS_FUNC(ipc)): Use n_args() instead of tcp->s_ent->nargs.
* linux/alpha/get_syscall_args.c (get_syscall_args): Likewise.
* linux/bfin/get_syscall_args.c (get_syscall_args): Likewise.
* linux/hppa/get_syscall_args.c (get_syscall_args): Likewise.
* linux/ia64/get_syscall_args.c (get_syscall_args): Likewise.
* linux/microblaze/get_syscall_args.c (get_syscall_args): Likewise.
* linux/mips/get_syscall_args.c (get_syscall_args): Likewise.
* linux/sh/get_syscall_args.c (get_syscall_args): Likewise.
* linux/sh64/get_syscall_args.c (get_syscall_args): Likewise.
* linux/x86_64/get_syscall_args.c (get_syscall_args): Likewise.
* linux/xtensa/get_syscall_args.c (get_syscall_args): Likewise.
* prctl.c (print_prctl_args): Likewise.
* signal.c (SYS_FUNC(sgetmask)): Likewise.
* util.c (printargs, printargs_u, printargs_d): Likewise.
* syscall.c (decode_ipc_subcall, decode_syscall_subcall: Likewise.
(dumpio, tamper_with_syscall_exiting, syscall_entering_decode,
syscall_entering_decode, syscall_entering_trace, syscall_entering_trace,
syscall_exiting_decode, print_syscall_resume, syscall_exiting_trace,
get_syscall_result): Use tcp_sysent() instead of tcp->s_ent.
(stub_sysent): New stub sysent.
(get_scno): Reset scno, s_ent, qual_flg; initialise s->ent from
stub_sysent.
* pathtrace.c (pathtrace_match_set): Use tcp_sysent() instead of
tcp->s_ent.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agosyscall.c: remove arch check for SEN_execv usage
Eugene Syromyatnikov [Tue, 29 Jan 2019 13:07:46 +0000 (14:07 +0100)]
syscall.c: remove arch check for SEN_execv usage

SEN_* declarations are always present and can be used regardless
of architecture.

* syscall.c (syscall_entering_trace): Remove "#if defined SPARC ||
defined SPARC64" guard.

5 years agoMerge "<... resumed>" printing
Eugene Syromyatnikov [Tue, 29 Jan 2019 12:54:23 +0000 (13:54 +0100)]
Merge "<... resumed>" printing

Apparently, it was slightly different with no apparent reason.
Use a single routine to print this message now.

* defs.h (print_syscall_resume): New function declaration.
* strace.c (print_event_exit): Replace open-coding of "<... resumed>"
message printing with a print_syscall_resume() call.
* syscall.c (syscall_exiting_trace): Likewise.
(print_syscall_resume): New function.
* tests/threads-execve.c: Update expected output.

5 years agosockaddr: print sin6_flowinfo field before sin6_addr
Shankara Pailoor [Wed, 9 Jan 2019 17:09:04 +0000 (09:09 -0800)]
sockaddr: print sin6_flowinfo field before sin6_addr

The sin6_flowinfo field comes before sin6_addr in the sockaddr_in6
defintion, but for some reason we switch the order when decoding.
This patch fixes the order of decoding.

* sockaddr.c (print_sockaddr_data_in6): Print sin6_flowinfo field
before sin6_addr.
* NEWS: Mention this fix.
* tests/group_req.c (main): Update expected output.
* tests/net-sockaddr.c (check_in6_linklocal, check_in6): Likewise.
* tests/net-yy-inet6.c (INADDR_STR, SA_FIELDS): Likewise.
* tests/sockaddr_xlat.c (validate_in6): Likewise.

5 years agomips o32: fix build
Dmitry V. Levin [Tue, 8 Jan 2019 19:23:44 +0000 (19:23 +0000)]
mips o32: fix build

Commit 917c2ccf3a67 "Refactor stack pointers" moved mips_REG_* macros
from linux/mips/arch_regs.h to linux/mips/arch_regs.c because these
macros are no longer used outside syscall.c or files included by
syscall.c, but this caused a build regression on mips o32 because
decode_syscall_subcall() uses mips_REG_SP prior to its definition.

* syscall.c (decode_syscall_subcall): Move ...
* linux/mips/get_syscall_args.c: ... here.
* NEWS: Mention this fix.

Reported-by: Baruch Siach <baruch@tkos.co.il>
Fixes: v4.26~61 "Refactor stack pointers"
5 years agoFix build for no-MMU targets
Baruch Siach [Tue, 8 Jan 2019 16:36:20 +0000 (18:36 +0200)]
Fix build for no-MMU targets

Commit 7488ce9e23f1 "Check whether PTRACE_GET_SYSCALL_INFO is supported
by the kernel" added a fork() call in test_ptrace_get_syscall_info()
which is included in the main strace executable code.  Although the
test_ptrace_get_syscall_info() routine is not called on no-MMU targets,
the compiler can't optimize it out because it is a global symbol.
So build for no-MMU targets currently fails:

strace-ptrace_syscall_info.o: In function `test_ptrace_get_syscall_info':
ptrace_syscall_info.c:(.text+0x1c): undefined reference to `fork'

* ptrace_syscall_info.c (test_ptrace_get_syscall_info): Make
the definition depend on HAVE_FORK.
* strace.c (init): Call test_ptrace_get_syscall_info unconditionally.
* NEWS: Mention this fix.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Fixes: v4.26~50 "Check whether PTRACE_GET_SYSCALL_INFO is supported by the kernel"
5 years agolinux/mips/.gitignore: drop copyright header
Baruch Siach [Tue, 8 Jan 2019 17:15:35 +0000 (19:15 +0200)]
linux/mips/.gitignore: drop copyright header

The '/*' in the first line of the copyright header matches all files in
that directory.  No other .gitignore file has this header.  Drop it.

* linux/mips/.gitignore: Remove copyright header.

Fixes: v4.26~23 "Add copyright headers to some files that lack them"
5 years agoHonor xlat styles when decoding sockaddr_in, sockaddr_in6, and sockaddr_ll
Shankara Pailoor [Wed, 2 Jan 2019 21:15:28 +0000 (13:15 -0800)]
Honor xlat styles when decoding sockaddr_in, sockaddr_in6, and sockaddr_ll

* print_fields.h (PRINT_FIELD_NET_PORT): Handle xlat styles.
* sockaddr.c (print_sll_protocol): New function.
(print_sockaddr_data_ll, print_inet_addr, print_sockaddr_data_in6):
Handle xlat styles.
* NEWS: Mention this.
* tests/sockaddr_xlat.c: New file.
* tests/sockaddr_xlat-Xabbrev.c: Likewise.
* tests/sockaddr_xlat-Xraw.c: Likewise.
* tests/sockaddr_xlat-Xverbose.c: Likewise.
* tests/Makefile.am (EXTRA_DIST): Add sockaddr_xlat.c.
* tests/gen_tests.in (sockaddr_xlat-Xabbrev, sockaddr_xlat-Xraw,
sockaddr_xlat-Xverbose): New tests.
* tests/pure_executables.list: Add sockaddr_xlat-Xabbrev,
sockaddr_xlat-Xraw, and sockaddr_xlat-Xverbose.
* tests/.gitignore: Likewise.

5 years agoRemove PRINT_FIELD_INET4_ADDR
Dmitry V. Levin [Mon, 7 Jan 2019 23:30:52 +0000 (23:30 +0000)]
Remove PRINT_FIELD_INET4_ADDR

Reduce code duplication by removing PRINT_FIELD_INET4_ADDR
and using PRINT_FIELD_INET_ADDR instead.

* print_fields.h (PRINT_FIELD_INET4_ADDR): Remove.
* msghdr.c (print_cmsg_ip_pktinfo): Use PRINT_FIELD_INET_ADDR
instead of PRINT_FIELD_INET4_ADDR.
* net.c (print_mreq): Likewise.
* sockaddr.c (print_sockaddr_data_in): Likewise.

5 years agoxlat: update REL_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update REL_* constants

* xlat/evdev_relative_axes.in (REL_HWHEEL_HI_RES): New constant
introduced by Linux kernel commit v5.0-rc1~18^2^7~7.
* NEWS: Mention this.

5 years agoxlat: update UDP_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update UDP_* constants

* xlat/sock_udp_options.in (UDP_GRO): New constant introduced
by Linux kernel commit v5.0-rc1~129^2~379^2~8.
* NEWS: Mention this.

5 years agoxlat: update FAN_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update FAN_* constants

* xlat/fan_event_flags.in (FAN_OPEN_EXEC, FAN_OPEN_EXEC_PERM): New
constants introduced by Linux kernel commits v5.0-rc1~124^2~5
and v5.0-rc1~124^2~3, respectively.
* NEWS: Mention this.
* tests/fanotify_mark.c (main): Update expected output.

5 years agoxlat: update SCTP_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update SCTP_* constants

* xlat/sock_sctp_options.in (SCTP_EVENT): New constant introduced
by Linux kernel commit v5.0-rc1~129^2~255^2.
* NEWS: Mention this.

5 years agoxlat: update IFLA_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update IFLA_* constants

* xlat/rtnl_ifla_info_data_bridge_attrs.in (IFLA_BR_MULTI_BOOLOPT): New
constant introduced by Linux kernel commit v5.0-rc1~129^2~207^2~2.
* NEWS: Mention this.
* tests/nlattr_ifla_linkinfo.c (main): Update.

5 years agoxlat: update NETNSA_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update NETNSA_* constants

* xlat/rtnl_nsid_attrs.in (NETNSA_TARGET_NSID, NETNSA_CURRENT_NSID): New
constants introduced by Linux kernel commits v5.0-rc1~129^2~201^2~2
and v5.0-rc1~129^2~201^2, respectively.
* rtnl_nsid.c (rtgenmsg_nla_decoders): Add NETNSA_TARGET_NSID
and NETNSA_CURRENT_NSID.
* NEWS: Mention this.

5 years agoxlat: update SECCOMP_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update SECCOMP_* constants

* xlat/seccomp_ops.in (SECCOMP_GET_NOTIF_SIZES): New constant introduced
by Linux kernel commit v5.0-rc1~66^2~1^2~1.
* xlat/seccomp_ret_action.in (SECCOMP_RET_USER_NOTIF): Likewise.
* xlat/seccomp_filter_flags.in (SECCOMP_FILTER_FLAG_NEW_LISTENER):
Likewise.
* NEWS: Mention this.
* tests/seccomp-filter.c (main): Update expected output.
* tests/seccomp-filter-v.c (main): Likewise.
* tests/seccomp_get_action_avail.c (main): Check SECCOMP_RET_USER_NOTIF.

5 years agoxlat: update NT_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update NT_* constants

* xlat/nt_descriptor_types.in (NT_ARM_PAC_MASK, NT_MIPS_MSA): New
constants introduced by Linux kernel commits v5.0-rc1~35^2~21
and v5.0-rc1~30^2~58, respectively.
* NEWS: Mention this.

5 years agoxlat: update PR_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update PR_* constants

* xlat/prctl_options.in (PR_PAC_RESET_KEYS): New constant introduced
by Linux kernel commit v5.0-rc1~35^2~19.
* NEWS: Mention this.

5 years agoxlat: update V4L2_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update V4L2_* constants

* xlat/v4l2_buf_types.in (V4L2_BUF_TYPE_META_OUTPUT): New constant
introduced by Linux kernel commit v5.0-rc1~181^2~21.
* xlat/v4l2_device_capabilities_flags.in (V4L2_CAP_META_OUTPUT):
Likewise.
* xlat/v4l2_pix_fmts.in (V4L2_PIX_FMT_CNF4): New constant introduced
by Linux kernel commit v5.0-rc1~182^2~120.
* NEWS: Mention this.

5 years agoxlat: update KVM_CAP_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update KVM_CAP_* constants

* xlat/kvm_cap.in (KVM_CAP_MANUAL_DIRTY_LOG_PROTECT,
KVM_CAP_HYPERV_CPUID): New constants introduced by Linux kernel commits
v5.0-rc1~156^2~115 and v5.0-rc1~156^2~74, respectively.
* NEWS: Mention this.

5 years agoxlat: update NDA_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update NDA_* constants

* xlat/rtnl_neigh_attrs.in (NDA_PROTOCOL): New constant introduced
by Linux kernel commit v5.0-rc1~129^2~79.
* rtnl_neigh.c (ndmsg_nla_decoders): Add NDA_PROTOCOL.
* NEWS: Mention this.

5 years agoxlat: update BTRFS_FEATURE_INCOMPAT_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update BTRFS_FEATURE_INCOMPAT_* constants

* xlat/btrfs_features_incompat.in
(BTRFS_FEATURE_INCOMPAT_METADATA_UUID): New constant introduced by Linux
kernel commit v5.0-rc1~126^2~64.
* NEWS: Mention this.

5 years agoxlat: update *_MAGIC constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update *_MAGIC constants

* xlat/fsmagic.in (BINDERFS_SUPER_MAGIC): New constant introduced
by Linux kernel commit v5.0-rc1~95^2~15.
* NEWS: Mention this.

5 years agoxlat: update KERN_* constants
Dmitry V. Levin [Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)]
xlat: update KERN_* constants

* xlat/sysctl_kern.in (KERN_PANIC_ON_WARN, KERN_PANIC_PRINT): New
constants introduced by Linux kernel commits v3.19-rc1~135^2~91
and v5.0-rc1~38^2~16, respectively.
* configure.ac (AC_CHECK_DECLS): Add them.
* NEWS: Mention this.

5 years agoxlat: update BPF_F_* constants
Dmitry V. Levin [Thu, 3 Jan 2019 23:36:22 +0000 (23:36 +0000)]
xlat: update BPF_F_* constants

* xlat/bpf_map_flags.in (BPF_F_ZERO_SEED): New constant introduced
by Linux kernel commit v5.0-rc1~129^2~114^2~18^2~3.
* xlat/bpf_prog_flags.in (BPF_F_ANY_ALIGNMENT): New constant introduced
by Linux kernel commit v5.0-rc1~129^2~209^2~17^2~3.
* NEWS: Mention this.
* tests/bpf.c (BPF_MAP_CREATE_checks, BPF_PROG_LOAD_checks,
print_BPF_PROG_LOAD_attr3, print_BPF_PROG_LOAD_attr4): Update.

5 years agotests: fix prog_info initialization in bpf-obj_get_info_by_fd-prog*
Martin Lau [Thu, 3 Jan 2019 23:36:22 +0000 (23:36 +0000)]
tests: fix prog_info initialization in bpf-obj_get_info_by_fd-prog*

The sys_bpf(BPF_OBJ_GET_INFO_BY_FD, &bpf_prog_get_info_attr, ...) is
called in a loop.  The bpf_prog_get_info_attr.info object is in size 104
but bpf_prog_get_info_attr.info_len is in size 168.  Hence, if the prog
is jited, the second iteration onwards will have nr_jited_ksyms == 1
which is asking the kernel to fill the
bpf_prog_get_info_attr.info.jited_ksyms and it is NULL.

* tests/bpf-obj_get_info_by_fd.c (main): Clear memory beyond prog_info
at the start of every iteration.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agotests: use tail_alloc instead of calloc in bpf-obj_get_info_by_fd-prog*
Dmitry V. Levin [Thu, 3 Jan 2019 23:36:22 +0000 (23:36 +0000)]
tests: use tail_alloc instead of calloc in bpf-obj_get_info_by_fd-prog*

This guarantees that map_info and prog_info objects are not accessed
out of bounds.

* tests/bpf-obj_get_info_by_fd.c: Include <string.h>.
(main): Use tail_alloc instead of calloc for map_info and prog_info.

5 years agoBring lists back to the sorted order
Dmitry V. Levin [Wed, 2 Jan 2019 00:29:09 +0000 (00:29 +0000)]
Bring lists back to the sorted order

* .gitignore: Make the list sorted again.
* Makefile.am (strace_SOURCES): Likewise.
* tests/.gitignore: Likewise.
* tests/gen_tests.in: Likewise.
* tests/Makefile.am (check_PROGRAMS, DECODER_TESTS, EXTRA_DIST):
Likewise.

5 years agotests: fix strace-k.test on alpha
Dmitry V. Levin [Tue, 1 Jan 2019 21:36:08 +0000 (21:36 +0000)]
tests: fix strace-k.test on alpha

Change strace-k.test to use chdir syscall instead of getpid syscall
because the latter is not universally available, e.g. there is no getpid
syscall on alpha.

* tests/stack-fcall-3.c (f3) <default>: Replace getpid with chdir.
* tests/strace-k.test: Likewise.
* tests/strace-k.expected: Likewise.
* tests/strace-k-demangle.expected: Likewise.
* NEWS: Mention this.

5 years agoFix preprocessor indentation
Dmitry V. Levin [Sun, 30 Dec 2018 15:35:21 +0000 (15:35 +0000)]
Fix preprocessor indentation

Indent the C preprocessor directives to reflect their nesting
using the following script:

$ cppi -l $(git grep -El '^[[:space:]]*#[[:space:]]*(if|ifdef|ifndef|elif|else|endif|define|pragma)[[:space:]]' |grep -v '\.sh$') |while read f; do
cppi < "$f" > "$f".cppi; mv "$f".cppi "$f"
done

5 years agoPost-release administrivia
Dmitry V. Levin [Sun, 30 Dec 2018 15:35:21 +0000 (15:35 +0000)]
Post-release administrivia

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

5 years agoPrepare for 4.26 release v4.26
Dmitry V. Levin [Wed, 26 Dec 2018 18:25:10 +0000 (18:25 +0000)]
Prepare for 4.26 release

* NEWS: Update for 4.26 release.

5 years agostrace.spec.in: add a comment about the license
Dmitry V. Levin [Wed, 26 Dec 2018 18:25:10 +0000 (18:25 +0000)]
strace.spec.in: add a comment about the license

5 years agoUpdate ioctl entries from linux v4.20
Gleb Fotengauer-Malinovskiy [Wed, 26 Dec 2018 16:57:01 +0000 (19:57 +0300)]
Update ioctl entries from linux v4.20

* linux/32/ioctls_inc_align16.h: Update from linux v4.20
using ioctls_gen.sh.
* linux/32/ioctls_inc_align32.h: Likewise.
* linux/32/ioctls_inc_align64.h: Likewise.
* linux/64/ioctls_inc.h: Likewise.
* linux/x32/ioctls_inc0.h: Likewise.
* linux/mips/ioctls_arch0.h: Likewise.
* linux/powerpc/ioctls_arch0.h: Likewise.
* linux/s390/ioctls_arch0.h: Likewise.
* linux/s390x/ioctls_arch0.h: Likewise.
* NEWS: Mention this.

5 years agomaint: update for linux 4.20
Gleb Fotengauer-Malinovskiy [Wed, 26 Dec 2018 16:56:18 +0000 (19:56 +0300)]
maint: update for linux 4.20

* maint/ioctls_sym.sh: Include linux/compiler_attributes.h in every
processed file.
Use asm/ioctls.h workaround for asm-generic/ioctls.h too.

5 years agoxlat: update BPF_* constants
Dmitry V. Levin [Wed, 26 Dec 2018 03:38:33 +0000 (03:38 +0000)]
xlat: update BPF_* constants

* xlat/bpf_map_types.in (BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE): New
constant introduced by Linux kernel commit v4.20-rc1~14^2~124^2~12^2~7.
(BPF_MAP_TYPE_QUEUE, BPF_MAP_TYPE_STACK): New constants introduced
by Linux kernel commit v4.20-rc1~151^2~32^2~11^2~3.
* xlat/bpf_commands.in (BPF_MAP_LOOKUP_AND_DELETE_ELEM): New constant
introduced by Linux kernel commit v4.20-rc1~151^2~32^2~11^2~2.
* tests/bpf.c (BPF_MAP_CREATE_checks): Update.

5 years agoxlat: add PR_SPEC_INDIRECT_BRANCH to pr_spec_cmds
Eugene Syromyatnikov [Fri, 14 Dec 2018 16:25:24 +0000 (17:25 +0100)]
xlat: add PR_SPEC_INDIRECT_BRANCH to pr_spec_cmds

* xlat/pr_spec_cmds.in (PR_SPEC_INDIRECT_BRANCH): New constant,
introduced by Linux commit v4.20-rc5~4^2~3.
* prctl.c (SYS_FUNC(prctl)) <case PR_GET_SPECULATION_CTRL, case
PR_SET_SPECULATION_CTRL>: Add PR_SPEC_INDIRECT_BRANCH handling.
* tests/prctl-spec-inject.c (main): Add PR_SPEC_INDIRECT_BRANCH decoding
checks, update expected output.
* NEWS: Mention this.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: update V4L2_CID_* and V4L2_PIX_FMT_* constants
Eugene Syromyatnikov [Thu, 1 Nov 2018 17:18:29 +0000 (18:18 +0100)]
xlat: update V4L2_CID_* and V4L2_PIX_FMT_* constants

* xlat/v4l2_control_ids.in (V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS,
V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION): New constants, introduced
by Linux commit v4.20-rc1~51^2~4.
* xlat/v4l2_pix_fmts.in (V4L2_PIX_FMT_MPEG2_SLICE): Likewise.
(V4L2_PIX_FMT_SUNXI_TILED_NV12): New constant, introduced by Linux
commit v4.20-rc1~51^2~3.
* NEWS: Mention this.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: add ABS_RESERVED to evdev_abs
Eugene Syromyatnikov [Thu, 1 Nov 2018 17:10:06 +0000 (18:10 +0100)]
xlat: add ABS_RESERVED to evdev_abs

* xlat/evdev_abs.in (ABS_RESERVED): New constant, introduced by Linux
commit v4.20-rc1~133^2~2^2.
* NEWS: Mention this.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: add REL_RESERVED and REL_WHEEL_HI_RES to evdev_relative_axes
Eugene Syromyatnikov [Thu, 1 Nov 2018 17:08:15 +0000 (18:08 +0100)]
xlat: add REL_RESERVED and REL_WHEEL_HI_RES to evdev_relative_axes

* xlat/evdev_relative_axes.in (REL_RESERVED): New constant, introduced
by Linux commit v4.20-rc1~133^2~2^2.
(REL_WHEEL_HI_RES): New constant, introduced by Linux commit
v4.20-rc1~133^2~2^2~6 and updated by Linux commit v4.20-rc1~133^2~2^2.
* NEWS: Mention this.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: update kvm_cap
Eugene Syromyatnikov [Sun, 23 Sep 2018 22:43:52 +0000 (00:43 +0200)]
xlat: update kvm_cap

* xlat/kvm_cap.in (KVM_CAP_NESTED_STATE): New constant, introduced
by Linux commit v4.19-rc1~87^2~62.
(KVM_CAP_ARM_INJECT_SERROR_ESR): New constant, introduced by Linux
commit v4.19-rc1~55^2~12^2~14, merged with its final value
in v4.19-rc1~55^2~12.
(KVM_CAP_MSR_PLATFORM_INFO): New constant, introduced by Linux commit
v4.19-rc5~8^2~2.
(KVM_CAP_PPC_NESTED_HV): New constant, introduced by Linux commit
v4.20-rc1~113^2~107^2~1.
(KVM_CAP_HYPERV_SEND_IPI): New constant, introduced by Linux commit
v4.20-rc1~113^2~72.
KVM_CAP_COALESCED_PIO): New constant, introduced by Linux commit
v4.20-rc1~113^2~31.
(KVM_CAP_HYPERV_ENLIGHTENED_VMCS): New constant, introduced by Linux
commit v4.20-rc1~113^2~25.
(KVM_CAP_EXCEPTION_PAYLOAD): New constant, introduced by Linux commit
v4.20-rc1~113^2~8.
(KVM_CAP_ARM_VM_IPA_SIZE): New constant, introduced by Linux commit
v4.20-rc1~113^2~5^2~8 and updated by Linux commit
v4.20-rc1~113^2~5.
* NEWS: Mention this.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: add IFA_TARGET_NETNSID to rtnl_addr_attrs
Eugene Syromyatnikov [Thu, 1 Nov 2018 16:34:10 +0000 (17:34 +0100)]
xlat: add IFA_TARGET_NETNSID to rtnl_addr_attrs

* xlat/rtnl_addr_attrs.in (IFA_TARGET_NETNSID): New constant, introduced
by Linux commit v4.20-rc1~14^2~428^2~7.
* NEWS: Mention this.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: update neighbor_cache_entry_flags
Eugene Syromyatnikov [Thu, 1 Nov 2018 16:29:29 +0000 (17:29 +0100)]
xlat: update neighbor_cache_entry_flags

* xlat/neighbor_cache_entry_flags.in (NTF_OFFLOADED): New constant,
introduced by Linux commit v4.13-rc1~157^2~252^2~13.
(NTF_STICKY): New constant, introduced by Linux commit
v4.20-rc1~14^2~392.
(NTF_USE, NTF_SELF, NTF_MASTER, NTF_PROXY, NTF_EXT_LEARNED, NTF_ROUTER):
Add fallback definitions.
* NEWS: Mention this.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: add flow dissector bpf program type constants
Eugene Syromyatnikov [Thu, 1 Nov 2018 16:15:24 +0000 (17:15 +0100)]
xlat: add flow dissector bpf program type constants

* xlat/bpf_attach_type.in (BPF_FLOW_DISSECTOR): New constant
introduced by Linux commit v4.20-rc1~14^2~259^2~9^2~4.
* xlat/bpf_prog_types.in (BPF_PROG_TYPE_FLOW_DISSECTOR): Likewise.
* NEWS: Mention this.
* tests/bpf.c (BPF_PROG_LOAD_checks, BPF_PROG_QUERY_checks): Update.
* tests/kernel_version.c (print_bpf_attr): Update.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agortnl_tc: add TCA_STATS_BASIC_HW
Eugene Syromyatnikov [Thu, 1 Nov 2018 16:01:29 +0000 (17:01 +0100)]
rtnl_tc: add TCA_STATS_BASIC_HW

* xlat/rtnl_tca_stats_attrs.in (TCA_STATS_BASIC_HW): New constant,
introduced by Linux commit v4.20-rc1~14^2~274^2~1.
* rtnl_tc.c (tca_stats_nla_decoders): Add TCA_STATS_BASIC_HW.
* NEWS: Mention this.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: add NETLINK_DUMP_STRICT_CHK to sock_netlink_options
Eugene Syromyatnikov [Thu, 1 Nov 2018 15:41:01 +0000 (16:41 +0100)]
xlat: add NETLINK_DUMP_STRICT_CHK to sock_netlink_options

* xlat/sock_netlink_options.in (NETLINK_DUMP_STRICT_CHK): New constant,
introduced by Linux commit v4.20-rc1~14^2~130^2~17.
* NEWS: Mention this.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: add IFLA_BR_VLAN_STATS_PER_PORT to rtnl_ifla_info_data_bridge_attrs
Eugene Syromyatnikov [Thu, 1 Nov 2018 15:31:14 +0000 (16:31 +0100)]
xlat: add IFLA_BR_VLAN_STATS_PER_PORT to rtnl_ifla_info_data_bridge_attrs

* xlat/rtnl_ifla_info_data_bridge_attrs.in
(IFLA_BR_VLAN_STATS_PER_PORT): New constant, introduced by Linux commit
v4.20-rc1~14^2~90.
* rtnl_link.c (ifla_info_data_bridge_nla_decoders): Add
IFLA_BR_VLAN_STATS_PER_PORT.
* NEWS: Mention this.
* tests/nlattr_ifla_linkinfo.c (main): Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: add TCP_CLOSE to netlink_states
Eugene Syromyatnikov [Sat, 20 Oct 2018 04:16:05 +0000 (06:16 +0200)]
xlat: add TCP_CLOSE to netlink_states

* xlat/netlink_states.in: Decode state 7 as TCP_CLOSE, since that's what
net core sets socket's initial state to.

5 years agoxlat: add fallback definitions to setsock_ipv6_options
Eugene Syromyatnikov [Mon, 15 Oct 2018 15:56:42 +0000 (17:56 +0200)]
xlat: add fallback definitions to setsock_ipv6_options

* xlat/setsock_ipv6_options.in: Add fallback definitions.

5 years agoxlat: add SOL_CAN_* to socketlayers
Eugene Syromyatnikov [Mon, 15 Oct 2018 15:32:01 +0000 (17:32 +0200)]
xlat: add SOL_CAN_* to socketlayers

* xlat/socketlayers.in (SOL_CAN_BASE): New constant, introduced by Linux
commit v2.6.25-rc1~1162^2~1414.
(SOL_CAN_RAW): New constant, introduced by Linux commit
v2.6.25-rc1~1162^2~1413.
* NEWS: Mention this.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: add FAN_ENABLE_AUDIT and FAN_REPORT_TID to fan_init_flags
Eugene Syromyatnikov [Mon, 10 Sep 2018 23:45:30 +0000 (01:45 +0200)]
xlat: add FAN_ENABLE_AUDIT and FAN_REPORT_TID to fan_init_flags

* xlat/fan_init_flags.in (FAN_ENABLE_AUDIT): New constant, introduced
by Linux commit v4.15-rc1~130^2^2~11.
(FAN_REPORT_TID): New constant, introduced by Linux commit
v4.20-rc1~75^2~2.
* NEWS: Mention this.
* tests/fanotify_init.c (main): Update expected output.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat: update siginfo_codes
Eugene Syromyatnikov [Mon, 15 Oct 2018 15:47:01 +0000 (17:47 +0200)]
xlat: update siginfo_codes

* xlat/siginfo_codes.in (SI_LWP): Remove, as it is not present on Linux.
(SI_NOINFO): Define only on SPARC, provide fallback value.

5 years agoloop: use XLAT_MACROS_ONLY instead of #stop
Eugene Syromyatnikov [Fri, 26 Oct 2018 00:03:40 +0000 (02:03 +0200)]
loop: use XLAT_MACROS_ONLY instead of #stop

As the former allows controlling presence of xlat definitions
during the inclusion and not header generation.

* xlat/loop_cmds.in: Remove #stop.
* loop.c: Wrap "xlat/loop_cmds.h" inclusion in XLAT_MACROS_ONLY.
* tests/ioctl_loop.c: Likewise.

5 years agosyslog: move constant definitions to xlat
Eugene Syromyatnikov [Wed, 26 Sep 2018 16:28:55 +0000 (18:28 +0200)]
syslog: move constant definitions to xlat

* syslog.c (enum): Remove.
* xlat/syslog_action_type.in: Add fallback definitions.

5 years agoAdd copyright headers to some files that lack them
Dmitry V. Levin [Mon, 24 Dec 2018 23:46:43 +0000 (23:46 +0000)]
Add copyright headers to some files that lack them

We do our best to keep copyright headers up to date, yet
git history provides better information on this subject
and is more accurate than copyright headers.

5 years agoUpdate copyright headers
Dmitry V. Levin [Mon, 24 Dec 2018 23:46:43 +0000 (23:46 +0000)]
Update copyright headers

5 years agoUpdate NEWS
Dmitry V. Levin [Mon, 24 Dec 2018 20:00:11 +0000 (20:00 +0000)]
Update NEWS

5 years agostrace.1.in: consistently use CTRL-combinations
Eugene Syromyatnikov [Tue, 4 Sep 2018 18:30:30 +0000 (20:30 +0200)]
strace.1.in: consistently use CTRL-combinations

5 years agostrace.1.in: print names of entities in bold, provide man page sections
Eugene Syromyatnikov [Tue, 4 Sep 2018 14:45:04 +0000 (16:45 +0200)]
strace.1.in: print names of entities in bold, provide man page sections

* strace.1.in (.SH DESCRIPTION, .SH OPTIONS): Add man page section
numbers.  Make mentions of strace and other entities bold.

5 years agostrace.1.in: document %net
Dmitry V. Levin [Mon, 24 Dec 2018 20:00:11 +0000 (20:00 +0000)]
strace.1.in: document %net

* strace.1.in: Mention %net as a synonym to %network.

Complements: v4.25-21-g97c3deca5 "basic_filters: add %net as a possible designation for network syscalls"

5 years agoquotactl: add xlat styles support
Shankara Pailoor [Wed, 19 Dec 2018 13:01:40 +0000 (05:01 -0800)]
quotactl: add xlat styles support

* quota.c (print_qcmd): New function.
(SYS_FUNC(quotactl)): Use it to print the quotactl command.
* tests/quotactl.c (print_dqinfo, print_dqfmt): Handle XLAT_RAW
and XLAT_VERBOSE.
(QUOTA_STR, QUOTA_ID_STR, QUOTA_STR_INVALID): New macros.
(gen_quotacmd, gen_quotaid): New functions.
(main): Use them.
* tests/quotactl-Xabbrev.c: New file.
* tests/quotactl-Xraw.c: Likewise.
* tests/quotactl-Xverbose.c: Likewise.
* tests/gen_tests.in (quotactl-Xabbrev, quotactl-Xraw,
quotactl-Xverbose): New tests.
* tests/pure_executables.list: Add quotactl-Xabbrev, quotactl-Xraw,
and quotactl-Xverbose.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoxlat_idx: do not issue warnings for holes in indices
Dmitry V. Levin [Mon, 24 Dec 2018 10:19:24 +0000 (10:19 +0000)]
xlat_idx: do not issue warnings for holes in indices

Some xlat indices like evdev_abs have holes, avoid issuing warnings
about them.

* xlat.c (xlat_idx): Do not issue warnings for holes in the index.

5 years agortnl_link: fix off-by-one errors in indexed and sorted xlat lookups
Dmitry V. Levin [Sun, 23 Dec 2018 22:12:36 +0000 (22:12 +0000)]
rtnl_link: fix off-by-one errors in indexed and sorted xlat lookups

* rtnl_link.c (decode_nla_tun_type, decode_ifla_xdp_attached,
decode_ifla_inet_conf, decode_ifla_inet6_flags, decode_ifla_inet6_conf,
decode_ifla_inet6_stats, decode_ifla_inet6_icmp6_stats,
decode_ifla_inet6_agm): Decrement xlat size by one to account
for XLAT_END as other users of indexed and sorted xlats do.

Fixes: v4.25~71 "rtnl_link: decode named constants for IFLA_XDP_ATTACHED attribute value"
Fixes: v4.23~41 "rtnl_link: decode IFLA_AF_SPEC"
Fixes: v4.23~37 "rtnl_link: implement IFLA_INFO_DATA for tun devices"
5 years agonet: fix off-by-one error in sorted xlat lookup
Dmitry V. Levin [Sun, 23 Dec 2018 22:12:36 +0000 (22:12 +0000)]
net: fix off-by-one error in sorted xlat lookup

* net.c (ax25_protocols): Decrement xlat size by one to account
for XLAT_END as other users of sorted xlats do.

Fixes: v4.25~28 "net: add support for AX.25 protocols and socket option names decoding"
5 years agonetlink_smc_diag: fix off-by-one error in xlat lookup
Dmitry V. Levin [Sun, 23 Dec 2018 22:12:36 +0000 (22:12 +0000)]
netlink_smc_diag: fix off-by-one error in xlat lookup

* netlink_smc_diag.c (decode_smc_diag_shutdown): Decrement xlat size
by one to account for XLAT_END as other users of xlats do.

Fixes: v4.25~54 "netlink_smc_diag: decode SMC_DIAG_SHUTDOWN attribute value"
5 years agoaio: fix off-by-one error in indexed xlat lookup
Dmitry V. Levin [Sun, 23 Dec 2018 22:12:36 +0000 (22:12 +0000)]
aio: fix off-by-one error in indexed xlat lookup

* aio.c (tprint_lio_opcode): Decrement xlat size by one to account
for XLAT_END as other users of indexed xlats do.

Fixes: v4.24~71 "aio: print IOCB_CMD_* using xlat"
5 years agonlattr: fix off-by-one error in indexed xlat lookup
Dmitry V. Levin [Sun, 23 Dec 2018 22:12:36 +0000 (22:12 +0000)]
nlattr: fix off-by-one error in indexed xlat lookup

* nlattr.c (decode_nla_meminfo): Decrement xlat size by one
to account for XLAT_END as other users of indexed xlats do.

Fixes: v4.23~89 "nlattr: print index names in netlink meminfo array"
5 years agoevdev: fix off-by-one error in decode_bitset
Eugene Syromiatnikov [Thu, 20 Dec 2018 15:35:27 +0000 (16:35 +0100)]
evdev: fix off-by-one error in decode_bitset

* evdev.c (decode_bitset): Decrement sorted/indexed xlat's size by one
in order to account for guarding XLAT_END, as other sorted/indexed xlat
wrappers do.

Fixes: v4.23~261 "evdev: support various types of xlats in decode_bitset"
5 years agostrace: terminate itself if interrupted by a signal
Dmitry V. Levin [Sat, 22 Dec 2018 22:16:03 +0000 (22:16 +0000)]
strace: terminate itself if interrupted by a signal

* strace.c (terminate): Terminate itself if interrupted by a signal.
* NEWS: Mention this change.
* tests/detach-running.test: Check it.
* tests/detach-sleeping.test: Likewise.
* tests/detach-stopped.test: Likewise.

5 years agotests: check that printsignal handles xlat styles properly
Shankara Pailoor [Thu, 20 Dec 2018 13:27:40 +0000 (05:27 -0800)]
tests: check that printsignal handles xlat styles properly

* tests/printsignal.c: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/printsignal-Xabbrev.c: New file.
* tests/printsignal-Xraw.c: Likewise.
* tests/printsignal-Xverbose.c: Likewise.
* tests/gen_tests.in (printsignal-Xabbrev, printsignal-Xraw,
printsignal-Xverbose): New tests.
* tests/pure_executables.list: Add printsignal-Xabbrev,
* printsignal-Xraw, and printsignal-Xverbose.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agosignal: return NULL if signal number has no string representation
Eugene Syromyatnikov [Sun, 7 Oct 2018 03:25:33 +0000 (05:25 +0200)]
signal: return NULL if signal number has no string representation

Also return NULL if signal number is 0.

* signal.c (signame): Return NULL if signal name has not been found.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agofilter_qualify: prepare for the change of signame semantics
Dmitry V. Levin [Sat, 22 Dec 2018 18:58:51 +0000 (18:58 +0000)]
filter_qualify: prepare for the change of signame semantics

* filter_qualify.c (sigstr_to_uint): Check signame return value.

5 years agoUse sprintsigname for converting signal number to string
Eugene Syromyatnikov [Sun, 7 Oct 2018 03:23:09 +0000 (05:23 +0200)]
Use sprintsigname for converting signal number to string

As signame is being converted to an xlookup-like function, a separate
routine is needed in order to get string representation of signal.

* defs.h (sprintsigname): New prototype.
* signal.c (sprintsigname): New function.
* strace.c (print_debug_info, print_signalled, print_stopped): Use it
instead of signame.
* wait.c (printstatus): Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoUse printsignal instead of signame
Eugene Syromyatnikov [Sun, 7 Oct 2018 03:12:42 +0000 (05:12 +0200)]
Use printsignal instead of signame

As the former respects xlat styles while the latter doesn't.

* clone.c (SYS_FUNC(clone)): Use printsignal for printing termination
signal in printflags.
* fcntl.c (print_fcntl) <case F_SETSIG>: Use printsignal.
* prctl.c (SYS_FUNC(prctl)) <case PR_GET_PDEATHSIG,
case PR_SET_PDEATHSIG>: Likewise.
* print_sigevent.c (print_sigevent): Likewise.
* s390.c (s390_runtime_instr): Likewise.
* signal.c (SYS_FUNC(kill), SYS_FUNC(tgkill)): Likewise.

5 years agosignal: make printisgnal honor xlat style
Eugene Syromyatnikov [Sun, 7 Oct 2018 03:09:09 +0000 (05:09 +0200)]
signal: make printisgnal honor xlat style

* signal.c (printsignal): Respect current xlat style.

5 years agoAlways define WCOREDUMP
Eugene Syromyatnikov [Wed, 3 Oct 2018 08:31:30 +0000 (10:31 +0200)]
Always define WCOREDUMP

wait.c does it already, now strace.c also does.

* wait.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* strace.c: Replace <sys/wait.h> with "wait.h".
[!WCOREDUMP]: Remove.
* wait.c: Replace <sys/wait.h> with "wait.h".
[!WCOREFLAG] (WCOREFLAG), [!WCOREDUMP] (WCOREDUMP): Move to wait.h,
rework.
[!W_STOPCODE] (W_STOPCODE), [!W_EXITCODE] (W_EXITCODE),
[!W_CONTINUED] (W_CONTINUED): Move to wait.h.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agonet: enhance decoding of getsockopt(SO_ERROR)
Masatake YAMATO [Mon, 17 Dec 2018 19:16:11 +0000 (04:16 +0900)]
net: enhance decoding of getsockopt(SO_ERROR)

* net.c (print_get_error): New function decoding error
number returned as option value for SO_ERROR option.
(print_getsockopt) <case SO_ERROR>: Call print_get_error.

* tests/so_error.c: New test.
* tests/gen_tests.in (so_error): Likewise.
* tests/pure_executables.list: Add so_error.
* tests/.gitignore: Likewise.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoia64: do not clobber r12 for raw syscalls
Dmitry V. Levin [Mon, 17 Dec 2018 17:30:24 +0000 (17:30 +0000)]
ia64: do not clobber r12 for raw syscalls

According to
https://sourceware.org/ml/libc-alpha/2018-12/msg00470.html
GCC mainline now gives errors for an asm that clobbers the stack
pointer.

According to
https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00932.html>
GCC previously ignored such a clobber; thus, this patch removes it
from the clobbers for ia64 raw syscalls.

* linux/ia64/raw_syscall.h (raw_syscall_0): Remove "r12" from clobbers.

5 years agoblock: decode BLKGETZONESZ and BLKGETNRZONES ioctls
Dmitry V. Levin [Mon, 17 Dec 2018 13:45:05 +0000 (13:45 +0000)]
block: decode BLKGETZONESZ and BLKGETNRZONES ioctls

These ioctls were introduced by linux kernel commits v4.20-rc1~17^2~16
and v4.20-rc1~17^2~15, respectively.

* block.c (block_ioctl): Handle BLKGETZONESZ and BLKGETNRZONES.
* xlat/block_ioctl_cmds.in (BLKGETZONESZ, BLKGETNRZONES): New entries.

5 years agoImplement PTRACE_GET_SYSCALL_INFO decoder
Dmitry V. Levin [Thu, 13 Dec 2018 22:07:26 +0000 (22:07 +0000)]
Implement PTRACE_GET_SYSCALL_INFO decoder

* defs.h (audit_arch): New prototype.
* process.c: Include "ptrace_syscall_info.h".
(SYS_FUNC(ptrace)) <PTRACE_GET_SYSCALL_INFO>: Call
print_ptrace_syscall_info on exiting syscall.
* ptrace_syscall_info.h (print_ptrace_syscall_info): New prototype.
* ptrace_syscall_info.c: Include "print_fields.h" and
"xlat/ptrace_syscall_info_op.h".
(print_ptrace_syscall_info): New function.
* xlat/ptrace_syscall_info_op.in: New file.
* tests/ptrace_syscall_info.c: New file.
* tests/gen_tests.in (ptrace_syscall_info): New test.
* tests/pure_executables.list: Add ptrace_syscall_info.
* tests/.gitignore: Likewise.

5 years agoIntroduce PTRACE_GET_SYSCALL_INFO support
Dmitry V. Levin [Wed, 21 Nov 2018 01:44:16 +0000 (01:44 +0000)]
Introduce PTRACE_GET_SYSCALL_INFO support

When PTRACE_GET_SYSCALL_INFO API works,
use it instead of traditional upeek/get_regs API.

Tested on x86_64 and x86.

* get_personality.c: New file.
* get_personality.h: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* linux/aarch64/arch_get_personality.c: New file.
* linux/powerpc64/arch_get_personality.c: Likewise.
* linux/riscv/arch_get_personality.c: Likewise.
* linux/s390x/arch_get_personality.c: Likewise.
* linux/sparc64/arch_get_personality.c: Likewise.
* linux/tile/arch_get_personality.c: Likewise.
* linux/x32/arch_get_personality.c: Likewise.
* linux/x86_64/arch_get_personality.c: Likewise.
* linux/check_scno.c: Likewise.
* linux/x32/check_scno.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* linux/ia64/arch_getrval2.c (getrval2): Invoke get_regs()
if ptrace_syscall_info is in use.
* linux/mips/arch_getrval2.c: Likewise.
* linux/sparc/arch_getrval2.c: Likewise.
* defs.h (get_personality_from_syscall_info): New prototype.
* syscall.c: Include "get_personality.h" and "ptrace_syscall_info.h".
(get_regs_error): Define unconditionally.
(ptrace_sci): New static variable.
(clear_regs): Reset ptrace_sci.op.
(ptrace_syscall_info_is_valid, ptrace_get_syscall_info,
get_syscall_regs): New functions.
(get_syscall_result_regs): Change to get_syscall_regs.
(get_instruction_pointer, get_stack_pointer, get_scno, get_syscall_args,
get_error, set_error, set_success): Add ptrace_syscall_info support.
* tests/int_0x80.test: New test.
* tests/Makefile.am (DECODER_TESTS): Add int_0x80.test.
(XFAIL_TESTS_x86_64, XFAIL_TESTS_x32): Remove.
* tests/gen_tests.in (int_0x80): Remove.

5 years agoCheck whether PTRACE_GET_SYSCALL_INFO is supported by the kernel
Dmitry V. Levin [Wed, 21 Nov 2018 01:44:16 +0000 (01:44 +0000)]
Check whether PTRACE_GET_SYSCALL_INFO is supported by the kernel

The result of this check is going to be used by subsequent commits.

* ptrace_syscall_info.c: New file.
* ptrace_syscall_info.h: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* strace.c: Include "ptrace_syscall_info.h".
(init): Call test_ptrace_get_syscall_info.

5 years agoAdd definitions for PTRACE_GET_SYSCALL_INFO API
Dmitry V. Levin [Wed, 21 Nov 2018 01:44:16 +0000 (01:44 +0000)]
Add definitions for PTRACE_GET_SYSCALL_INFO API

Provide fallback definitions for PTRACE_GET_SYSCALL_INFO API.
Add very basic PTRACE_GET_SYSCALL_INFO support in the parser
of ptrace syscall.

* ptrace.h: Include <stdint.h>.
[!PTRACE_GET_SYSCALL_INFO] (PTRACE_GET_SYSCALL_INFO,
PTRACE_SYSCALL_INFO_NONE, PTRACE_SYSCALL_INFO_ENTRY,
PTRACE_SYSCALL_INFO_EXIT, PTRACE_SYSCALL_INFO_SECCOMP,
struct ptrace_syscall_info): Define.
* xlat/ptrace_cmds.in: Add PTRACE_GET_SYSCALL_INFO.
* process.c (SYS_FUNC(ptrace)): Handle it.

5 years agoChange the license of strace to LGPL-2.1-or-later
Dmitry V. Levin [Mon, 10 Dec 2018 00:00:00 +0000 (00:00 +0000)]
Change the license of strace to LGPL-2.1-or-later

strace is now provided under the terms of the GNU Lesser General
Public License version 2.1 or later, see COPYING for more details.

strace test suite is now provided under the terms of the GNU General
Public License version 2 or later, see tests/COPYING for more details.

5 years agotests: change the license to GPL-2.0-or-later
Dmitry V. Levin [Mon, 10 Dec 2018 00:00:00 +0000 (00:00 +0000)]
tests: change the license to GPL-2.0-or-later

strace test suite is now provided under the terms of the GNU General
Public License version 2 or later, see tests/COPYING for more details.

5 years agobpf: honor xlat styles when printing kernel version
Shankara Pailoor [Sun, 9 Dec 2018 15:41:43 +0000 (07:41 -0800)]
bpf: honor xlat styles when printing kernel version

* print_kernel_version.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (print_kernel_version): New prototype.
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)):
Use print_kernel_version.
* tests/kernel_version.c: New file.
* tests/kernel_version-Xabbrev.c: Likewise.
* tests/kernel_version-Xraw.c: Likewise.
* tests/kernel_version-Xverbose.c: Likewise.
* tests/gen_tests.in (kernel_version, kernel_version-Xabbrev,
kernel_version-Xraw, kernel_version-Xverbose): New tests.
* tests/pure_executables.list: Add kernel_version,
kernel_version-Xabbrev, kernel_version-Xraw, and kernel_version-Xverbose.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoprint_dev_t: add xlat styles support
Shankara Pailoor [Sat, 8 Dec 2018 22:12:42 +0000 (14:12 -0800)]
print_dev_t: add xlat styles support

* print_dev_t.c (print_dev_t): Respect xlat_verbosity.
* tests/btrfs.c (sprint_makedev): New function.
(btrfs_print_balance_args, btrfs_test_dev_info_ioctl,
btrfs_test_dev_replace_ioctl, btrfs_test_get_dev_stats_ioctl,
btrfs_test_scrub_ioctls): Use it to update expected output.
* tests/xstatx.c (print_st_mode, sprint_makedev): New functions.
(print_stat): Use them.
* tests/fstat-Xabbrev.c: New file.
* tests/fstat-Xraw.c: Likewise.
* tests/fstat-Xverbose.c: Likewise.
* tests/fstat64-Xabbrev.c: Likewise.
* tests/fstat64-Xraw.c: Likewise.
* tests/fstat64-Xverbose.c: Likewise.
* tests/gen_tests.in (fstat-Xabbrev, fstat-Xraw, fstat-Xverbose,
fstat64-Xabbrev, fstat64-Xraw, fstat64-Xverbose): New entries.
* tests/trace_fstat.in: Likewise.
* tests/trace_stat_like.in: Likewise.
* tests/pure_executables.list: Add fstat-Xabbrev, fstat-Xraw,
fstat-Xverbose, fstat64-Xabbrev, fstat64-Xraw, and fstat64-Xverbose.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoi386, x32: use upoke() instead of set_regs()
Dmitry V. Levin [Wed, 5 Dec 2018 18:37:34 +0000 (18:37 +0000)]
i386, x32: use upoke() instead of set_regs()

This brings i386 and x32 in line with x86_64
and removes redundant HAVE_GETREGS_OLD checks.
Besides that, use of PTRACE_GET_SYSCALL_INFO would require
an extra get_regs() invocation before set_regs().

* syscall.c (ARCH_MIGHT_USE_SET_REGS): Define to 1.
[HAVE_GETREGS_OLD] (ARCH_MIGHT_USE_SET_REGS): Redefine to 0.
(ptrace_setregset_or_setregs): Check ARCH_MIGHT_USE_SET_REGS instead
of HAVE_GETREGS_OLD.
* linux/i386/arch_regs.c (ARCH_MIGHT_USE_SET_REGS): Redefine to 0.
* linux/powerpc/arch_regs.c: Likewise.
* linux/x86_64/arch_regs.c: Likewise.
* linux/i386/set_error.c (arch_set_error, arch_set_success)
[!HAVE_GETREGS_OLD]: Remove.
* linux/i386/set_scno.c (arch_set_scno) [!HAVE_GETREGS_OLD]: Remove.
* linux/powerpc/set_error.c (arch_set_error, arch_set_success)
[!HAVE_GETREGS_OLD]: Remove.
* linux/powerpc/set_scno.c (arch_set_scno) [!HAVE_GETREGS_OLD]: Remove.
* linux/x86_64/set_error.c [!HAVE_GETREGS_OLD]: Remove.
* linux/x86_64/set_scno.c: Likewise.

5 years agoupoke: workaround crippled x32
Dmitry V. Levin [Wed, 5 Dec 2018 18:37:34 +0000 (18:37 +0000)]
upoke: workaround crippled x32

As PTRACE_POKEUSER is crippled on x32 by design from the very first
linux kernel commit v3.4-rc1~33^2~2 when it was introduced,
workaround this by using the raw x86_64 syscall instead.

* linux/ptrace_pokeuser.c: New file.
* linux/x32/ptrace_pokeuser.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* upoke.c: Include "ptrace_pokeuser.c".
(upoke): Use ptrace_pokeuser instead of ptrace.

5 years agox86_64: remove some annoying pieces of unused code
Dmitry V. Levin [Wed, 5 Dec 2018 18:37:34 +0000 (18:37 +0000)]
x86_64: remove some annoying pieces of unused code

* linux/x86_64/get_scno.c (X32_PERSONALITY_NUMBER): Remove.
(arch_get_scno): Remove ifdefed archeological artefacts.

5 years agoRefactor tamper_with_syscall_exiting()
Dmitry V. Levin [Wed, 5 Dec 2018 16:10:05 +0000 (16:10 +0000)]
Refactor tamper_with_syscall_exiting()

Move the code than deals with updating the return and error values
to separate functions.

* syscall.c (set_error, set_success): New functions.
(tamper_with_syscall_exiting): Use them.

5 years agoRefactor get_syscall_args() and get_error()
Dmitry V. Levin [Wed, 5 Dec 2018 06:47:35 +0000 (06:47 +0000)]
Refactor get_syscall_args() and get_error()

* linux/*/get_error.c: Rename all arch-specific implementations
of get_error() to arch_get_error().
* linux/*/get_syscall_args.c: Rename all arch-specific implementations
of get_syscall_args() to arch_get_syscall_args().
* syscall.c (get_syscall_args, get_error): New functions.
(tamper_with_syscall_exiting, get_syscall_result): Do not clear
tcp->u_error before get_error() invocation as the latter does it now.

5 years agoRefactor stack pointers
Dmitry V. Levin [Tue, 4 Dec 2018 22:31:41 +0000 (22:31 +0000)]
Refactor stack pointers

Change all linux/*/arch_regs.c to provide either ARCH_SP_REG
or ARCH_SP_PEEK_ADDR.  Introduce get_stack_pointer(), rewrite
all code accessing stack pointers to use get_stack_pointer().
On some architectures stack pointers were referred to as frame pointers,
clean up this confusion.

* defs.h (get_stack_pointer): New prototype.
* syscall.c (get_stack_pointer): New function.
* linux/arch_rt_sigframe.c: New file.
* linux/aarch64/arch_regs.c (aarch64_sp_ptr, arm_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/alpha/arch_regs.c: Import linux/alpha/arch_regs.h.
(REG_FP): Rename to REG_SP.
(ARCH_SP_PEEK_ADDR): New macro.
* linux/alpha/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/arc/arch_regs.c (arc_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/arm/arch_regs.c (arm_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/arm/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/avr32/arch_regs.c (avr32_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/bfin/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/hppa/arch_regs.c: Import linux/hppa/arch_regs.h.
(PT_GR30, ARCH_SP_PEEK_ADDR): New macros.
* linux/hppa/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/i386/arch_regs.c (i386_esp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/i386/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/i386/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/ia64/arch_regs.c (ia64_frame_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/ia64/arch_regs.h (ia64_frame_ptr): Remove.
* linux/ia64/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/m68k/arch_regs.c (m68k_usp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/m68k/arch_rt_sigframe.c: Link to i386/arch_rt_sigframe.c.
* linux/m68k/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/metag/arch_regs.c (metag_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/metag/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/microblaze/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/mips/arch_regs.c: Import linux/mips/arch_regs.h.
(mips_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/mips/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/nios2/arch_regs.c (nios2_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/or1k/arch_regs.c (or1k_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/powerpc/arch_regs.c (ppc_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/powerpc/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/powerpc/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/powerpc64/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/riscv/arch_regs.c (riscv_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/s390/arch_regs.c (s390_frame_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/s390/arch_sigreturn.c (S390_FRAME_PTR): Remove.
(arch_sigreturn): Use get_stack_pointer.
* linux/s390x/arch_regs.c (s390_frame_ptr, s390x_frame_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/s390x/arch_sigreturn.c (S390_FRAME_PTR): Remove.
* linux/sh/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/sh64/arch_regs.c: Likewise.
* linux/sparc/arch_regs.c: Import linux/sparc/arch_regs.h.
(sparc_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/sparc/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/sparc64/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/tile/arch_regs.c (tile_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/tile/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/x86_64/arch_regs.c (i386_esp_ptr, x86_64_rsp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/x86_64/arch_regs.h (i386_esp_ptr, x86_64_rsp_ptr): Remove.
* linux/x86_64/arch_rt_sigframe.c: Link to i386/arch_rt_sigframe.c.
* linux/xtensa/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/aarch64/arch_regs.h: Remove.
* linux/aarch64/arch_rt_sigframe.c: Remove.
* linux/alpha/arch_regs.h: Remove.
* linux/alpha/arch_rt_sigframe.c: Remove.
* linux/arc/arch_regs.h: Remove.
* linux/arc/arch_rt_sigframe.c: Remove.
* linux/arm/arch_regs.h: Remove.
* linux/arm/arch_rt_sigframe.c: Remove.
* linux/avr32/arch_regs.h: Remove.
* linux/avr32/arch_rt_sigframe.c: Remove.
* linux/bfin/arch_rt_sigframe.c: Remove.
* linux/hppa/arch_regs.h: Remove.
* linux/i386/arch_regs.h: Remove.
* linux/m68k/arch_regs.h: Remove.
* linux/metag/arch_regs.h: Remove.
* linux/microblaze/arch_rt_sigframe.c: Remove.
* linux/mips/arch_regs.h: Remove.
* linux/mips/arch_rt_sigframe.c: Remove.
* linux/nios2/arch_regs.h: Remove.
* linux/nios2/arch_rt_sigframe.c: Remove.
* linux/or1k/arch_regs.h: Remove.
* linux/or1k/arch_rt_sigframe.c: Remove.
* linux/powerpc/arch_regs.h: Remove.
* linux/powerpc64/arch_regs.h: Remove.
* linux/riscv/arch_regs.h: Remove.
* linux/riscv/arch_rt_sigframe.c: Remove.
* linux/s390/arch_regs.h: Remove.
* linux/s390/arch_rt_sigframe.c: Remove.
* linux/s390x/arch_regs.h: Remove.
* linux/s390x/arch_rt_sigframe.c: Remove.
* linux/sh/arch_rt_sigframe.c: Remove.
* linux/sh64/arch_rt_sigframe.c: Remove.
* linux/sparc/arch_regs.h: Remove.
* linux/sparc/arch_rt_sigframe.c: Remove.
* linux/sparc64/arch_regs.h: Remove.
* linux/tile/arch_regs.h: Remove.
* linux/tile/arch_rt_sigframe.c: Remove.
* linux/xtensa/arch_rt_sigframe.c: Remove.
* Makefile.am (EXTRA_DIST): Remove them, add linux/arch_rt_sigframe.c.

5 years agoRefactor print_pc()
Dmitry V. Levin [Mon, 3 Dec 2018 19:45:02 +0000 (19:45 +0000)]
Refactor print_pc()

Split print_pc() into arch-independent print_instruction_pointer()
and arch-specific get_instruction_pointer().

* print_instruction_pointer.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (print_pc): Remove.
(get_instruction_pointer, print_instruction_pointer): New prototypes.
* syscall.c (print_pc): Remove.
(get_instruction_pointer): New function.
* strace.c (printleader): Replace print_pc with
print_instruction_pointer.

5 years agoppc64: remove redundant redefinition
Dmitry V. Levin [Tue, 4 Dec 2018 22:31:41 +0000 (22:31 +0000)]
ppc64: remove redundant redefinition

* linux/powerpc64/arch_regs.c (ARCH_PC_REG): Remove.

5 years agoprint_dev_t: print major and minor numbers in hex like stat(1)
Shankara Pailoor [Sun, 2 Dec 2018 19:57:10 +0000 (11:57 -0800)]
print_dev_t: print major and minor numbers in hex like stat(1)

* print_dev_t.c (print_dev_t): Print major and minor numbers in hex.
* strace.1.in: Update makedev example.
* tests/bpf-obj_get_info_by_fd.c (main): Update expected output.
* tests/btrfs.c (btrfs_print_balance_args, btrfs_test_scrub_ioctls,
btrfs_test_dev_info_ioctl, btrfs_test_get_dev_stats_ioctl,
btrfs_test_dev_replace_ioctl): Update expected output.
* tests/ioctl_dm.c (main): Likewise.
* tests/ioctl_loop.c (print_loop_info, print_loop_info64): Likewise.
* tests/mknod.c (main): Likewise.
* tests/mknodat.c (main): Likewise.
* tests/nlattr_unix_diag_msg.c (main): Likewise.
* tests/ustat.c (main): Likewise.
* tests/xstatx.c (print_stat): Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agos390x: beautify sthyi data tail prints
Janosch Frank [Fri, 30 Nov 2018 15:41:39 +0000 (16:41 +0100)]
s390x: beautify sthyi data tail prints

The test already expects a ", " before the print of struct
padding. Let's add it to s390.c to make the output look a bit nicer and
fix test runs on z/VM that have padding at the end of the STHYI structs.

* s390.c (decode_ebcdic): Add missing comma.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
5 years agoStop using SIG_0
Dmitry V. Levin [Tue, 27 Nov 2018 01:13:40 +0000 (01:13 +0000)]
Stop using SIG_0

Number 0 is not a valid signal number, and SIG_0 is not a valid
description for a signal.

* linux/signalent.h: Replace SIG_0 with 0.
* linux/alpha/signalent.h: Likewise.
* linux/hppa/signalent.h: Likewise.
* linux/mips/signalent.h: Likewise.
* linux/sparc/signalent.h: Likewise.
* filter_qualify.c (sigstr_to_uint): Start iterations with number 1.
* tests/fcntl-common.c (test_fcntl_others): Update expected output.
* tests/kill.c (main): Likewise.
* tests/ptrace.c (test_peeksiginfo): Likewise.
* tests/s390_runtime_instr.c (main): Likewise.

5 years agomem: fix build on architectures where kernel_ulong_t is bigger than long
Dmitry V. Levin [Mon, 26 Nov 2018 20:49:05 +0000 (20:49 +0000)]
mem: fix build on architectures where kernel_ulong_t is bigger than long

* mem.c (print_mmap_flags): Fix format string.

Fixes: v4.25-26-g0933b3086 "mem: add xlat styles support to print_mmap_flags"