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!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
We can never be cautious enough.
* defs.h (set_personality): Change argument type to unsigned int.
* syscall.c (set_personality): Change argument type to unsigned int,
check whether requested personality is sane, die otherwise.
As all the personality-dependent entries are initially in sync, we can
move the check whether we are setting the same personality as we
currently are inside set_personality out of update_personality.
* syscall.c (current_wordsize, current_klongsize): Initialise to 0'th
personality value in order to make the statement about "all the
personality-dependent entries are initially in sync" true.
(set_personality): Check whether requested personality differs from
current_personality.
(update_personality): Call set_personality unconditionally.
Sometimes (for example, switching from a process with one personality
to a process that previously had different personality but returning
from execve to that same personality into) it is possible that
current_personality is not changed, but tcp->currpers is different.
So, let's not return from update_personality and always update
tcp->currpers if it differs from the target personality.
* syscall.c (update_personality): Do not exit early if personality ==
current_personality.
* defs.h (HAVE_PERSONALITY_1_MPERS, HAVE_PERSONALITY_2_MPERS): New
macros.
* syscall.c (update_personality): Add need_mpers_warning array
initialized with mpers support data. Use it for printing the mpers
unavailability warning once per personality.
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Some weird syscalls (like modify_ldt) return value that doesn't indicate
an error (less than -4096), but it is, in fact, erroneous (because they
decide to clip the return value to 32-bit, for example).
Add a flag to print decoded error code along with syscall return value.
* defs.h (RVAL_PRINT_ERR_VAL): New rval flag.
* syscall.c (syscall_exiting_trace): Handle it.
This is a part of "Prepare for adding support for Lua scripting"
commit.
* defs.h (personality_names): New external constant declaration.
* syscall.c: (personality_names): New global variable.
(update_personality): Use personality_names for reporting personality
name.
Co-Authored-by: Eugene Syromyatnikov <evgsyr@gmail.com>
* linux/powerpc/getregs_old.c (getregs_old): Change the first argument
from pid_t pid to struct tcb *tcp. Replace all instances of pid with
tcp->pid.
* linux/x86_64/getregs_old.c (getregs_old): Likewise.
* linux/x86_64/getregs_old.h (getregs_old): Update declaration.
* syscall.c (get_regs) [HAVE_GETREGS_OLD]: Pass tcp to the getregs_old
call instead of tcp->pid.
This opens the way for future changes related to get_regs.
* syscall.c (get_regs): Change argument type from "pid_t"
to "struct tcb *", all callers changed.
This make the code less confusing and opens the way for future changes
related to get_regs.
* syscall.c (syscall_exiting_decode): Move get_regs invocation ...
(get_syscall_result) [ptrace_getregset_or_getregs]: ... here.
Move syscall subcall handling to the same switch statement that
handles ipc and socket subcalls.
* linux/mips/syscallent-o32.h [LINUX_MIPSO32] (SYS_syscall_subcall):
Define.
* syscall.c (decode_mips_subcall): Rename to decode_syscall_subcall,
conditionalize on SYS_syscall_subcall instead of LINUX_MIPSO32.
(syscall_entering_decode) [LINUX_MIPSO32]: Remove.
(syscall_entering_decode) [SYS_syscall_subcall]: Handle SEN_syscall
using decode_syscall_subcall.
* syscall.c (shuffle_scno): Check for ARM_FIRST_SHUFFLED_SYSCALL
instead of ARM || AARCH64. This does not result to any code change
but looks more comprehensible.
* syscall.c (get_regs_error) [!ptrace_getregset_or_getregs]: Do not
define.
(clear_regs) [!ptrace_getregset_or_getregs]: Do not set get_regs_error.
(get_regs) [ptrace_getregset_or_getregs]: Return get_regs_error, all
callers changed to test get_regs return code instead of get_regs_error
static variable, which is now internally used by get_regs() and
clear_regs() only.
(USE_GET_SYSCALL_RESULT_REGS): Do not define.
Use "#ifndef ptrace_getregset_or_getregs"
instead of "#ifdef USE_GET_SYSCALL_RESULT_REGS".
Introduce "flags" field to struct inject_data and use it instead
of magic rval and signo constants.
Due to layout of struct inject_data, this new field does not change
sizeof(struct inject_data).
* defs.h (INJECT_F_RETVAL, INJECT_F_SIGNAL): New macros.
(INJECT_OPTS_RVAL_DEFAULT): Remove macro.
(struct inject_data): Add "flags" field.
* filter_qualify.c (parse_inject_token, qualify_inject_common): Check
struct inject_data.flags instead of inject_data.rval
and inject_data.signo, do not initialize inject_opts.data.
* syscall.c (tamper_with_syscall_entering): Check struct
inject_data.flags instead of inject_data.rval and inject_data.signo.
* defs.h (inject_data): New structure.
(struct inject_opts): Replace "signo" and "rval" fields with "data"
field of type "struct inject_data".
* filter_qualify.c (parse_inject_token, qualify_inject_common): Update
for the new layout of struct inject_opts.
* syscall.c (tamper_with_syscall_entering, tamper_with_syscall_exiting):
Likewise.
Co-authored-by: Victor Krapivensky <krapivenskiy.va@phystech.edu>
I see no reason for not having these definitions for SPARC64 and RISC-V.
Also, borrow the check template from supported_personalities.h.
* syscall.c (update_personality) [defined RISCV, defined SPARC64]
<PERSONALITY_NAMES>: Define it for these architectures.
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
As Chris Metcalf, the author of v4.7-40-g0b99a8a, told in private, there
is no strong reason for having tile's personality name different from
personality names on other architectures, so let's use spaces instead of
dashes here. And, while we are here, remove duplication of personality
name definitions for various architectures.
* syscall.c (update_personality) [defined TILE]: Change dashes to spaces
in personality names.
* number_set.h (number_slot_t, struct number_set): Move to number_set.c.
(struct number_set): Add forward declaration.
(read_set, write_set, signal_set): Change prototypes from objects
to pointers.
* filter_qualify.c (read_set, write_set, signal_set): Change definitions
from objects to pointers.
(abbrev_set, inject_set, raw_set, trace_set, verbose_set): Change
definitions from arrays to pointers.
(qualify_read): Initialize read_set before first use.
(qualify_write): Initialize write_set before first use.
(qualify_signals): Initialize signal_set before first use.
(qualify_trace): Initialize trace_set before first use.
(qualify_abbrev): Initialize abbrev_set before first use.
(qualify_verbose): Initialize verbose_set before first use.
(qualify_raw): Initialize raw_set before first use.
(qualify_inject_common): Initialize inject_set before first use.
* strace.c (print_signalled, print_stopped): Update signal_set usage.
* syscall.c (dumpio): Update usage of read_set and write_set.
Avoid proliferation of exactly the same definitions of shorthand
notations for macros defined in sysent.h by moving definitions
and undefs of these shorthand notations to separate files.
* sysent_shorthand_defs.h: New file.
* sysent_shorthand_undefs.h: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* syscall.c: Use them.
Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Move is_negated_errno() to a separate new header file negated_errno.h
and include it just for architectures which require it.
is_negated_errno() is not used on those architectures
that have a dedicated register to signal a syscall error.
The issue was raised when compiling with clang, which is more
strict regarding semantics of unused static inline functions
defined in C files and will issue a -Wunused-function warrning
if they are not used anywhere.
* syscall.c (is_negated_errno): Move to ...
* negated_errno.h: ... new file.
* Makefile.am (strace_SOURCES): Add it.
* linux/aarch64/get_error.c: Include it.
* linux/arc/get_error.c: Likewise.
* linux/arm/get_error.c: Likewise.
* linux/avr32/get_error.c: Likewise.
* linux/bfin/get_error.c: Likewise.
* linux/crisv10/get_error.c: Likewise.
* linux/hppa/get_error.c: Likewise.
* linux/i386/get_error.c: Likewise.
* linux/ia64/get_error.c: Likewise.
* linux/m68k/get_error.c: Likewise.
* linux/metag/get_error.c: Likewise.
* linux/microblaze/get_error.c: Likewise.
* linux/or1k/get_error.c: Likewise.
* linux/riscv/get_error.c: Likewise.
* linux/s390/get_error.c: Likewise.
* linux/sh/get_error.c: Likewise.
* linux/sh64/get_error.c: Likewise.
* linux/tile/get_error.c: Likewise.
* linux/x86_64/get_error.c: Likewise.
* linux/xtensa/get_error.c: Likewise.
This change removes the trace_syscall function. Now, the code that uses
syscall.c trace functions is expected to check whether it is a syscall
entry or exit (with entering(tcp)/exiting(tcp)) itself, and then make
an appropriate sequence of function calls.
* defs.h: Update comment on TCB_INSYSCALL.
(trace_syscall): Remove prototype.
(syscall_entering_decode, syscall_entering_trace,
syscall_entering_finish, syscall_exiting_decode, syscall_exiting_trace,
syscall_exiting_finish): New prototypes.
* strace.c (trace_syscall): New static replacement for old trace_syscall.
* syscall.c (trace_syscall): Remove.
(trace_syscall_entering): Split into ...
(syscall_entering_decode, syscall_entering_trace,
syscall_entering_finish): ... new functions.
(trace_syscall_exiting): Split into ...
(syscall_exiting_decode, syscall_exiting_trace,
syscall_exiting_finish): ... new functions.
This saves up to 25% of ptrace syscalls in case of trace filtering.
* syscall.c (trace_syscall_exiting): Do not call gettimeofday
and get_regs for filtered syscalls.
* NEWS: Mention this change.
* tests/get_regs.test: New test.
* tests/Makefile.am (MISC_TESTS): Add it.
strace used to call get_regs on every stop of a tracee, including cases
when the result is going to be discarded. Prepare to change this lavish
practice by delaying get_regs invocation until its result is actually
needed.
* defs.h (get_regs): Remove.
* strace.c (trace): Do not call get_regs.
* syscall.c (get_regs): Add static qualifier.
(trace_syscall_exiting, print_pc, get_scno): Call get_regs.
At this moment there is only one call to get_regs,
but there is going to be more of them, so a guard is needed.
This change also adds a clear_regs call before get_regs,
which essentially reverts commit v4.9-288-ge9bfff6.
* strace.c (trace): Call clear_regs before get_regs.
* syscall.c (get_regs): Skip if get_regs_error != -1.
* syscall.c (trace_syscall_entering, trace_syscall_exiting): Move
definitions of automatic variables closer to their first use. This
change slightly improves readability.
Drop use of INJECT_OPTS_RVAL_DISABLE special inject_opts.rval value,
INJECT_OPTS_RVAL_DEFAULT is enough.
* defs.h (INJECT_OPTS_RVAL_DISABLE): Remove.
* qualify.c (qualify_inject_common): Do not replace
INJECT_OPTS_RVAL_DEFAULT with INJECT_OPTS_RVAL_DISABLE
in inject_opts.rval.
* syscall.c (tamper_with_syscall_entering): Check
for INJECT_OPTS_RVAL_DEFAULT instead of INJECT_OPTS_RVAL_DISABLE.