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.
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.
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"
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.
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.
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.
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.
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>
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.
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.
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>
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>
* 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>
* 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>
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>
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.
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>
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"
* 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"
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.
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>
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.
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.
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.
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().
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.
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.
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.
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>