tests: robustify strace -k tests against link-time optimizer
Some distributions enable by default a link-time optimizer that
mangles stack_fcall sample executables in a way that renders them
unusable for test purposes.
Robustify tests to defeat link-time optimizer.
* tests/stack-fcall.h (f0, f1, f2, f3): Add second parameter.
* tests/stack-fcall.c (main): Pass main as the second parameter to f0.
* tests/stack-fcall-0.c (f0): Add second parameter f, pass the xor of it
and f0 to f1.
* tests/stack-fcall-1.c (f1): Add second parameter f, pass the xor of it
and f1 to f2.
* tests/stack-fcall-2.c (f2): Add second parameter f, pass the xor of it
and f2 to f3.
* tests/stack-fcall-3.c: Include <asm/unistd.h>.
(f3): Add second parameter f, invoke __NR_gettid syscall with the xor
of f and f3 as its argument.
tests: check decoding of mode argument of mbind and set_mempolicy syscalls
* tests/mbind.c: Include "scno.h".
(errstr): New variable.
(k_mbind): New function.
(out_str): New macro.
(mpol_modes): New array.
(main): Use it and k_mbind.
* tests/set_mempolicy.c: Include "scno.h", do not include <errno.h>,
"xlat.h" and "xlat/mpol_modes.h".
(errstr): New variable.
(k_set_mempolicy): New function.
(out_str): New macro.
(mpol_modes): New array.
(print_nodes): Use it and k_set_mempolicy.
(main): Likewise.
* tests/mbind-Xabbrev.c: New file.
* tests/mbind-Xraw.c: Likewise.
* tests/mbind-Xverbose.c: Likewise.
* tests/set_mempolicy-Xabbrev.c: Likewise.
* tests/set_mempolicy-Xraw.c: Likewise.
* tests/set_mempolicy-Xverbose.c: Likewise.
* tests/gen_tests.in (mbind-Xabbrev, mbind-Xraw, mbind-Xverbose,
set_mempolicy-Xabbrev, set_mempolicy-Xraw, set_mempolicy-Xverbose):
New entries.
* tests/pure_executables.list: Add mbind-Xabbrev, mbind-Xraw,
mbind-Xverbose, set_mempolicy-Xabbrev, set_mempolicy-Xraw,
and set_mempolicy-Xverbose.
* tests/.gitignore: Likewise.
numa: enhance decoding of mode argument of mbind and set_mempolicy syscalls
Implement decoding of memory policy mode flags introduced by Linux
kernel commits v2.6.26-rc1~990 and v2.6.26-rc1~988.
* xlat/mpol_mode_flags.in: New file.
* numa.c: Include "xlat/mpol_mode_flags.h".
(print_mode): Print MPOL_MODE_FLAGS part of mode argument as flags.
* NEWS: Mention this.
sparc, sparc64: refactor arch_set_error and arch_set_success
* linux/sparc/set_error.c (sparc_set_o0_psr): New function.
(arch_set_error, arch_set_success): Use it.
* linux/sparc64/set_error.c (sparc64_set_o0_tstate): New function.
(arch_set_error, arch_set_success): Use it.
sparc, sparc64: fix syscall tampering when PTRACE_GET_SYSCALL_INFO is in use
When PTRACE_GET_SYSCALL_INFO is in use on sparc, psr is not loaded,
so it has to be loaded explicitly before tampering.
Likewise, when PTRACE_GET_SYSCALL_INFO is in use on sparc64, tstate
is not loaded, so it has to be loaded explicitly before tampering.
* linux/sparc/set_error.c (arch_set_error, arch_set_success): Explicitly
call get_regs before changing psr when PTRACE_GET_SYSCALL_INFO is in use.
* linux/sparc64/set_error.c (arch_set_error, arch_set_success):
Explicitly call get_regs before changing tstate when
PTRACE_GET_SYSCALL_INFO is in use.
* NEWS: Mention this fix.
powerpc: fix syscall tampering when PTRACE_GET_SYSCALL_INFO is in use
When PTRACE_GET_SYSCALL_INFO is in use, CCR is not loaded, so it has
to be loaded explicitly before tampering.
* linux/powerpc/set_error.c (arch_set_error, arch_set_success):
Explicitly load CCR before changing it when PTRACE_GET_SYSCALL_INFO
is in use.
* NEWS: Mention this fix.
* xlat/bpf_attach_type.in (BPF_CGROUP_SYSCTL): New constant introduced
by Linux kernel commit v5.2-rc1~133^2~132^2~39^2~19.
(BPF_CGROUP_UDP4_RECVMSG, BPF_CGROUP_UDP6_RECVMSG): New constants
introduced by Linux kernel commit v5.2-rc6~33^2~44^2^2~5.
* xlat/bpf_commands.in (BPF_MAP_FREEZE): New constant introduced
by Linux kernel commit v5.2-rc1~133^2~193^2~12^2~12.
* xlat/bpf_map_flags.in (BPF_F_RDONLY_PROG, BPF_F_WRONLY_PROG): New
constants introduced by Linux kernel commit
v5.2-rc1~133^2~193^2~12^2~13.
* xlat/bpf_map_types.in (BPF_MAP_TYPE_SK_STORAGE): New constant
introduced by Linux kernel commit v5.2-rc1~133^2~80^2^2~6.
* xlat/bpf_prog_types.in (BPF_PROG_TYPE_CGROUP_SYSCTL): New constant
introduced by Linux kernel commit v5.2-rc1~133^2~132^2~39^2~19.
(BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE): New constant introduced
by Linux kernel commit v5.2-rc1~133^2~80^2~1^2~4.
* NEWS: Mention this.
* tests/bpf.c (BPF_MAP_CREATE_checks, BPF_PROG_LOAD_checks,
BPF_PROG_QUERY_checks): Update.
* tests/kernel_version.c (print_bpf_attr): Update.
Dmitry V. Levin [Thu, 27 Jun 2019 16:51:33 +0000 (16:51 +0000)]
print_dirfd: do not print trailing comma
It was fine to print trailing comma in print_dirfd until introduction
of a syscall with the last argument being a dirfd.
Now it's time to change print_dirfd.
Dmitry V. Levin [Wed, 26 Jun 2019 08:00:39 +0000 (08:00 +0000)]
mips: refactor syscallent initializers
Change format of designated initializers to BASE_NR + offset.
* linux/mips/syscallent-n32.h (BASE_NR): New macro. Use it in designated
initializers.
* linux/mips/syscallent-n64.h: Likewise.
* linux/mips/syscallent-o32.h: Likewise.
Paul Chaignon [Fri, 28 Jun 2019 15:51:42 +0000 (17:51 +0200)]
travis: Move fastest test configuration first
I use Travis CI to check each patch before sending my patchsets. Most
failures are simple and make all test configurations fail. However, since
Travis CI runs test configurations in order and given that the first three
configurations are the slowest ones, it takes about twenty minutes to see
the failure. Moving the fastest test configuration first would allow to
fail earlier. It would become about 3x faster to fail in case of simple
mistakes.
* .travis.yml (CC=gcc, STACKTRACE=no): Move to first position.
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Dmitry V. Levin [Thu, 20 Jun 2019 09:49:27 +0000 (09:49 +0000)]
Enhance decoding of CLONE_PARENT_SETTID flag of clone syscall
* clone.c (SYS_FUNC(clone)): Print the parent_tid returned by the kernel
instead of its address when CLONE_PARENT_SETTID flag is set.
* tests/clone-flags.c (main): Check it.
Dmitry V. Levin [Mon, 27 May 2019 21:25:52 +0000 (21:25 +0000)]
xlat: update KVM_CAP_* constants
* xlat/clone_flags.in (KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2): New
constant introduced by Linux kernel commit v5.2-rc1~17^2~11.
(KVM_CAP_PPC_IRQ_XIVE): New constant introduced by Linux kernel commits
v5.2-rc1~17^2~2^2~19 and v5.2-rc1~17^2~2.
(KVM_CAP_ARM_SVE): New constant introduced by Linux kernel commit
v5.2-rc1~17^2~1^2~31.
(KVM_CAP_ARM_PTRAUTH_ADDRESS, KVM_CAP_ARM_PTRAUTH_GENERIC): New
constants introduced by Linux kernel commits v5.2-rc1~17^2~1^2~10
and v5.2-rc1~17^2~1.
* NEWS: Mention this.
Dmitry V. Levin [Sun, 26 May 2019 22:08:55 +0000 (22:08 +0000)]
xlat: update V4L2_PIX_* constants
* xlat/v4l2_pix_fmts.in (V4L2_PIX_FMT_FWHT_STATELESS): New constant
introduced by Linux kernel commit v5.2-rc1~33^2~132.
(V4L2_PIX_FMT_BGRA32, V4L2_PIX_FMT_BGRX32, V4L2_PIX_FMT_RGBA32,
V4L2_PIX_FMT_RGBX32): New constants introduced by Linux kernel commit
v5.2-rc1~33^2~25.
(V4L2_PIX_FMT_RGBA444, V4L2_PIX_FMT_RGBX444, V4L2_PIX_FMT_ABGR444,
V4L2_PIX_FMT_XBGR444, V4L2_PIX_FMT_XBGR444, V4L2_PIX_FMT_BGRX444): New
constants introduced by Linux kernel commit v5.2-rc1~33^2~24.
(V4L2_PIX_FMT_RGBA555, V4L2_PIX_FMT_RGBX555, V4L2_PIX_FMT_ABGR555,
V4L2_PIX_FMT_XBGR555, V4L2_PIX_FMT_BGRA555, V4L2_PIX_FMT_BGRX555): New
constants introduced by Linux kernel commit v5.2-rc1~33^2~23.
Dmitry V. Levin [Sun, 26 May 2019 22:08:55 +0000 (22:08 +0000)]
xlat: update V4L2_CID_* constants
* xlat/v4l2_control_ids.in (V4L2_CID_FWHT_I_FRAME_QP,
V4L2_CID_FWHT_P_FRAME_QP): New constants introduced by Linux kernel
commit v5.2-rc1~33^2~132.
(V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP,
V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP,
V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP,
V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP): New constants introduced by
Linux kernel commit v5.2-rc1~33^2~95.
* NEWS: Mention this.
Dmitry V. Levin [Sat, 25 May 2019 22:12:30 +0000 (22:12 +0000)]
xlat: update AUDIT_* constants
* xlat/nl_audit_types.in (AUDIT_FANOTIFY): New constant introduced by
Linux kernel commit v4.15-rc1~130^2^2~11.
(AUDIT_TIME_INJOFFSET): New constant introduced by Linux kernel commit
v5.2-rc1~144^2~2.
(AUDIT_TIME_ADJNTPVAL): New constant introduced by Linux kernel commit
v5.2-rc1~144^2~1.
Dmitry V. Levin [Fri, 24 May 2019 21:54:17 +0000 (21:54 +0000)]
xlat: update AUDIT_ARCH_* constants
* xlat/audit_arch.in (AUDIT_ARCH_ARCOMPACT, AUDIT_ARCH_ARCOMPACTBE,
AUDIT_ARCH_ARCV2, AUDIT_ARCH_ARCV2BE): New constants introduced by Linux
kernel commit v5.2-rc1~144^2~16.
(AUDIT_ARCH_C6X, AUDIT_ARCH_C6XBE): New constants introduced by Linux
kernel commit v5.2-rc1~144^2~15.
(AUDIT_ARCH_CSKY): New constant introduced by Linux kernel commit
v5.0-rc1~37^2~15.
(AUDIT_ARCH_H8300): New constant introduced by Linux kernel commit
v5.2-rc1~144^2~14.
(AUDIT_ARCH_HEXAGON): New constant introduced by Linux kernel commit
v5.2-rc1~144^2~12.
(AUDIT_ARCH_NDS32, AUDIT_ARCH_NDS32BE): New constants introduced by
Linux kernel commit v5.2-rc1~144^2~9.
(AUDIT_ARCH_NIOS2): New constant introduced by Linux kernel commit
v5.2-rc1~144^2~8.
(AUDIT_ARCH_RISCV32, AUDIT_ARCH_RISCV64): New constants introduced by
Linux kernel commit v5.0-rc2~23^2~1^2~5.
(AUDIT_ARCH_TILEGX, AUDIT_ARCH_TILEGX32, AUDIT_ARCH_TILEPRO): New
constants introduced by Linux kernel commit v4.3-rc1~83^2~3.
(AUDIT_ARCH_UNICORE): New constant introduced by Linux kernel commit
v5.2-rc1~144^2~6.
(AUDIT_ARCH_XTENSA): New constant introduced by Linux kernel commit
v5.0-rc1~92^2~8.
* NEWS: Mention this.
Dmitry V. Levin [Tue, 21 May 2019 23:30:35 +0000 (23:30 +0000)]
tests: robustify bpf-obj_get_info_by_fd test against future kernels
* tests/bpf-obj_get_info_by_fd.c (print_prog_load, main): Change
log_level from 42 to 7, to placate Linux kernels containing commit
v5.2-rc1~133^2~193^2~18^2~9.
Dmitry V. Levin [Tue, 21 May 2019 21:26:52 +0000 (21:26 +0000)]
xlat: update IPV6_* constants
* xlat/sock_ipv6_options.in (IPV6_MULTICAST_ALL): New constant
introduced by Linux kernel commit v4.20-rc1~14^2~384.
(IPV6_ROUTER_ALERT_ISOLATE): New constant introduced
by Linux kernel commit v5.1-rc1~178^2~22.
* NEWS: Mention this.
Dmitry V. Levin [Mon, 20 May 2019 22:50:44 +0000 (22:50 +0000)]
xlat: update BPF_* constants
* xlat/ebpf_class.in (BPF_JMP32): New constant introduced
by Linux kernel commit v5.1-rc1~178^2~404^2~4^2~15.
* xlat/bpf_map_update_elem_flags.in (BPF_F_LOCK): New constant
introduced by Linux kernel commit v5.1-rc1~178^2~375^2~4^2~3.
* NEWS: Mention this.
Dmitry V. Levin [Mon, 20 May 2019 22:50:44 +0000 (22:50 +0000)]
xlat: update V4L2_* constants
* xlat/v4l2_control_ids.in
(V4L2_CID_MPEG_VIDEO_H264_CONSTRAINED_INTRA_PREDICTION): New constant
introduced by Linux kernel commit v5.1-rc1~88^2~261.
(V4L2_CID_MPEG_VIDEO_H264_CHROMA_QP_INDEX_OFFSET): New constant
introduced by Linux kernel commit v5.1-rc1~88^2~260.
* xlat/v4l2_pix_fmts.in (V4L2_PIX_FMT_AYUV32, V4L2_PIX_FMT_XYUV32,
V4L2_PIX_FMT_VUYA32, V4L2_PIX_FMT_VUYX32): New constants
introduced by Linux kernel commit v5.1-rc1~88^2~90.
* NEWS: Mention this.
Dmitry V. Levin [Fri, 17 May 2019 16:16:29 +0000 (16:16 +0000)]
tests: check decoding of SO_TIMESTAMP*_NEW control messages
* configure.ac (AC_CHECK_TYPES): Check for struct __kernel_timespec
and struct __kernel_sock_timeval.
* tests/msg_control.c [HAVE_STRUCT___KERNEL_SOCK_TIMEVAL ||
HAVE_STRUCT___KERNEL_TIMESPEC]: Include <linux/time_types.h>.
(test_scm_timestamp): Rename to test_scm_timestamp_old.
(test_scm_timestampns): Rename to test_scm_timestampns_old.
(test_scm_timestamping): Rename to test_scm_timestamping_old.
[HAVE_STRUCT___KERNEL_SOCK_TIMEVAL] (test_scm_timestamp_new): New
function.
[HAVE_STRUCT___KERNEL_TIMESPEC] (test_scm_timestampns_new,
test_scm_timestamping_new): New functions.
(test_sol_socket): Use them.
* tests/sockopt-timestamp.c [HAVE_STRUCT___KERNEL_SOCK_TIMEVAL ||
HAVE_STRUCT___KERNEL_TIMESPEC]: Include <linux/time_types.h>.
Include "xlat/sock_options.h" in XLAT_MACROS_ONLY mode.
(print_timestampns_old): Define unconditionally.
[HAVE_STRUCT___KERNEL_SOCK_TIMEVAL] (print_timestamp_new): New function.
[HAVE_STRUCT___KERNEL_TIMESPEC] (print_timestampns_new): Likewise.
(main): Test SO_TIMESTAMPNS_OLD unconditionally.
[HAVE_STRUCT___KERNEL_SOCK_TIMEVAL]: Test SO_TIMESTAMP_NEW.
[HAVE_STRUCT___KERNEL_TIMESPEC]: Test SO_TIMESTAMPNS_NEW.
Dmitry V. Levin [Fri, 17 May 2019 16:16:29 +0000 (16:16 +0000)]
print_timespec.h: parametrize TIMESPEC_T.tv_nsec
This is going to be used to implement a parser of SO_TIMESTAMP_NEW
control message.
* print_timespec.h [!TIMESPEC_NSEC] (TIMESPEC_NSEC): Define to tv_sec.
(TIMESPEC_TO_SEC_NSEC, timespec_fmt, print_timespec_t_utime): Use
TIMESPEC_NSEC instead of tv_sec.
Dmitry V. Levin [Fri, 17 May 2019 16:16:29 +0000 (16:16 +0000)]
xlat: add SO_TIMESTAMP*_NEW constants
* xlat/sock_options.in (SO_TIMESTAMP_NEW, SO_TIMESTAMPNS_NEW,
SO_TIMESTAMPING_NEW): New constants introduced by Linux commits
v5.1-rc1~178^2~363^2~4 and v5.1-rc1~178^2~363^2~3.
* xlat/scmvals.in: Likewise.
Dmitry V. Levin [Thu, 16 May 2019 22:46:26 +0000 (22:46 +0000)]
Use kernel_timeval64_t in definition of kernel_timex64_t
* kernel_timex.h: Include "kernel_timeval.h".
(kernel_timex64_t): Change the type of "time" field from a locally
defined structure to its equivalent kernel_timeval64_t.
Dmitry V. Levin [Wed, 15 May 2019 16:52:37 +0000 (16:52 +0000)]
Replace SCM_TIMESTAMP* constants with SO_TIMESTAMP*
Besides the fact that SO_TIMESTAMP* constants appear to be more
standardized than SCM_TIMESTAMP*, new SO_TIMESTAMP*_OLD and
SO_TIMESTAMP*_NEW constants introduced in Linux 5.1 have no
SCM_TIMESTAMP*_OLD and SCM_TIMESTAMP*_NEW analogues.
* xlat/scmvals.in: Replace SCM_WIFI_STATUS, SCM_TXTIME, SCM_TIMESTAMP,
SCM_TIMESTAMPNS, and SCM_TIMESTAMPING with SO_WIFI_STATUS, SO_TXTIME,
SO_TIMESTAMP, SO_TIMESTAMPNS, and SO_TIMESTAMPING, respectively.
* msghdr.c: Include "xlat/sock_options.h" in XLAT_MACROS_ONLY mode.
(cmsg_socket_printers): Replace SCM_TIMESTAMP, SCM_TIMESTAMPNS, and
SCM_TIMESTAMPING with SO_TIMESTAMP, SO_TIMESTAMPNS, and SO_TIMESTAMPING,
respectively.
* tests/msg_control.c: Include "xlat/sock_options.h" in XLAT_MACROS_ONLY
mode.
(test_scm_timestamp): Replace SCM_TIMESTAMP with SO_TIMESTAMP.
(test_scm_timestampns): Replace SCM_TIMESTAMPNS with SO_TIMESTAMPNS.
(test_scm_timestamping): Replace SCM_TIMESTAMPING with SO_TIMESTAMPING.
* tests/sockopt-timestamp.c (main): Replace SCM_TIMESTAMP and
SCM_TIMESTAMPNS with SO_TIMESTAMP and SO_TIMESTAMPNS, respectively.