IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an
email to Administrator. User accounts are meant only to access repo
and report issues and/or generate pull requests.
This is a purpose-specific Git hosting for
BaseALT
projects. Thank you for your understanding!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
This opens the way for alternative unwinder back-ends.
* unwind.h: New file, defines the unwinder back-end interface.
* unwind.c: Move all libunwind related code ...
* unwind-libunwind.c: ... here.
* Makefile.am [USE_LIBUNWIND] (strace_SOURCES): Add unwind.h
and unwind-libunwind.c.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
This change renames functions exported to strace core part from unwind
subsystem.
The new names imply that unwind subsystem exports two types of
functions. One is for manipulating back-end itself, "unwind_" prefix
is used for this type. Another is for manipulating back-end private data
structure (unwind_ctx) attached to tcb, "unwind_tcb_" is used for this
type.
This naming should help people to understand unwind subsystem
and the relation between unwind subsystem and back-ends.
* defs.h (unwind_print_stacktrace): Rename to unwind_tcb_print.
(unwind_capture_stacktrace): Rename to unwind_tcb_capture.
* unwind.c: Ditto.
* syscall.c (syscall_entering_trace, syscall_exiting_trace): Use
new names.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
The names given to struct tcb.queue field and its type are too common,
this may cause conflicts in the future if new fields are added
to struct tcb.
* defs.h (struct tcb): Rename queue field to unwind_queue,
rename its type queue_t to unwind_queue_t.
* unwind.c (struct unwind_queue_t): Rename to unwind_queue_t.
All users updated.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Narrowing the area where the code refers to names associated with
libunwind is needed to utilize libdw of elfutils as an alternative
unwinder.
* defs.h (struct tcb): Rename libunwind_ui field to unwind_ctx, change
its type to "void *".
* unwind.c (unwind_tcb_init, unwind_tcb_fin, stracetrace_walk): Reflect
* the above field renaming.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* strace.c (open_append): New variable.
(init): Handle -A option.
(strace_fopen): Open file in "a" mode if open_append is set to true.
* strace.1.in: Document this.
* NEWS: Mention this.
Suggested-by: Philipp Marek <philipp.marek@emerion.com>
Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=528488
* strace.c (init): Do not set tflag when rflag is set.
(printleader): Handle rflag and tflag separately.
* strace.1.in (.SH OPTIONS): Add a note about differences between
the monotonic clock time and the wall clock time.
* tests/options-syntax.test: Remove the check for
"-tt has no effect with -r" warning.
* NEWS: Mention this.
Suggested-by: Josh Triplett <josh@freedesktop.org>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466195
It makes sense to try to dump the argument of write syscalls as they can
be readily available despite the fact that error has been returned.
* syscall.c (dumpio): Move check for syserror and check for fd in
read_set to the end of the function.
* tests/read-write.c: Add a check for this behaviour.
* tests/pread64-pwrite64.c: Update expected output.
* NEWS: Mention this.
Suggested-by: J. Bruce Fields <bfields@fieldses.org>
Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=436284
There is no reason to check for auxstr being non-NULL
because syscall_exiting_trace already does the check.
* sched.c (SYS_FUNC(sched_getscheduler)): Do not check tcp->auxstr,
return RVAL_STR unconditionally.
* time.c (do_adjtimex): Likewise.
Since pointers stored in the bpf_attr union are 64-bit regardless
of architecture bitness.
* bpf.c (DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)): Call print_big_u64_addr
for attr.license.
(DEF_BPF_CMD_DECODER(BPF_OBJ_PIN)): Call print_big_u64_addr
for attr.pathname.
* tests/bpf.c (BPF_OBJ_PIN_checks): Check it.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
These were introduced by Linux commit v4.15-rc1~84^2~384^2~4.
* bpf_attr.h (struct BPF_OBJ_PIN_struct): Add file_flags field.
(struct BPF_PROG_GET_NEXT_ID_struct, struct BPF_PROG_GET_FD_BY_ID_struct,
struct BPF_MAP_GET_FD_BY_ID_struct): Add open_flags field.
(BPF_OBJ_PIN_struct_size, expected_BPF_OBJ_PIN_struct_size,
expected_BPF_PROG_GET_NEXT_ID_struct_size,
expected_BPF_PROG_GET_FD_BY_ID_struct_size,
expected_BPF_MAP_GET_FD_BY_ID_struct_size): Update.
* bpf.c (DEF_BPF_CMD_DECODER(BPF_OBJ_PIN)): Check the length, skip
printing the rest of attributes if it is less than offset of the
end of the bpf_fd field, print file_flags field otherwise.
(DEF_BPF_CMD_DECODER(BPF_PROG_GET_NEXT_ID),
DEF_BPF_CMD_DECODER(BPF_PROG_GET_FD_BY_ID),
DEF_BPF_CMD_DECODER(BPF_MAP_GET_FD_BY_ID)): Check the length, skip
printing the rest of attributes if it is less than offset of the
end of the next_id field, print open_flags field otherwise.
* xlat/bpf_file_mode_flags.in: New file.
* tests/bpf.c (BPF_OBJ_PIN_checks, BPF_PROG_GET_NEXT_ID_checks,
BPF_PROG_GET_FD_BY_ID_checks, BPF_MAP_GET_FD_BY_ID_checks): Check it.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
The aim of this change is to introduce an ability to perform multiple
checks for a specific bpf command. In order to achieve so, all the
related data is stored in check descriptor, and test_bpf iterates over
it. There are also some provisions made in regard to future changes
(specifically, the way bpf_attr_data union is defined).
* tests/bpf.c (print_bpf_attr): New function, a wrapper around
struct bpf_check.printer.
(test_bpf_): Rename to...
(test_bpf): ...this. Replace arguments with struct bpf_check pointer.
Iterate over possible attribute variants. Account for changes in
attribute initialisation routine: provide a pointer to locally defined
union bpf_attr_data and perform memcpy afterwards. Initialise memory
from data each time before a bpf call.
(TEST_BPF, DEF_*, init_*, print_*): Remove.
(init_BPF_PROG_LOAD_attr, print_BPF_PROG_LOAD_attr,
init_BPF_OBJ_PIN_attr): New functions.
(license, pathname): New variables.
(BPF_MAP_CREATE_checks, BPF_MAP_LOOKUP_ELEM_checks,
BPF_MAP_UPDATE_ELEM_checks, BPF_MAP_DELETE_ELEM_checks,
BPF_MAP_GET_NEXT_KEY_checks, BPF_PROG_LOAD_checks, BPF_OBJ_PIN_checks,
BPF_PROG_ATTACH_checks, BPF_PROG_DETACH_checks,
BPF_PROG_TEST_RUN_checks, BPF_PROG_GET_NEXT_ID_checks,
BPF_PROG_GET_FD_BY_ID_checks, BPF_MAP_GET_FD_BY_ID_checks,
BPF_OBJ_GET_INFO_BY_FD_checks): New arrays.
(BPF_OBJ_GET_checks, BPF_MAP_GET_NEXT_ID_checks): New macros.
(CHK): New macro, a shorthand for initialising array of struct bpf_check.
(main): New static constant checks, iterate over checks and run test_bpf
with each element.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
* configure.ac (AC_CHECK_HEADERS([linux/bpf.h])): Check for
struct bpf_insn.
* tests/bpf.c: Remove the test guard, include "scno.h", "bpf_attr.h",
"xlat.h", and "xlat/bpf_commands.h". Conditionalize inclusion of
<linux/bpf.h> on HAVE_LINUX_BPF_H. Remove all HAVE_UNION_* checks.
(BPF_ATTR_DATA_FIELD): New macro.
(bpf_attr_data): New union. Note that it is larger than modern
union bpf_attr, this allows more checks to be implemented in the future.
(sizeof_attr, test_bpf_): Replace union bpf_attr with
union bpf_attr_data.
(DEF_BPF_INIT_FIRST): Replace union bpf_attr with the corresponding
structure.
(init_BPF_MAP_CREATE_attr): Replace union bpf_attr with
struct BPF_MAP_CREATE_struct.
(init_BPF_MAP_LOOKUP_ELEM_attr): Replace union bpf_attr with
struct BPF_MAP_LOOKUP_ELEM_struct.
(init_BPF_MAP_UPDATE_ELEM_attr): Replace union bpf_attr with
struct BPF_MAP_UPDATE_ELEM_struct.
(init_BPF_MAP_DELETE_ELEM_attr): Replace union bpf_attr with
struct BPF_MAP_DELETE_ELEM_struct.
(init_BPF_MAP_GET_NEXT_KEY_attr): Replace union bpf_attr with
struct BPF_MAP_GET_NEXT_KEY_struct.
(init_BPF_PROG_LOAD_attr): Replace union bpf_attr with
struct BPF_PROG_LOAD_struct.
(init_BPF_OBJ_PIN_attr): Replace union bpf_attr with
struct BPF_OBJ_PIN_struct.
(init_BPF_PROG_ATTACH_attr): Replace union bpf_attr with
struct BPF_PROG_ATTACH_struct.
(init_BPF_PROG_DETACH_attr): Replace union bpf_attr with
struct BPF_PROG_DETACH_struct.
(init_BPF_PROG_GET_NEXT_ID_attr): Replace union bpf_attr with
struct BPF_PROG_GET_NEXT_ID_struct.
(sample_BPF_PROG_TEST_RUN_attr): Change type from union bpf_attr to
struct BPF_PROG_TEST_RUN_struct, all users updated.
(sample_BPF_OBJ_GET_INFO_BY_FD_attr): Change type from union bpf_attr
to struct BPF_OBJ_GET_INFO_BY_FD_struct, all users updated.
* gen_bpf_attr_check.sh: New file.
* Makefile.am (EXTRA_DIST): Add it.
(strace_SOURCES_check): New variable.
(strace_SOURCES): Add $(strace_SOURCES_check).
(BUILT_SOURCES, CLEANFILES): Add bpf_attr_check.c.
(bpf_attr_check.c): New rule.
(sys_func_h_sources): New variable.
(sys_func.h): Use it instead of strace_SOURCES_c.
* .gitignore: Add /bpf_attr_check.c.
Rather than list by hand some members of union bpf_attr that we check
for availability, automatically list all members of union bpf_attr we
are aware of.
* m4/gen_bpf_attr_m4.sh: New file.
* bootstrap: Invoke it.
* configure.ac (AC_CHECK_HEADERS([linux/bpf.h])): Use st_BPF_ATTR.
* m4/.gitignore: New file.
This also unifies decoders of bpf commands by moving common code
to new macros.
* bpf_attr.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* bpf.c: Include it.
(DEF_BPF_CMD_DECODER): Rename to BEGIN_BPF_CMD_DECODER, add code common
to all decoders. All users updated.
(END_BPF_CMD_DECODER): New macro, add its invocation to all users
of BEGIN_BPF_CMD_DECODER macro.
This is needed at least for bpf, btrfs, and sg_io, as 32-bit tracer
cannot figure out whether the kernel is 32-bit or 64-bit,
and its behaviour differs when it handles u64 as a pointer.
* linux/arch_defs_.h [!CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL]
(CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL): New definition, default to 0.
* linux/arm/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
Define to 1.
* linux/i386/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
Likewise.
* linux/mips/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
Likewise.
* linux/powerpc/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
Likewise.
* linux/riscv/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
Likewise.
* linux/s390/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
Likewise.
* linux/sparc/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
Likewise.
* linux/tile/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
Likewise.
* defs.h (print_big_u64_addr): New function.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
We are going to use static_assert provided by <assert.h> or,
if it doesn't work, our cheap imitation that doesn't display
the message specified as the second argument of static_assert.
* configure.ac (AC_CACHE_CHECK): Check for static_assert in <assert.h>,
define HAVE_STATIC_ASSERT if it is available.
* static_assert.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* tests/Makefile.am (AM_CPPFLAGS): Forward SIZEOF_KERNEL_LONG_T
and SIZEOF_LONG as TESTS_SIZEOF_KERNEL_LONG_T and TESTS_SIZEOF_LONG.
* tests/tests.h [TESTS_SIZEOF_KERNEL_LONG_T] (SIZEOF_KERNEL_LONG_T):
Redefine to TESTS_SIZEOF_KERNEL_LONG_T.
[TESTS_SIZEOF_LONG] (SIZEOF_LONG): Redefine to TESTS_SIZEOF_LONG.
Complements: v4.21~5 ("Export SIZEOF_LONG and SIZEOF_KERNEL_LONG_T to tests")
* maint/ioctls_sym.sh: Add aarch64 and mips architectures to the list
of kvm-capable architectures.
* linux/aarch64/ioctls_arch0.h: Regenerate.
* linux/mips/ioctls_arch0.h: Regenerate.
Fixes: v4.15~92 ("Move KVM_* ioctl entries from ioctls_inc*.h to ioctls_arch*.h")
As it could be not entirely clear what bytes are printed.
* bpf.c (decode_attr_extra_data): Print a comment about the byte range
to be printed.
* tests/bpf.c: Update expected output.
It has only single user and implementation of xlat styles for it would
lead to lots of code duplication.
* defs.h (addflags): Remove declaration.
* mem.c (print_mmap_flags): Convert addflags call into printflags64 with
non-zeroeness flags check.
* xlat.c (addflags): Remove.
Let's make a step towards the growing strace userbase all around
the world and translate something to the language of their choice.
This change enables translation of error messages corresponding
to errno codes, making it consistent with error diagnostics of other
i18n-aware tools, e.g.
$ LANG=es_ES strace -qq -a38 -P /missing unlink /missing
unlink("/missing") = -1 ENOENT (No existe el fichero o el directorio)
unlink: no se puede deshacer el enlace '/missing': No existe el fichero o el directorio
* strace.c: Include <locale.h>.
(main): Invoke setlocale.
* tests/init.sh: Export LC_ALL=C.
* NEWS: Mention this enhancement.
* defs.h (RVAL_PRINT_ERR_VAL): Remove.
* ldt.c (SYS_FUNC(modify_ldt)): Return 0.
* syscall.c (syscall_exiting_trace): When printing an error,
always print struct tcb.u_rval as if RVAL_PRINT_ERR_VAL was set.
Extend the range of injected return value to the maximum, print warnings
if negative injection value can be clipped in compat personality or can
inadvertently turn into a fault injection.
* defs.h (INJECT_F_ERROR): New macro.
* filter_qualify.c (parse_inject_token): Revert type of intval local
variable back to int, check INJECT_F_ERROR along with INJECT_F_RETVAL,
use strtoull to parse retval argument, print warnings in case of retval
clipping and inadvertent fault injection.
(qualify_inject_common): Set INJECT_F_ERROR instead of INJECT_F_RETVAL.
* syscall.c (tamper_with_syscall_exiting): Check inject_data.flags
to determine whether a fault injection or retval injection has to be
performed.
(syscall_exiting_trace) <case RVAL_DECIMAL>: Explicitly print
tcp->u_rval as int if current_klongsize < sizeof(tcp->u_rval).
* tests/inject-nf.c (main): Update.
* tests/inject-nf.test: Test injection of negative return values.
* tests/qual_inject-syntax.test: Remove retval=-1 check as it is now
allowed, add checks for invalid retval parameters.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>