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 patch is similar to what I did in commit
02f9f6b386.
That commit was for sendmsg and recvmsg system calls.
This one is for sendmmsg and recvmmsg system calls.
* defs.h (dumpiov_in_mmsghdr): New declaration.
* net.c (extractmmsghdr): New function derived from printmmsghdr.
(printmmsghdr): Use it.
(dumpiov_in_mmsghdr): New function.
* syscall.c (dumpio) [HAVE_SENDMSG]: Call dumpiov_in_mmsghdr
for recvmmsg and sendmmsg syscalls.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
This fixes compilation with musl libc.
This approach was already used in process.c, so I assume it is safe.
* signal.c: Move [HAVE_LINUX_PTRACE_H] code out of [HAVE_SYS_REG_H] check.
* syscall.c: Likewise.
* util.c: Likewise.
Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
* configure.ac (gl_WARN_ADD): Add -Wsign-compare.
* defs.h (struct tcb): Change 'currpers' type to unsigned.
(struct xlat): Change 'val' type to unsigned
(signame): Add 'const' qualifier to its argument.
(xlookup, printxval): Add 'const' qualifier to the 2nd argument and
change its type to unsigned.
(printpathn): Change the 3rd argument type to unsigned.
(ioctl_lookup): Change 1st argument type to unsigned.
* count.c (call_summary_pers, call_summary): Change 'i' type to unsigned.
* file.c (print_xattr_list): Fix comparisons between signed and unsigned
long values.
* ioctl.c (compare): Fix cast.
(ioctl_lookup): Change 1st argument type to to unsigned.
(ioctl_next_match): Change 'code' type to unsigned.
* mem.c (sys_move_pages): Change 'i' type to unsigned.
* mtd.c (mtd_ioctl): Change 'i' and 'j' types to unsigned.
Print 'i' using %u format string.
* process.c (sys_prctl): Change 'i' type to unsigned.
(printargv): Change 'n' type to unsigned.
(sys_ptrace): Change 'addr' type to unsigned.
* scsi.c (print_sg_io_buffer): Add 'const' qualifier to 'len' argument
and change its type to unsigned. Change 'i' and 'allocated' types
to unsigned.
* signal.c (signame): Add 'const' qualifier to its argument.
Fix comparisons between signed and unsigned values.
(sprintsigmask_n, printsiginfo): Fix comparisons between signed and
unsigned values.
* sock.c (sock_ioctl): Change 'i' and 'nifra' types to unsigned.
* strace.c (expand_tcbtab, alloctcb): Change 'i' type to unsigned.
(detach): Change 'sig' type to unsigned.
(startup_attach): Change 'tcbi' type to unsigned.
(startup_child): Change 'm', 'n', and 'len' types to unsigned.
(init): Use new variable to iterate 'tcbtab'.
(pid2tcb): Change 'i' type to unsigned.
(cleanup): Change 'i' and 'sig' types to unsigned.
* syscall.c (update_personality): Change 'personality' argument type
to unsigned.
(struct qual_options): Change 'bitflag' type to unsigned.
(reallocate_qual): Add 'const' qualifier to its argument and change its
type to unsigned.
(qualify_one): Change 'n' and 'bitflag' arguments types to unsigned.
Add 'const' qualifier to 'n', 'not', and 'pers' arguments.
Change 'p' type to signed int.
(qual_syscall): Change 'bitflag' argument type to unsigned.
Add 'const' qualifier to 'bitflag' and 'not' arguments.
Change 'p' type to signed int.
(qual_signal): Change 'bitflag' argument type to unsigned.
Add 'const' qualifier to 'bitflag' and 'not' arguments.
Change 'i' type to unsigned.
(qual_desc): Change 'bitflag' argument type to unsigned.
Add 'const' qualifier to 'bitflag' and 'not' arguments.
(qualify): Change 'i' type to unsigned.
(get_scno): Change 'currpers' type to unsigned.
Fix a comparison between signed and unsigned values.
* system.c (sys_sysctl): Change 'cnt' and 'max_cnt' types to unsigned.
Fix comparisons between signed and unsigned values.
* util.c (xlookup, printxval): Add 'const' qualifier to 'val' argument
and change its type to unsigned.
(printuid): Fix a comparison between signed and unsigned values.
(printpathn): Change 'n' argument type to unsigned.
(printstr): Change 'size' type to unsigned.
Fix a comparison between signed and unsigned values.
(setbpt): Change 'i' type to unsigned.
* net.c (printsock): Silence a compilation warning.
* reboot.c (sys_reboot): Likewise.
Instead of handling stacktrace capturing and mmap cache invalidating in
sys_* functions, handle them uniformly in trace_syscall_entering using
new flags introduced by previous two commits.
The patch is simpler than its older version(v3). The value of
hide_log_until_execve is just ignored. I found the value is nothing
to do with this patch. unwind_cache_invalidate is mentioned only
once in trace_syscall_exiting.
Both are suggested by Dmitry Levin.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Some system calls require capturing the stack trace before they are
processed in kernel. Typical one is execve. Some system calls require
invalidating mmap cache after they are processed in kernel.
In current implementation these requirements are handled directly by
appropriate syscall handlers. However, it is difficult to keep the
source code maintainable using this approach to cover all system calls
which have such requirements.
A more generic way to implement this is to flag all syscalls that
require special processing, and handle these flags right in
trace_syscall_entering instead of changing syscall handlers.
This patch just defines new flags: STACKTRACE_INVALIDATE_CACHE and
STACKTRACE_CAPTURE_ON_ENTER.
The names of macros are suggested by Dmitry Levin.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Print the stack trace of the traced process after each system call when
-k option is specified. It is implemented using libunwind to unwind the
stack and to obtain the function name pointed by the IP.
Based on the code that was originally taken from strace-plus
of Philip J. Guo.
* configure.ac: Add --with-libunwind option. Check libunwind support.
* Makefile.am: Add libunwind support.
* defs.h (struct tcb) [USE_LIBUNWIND]: Append libunwind specific fields.
[USE_LIBUNWIND] (stack_trace_enabled, alloc_mmap_cache,
delete_mmap_cache, print_stacktrace): New prototypes.
* mem.c (print_mmap, sys_munmap, sys_mprotect): Add libunwind support.
* process.c (sys_execve): Likewise.
* strace.c (usage, alloctcb, droptcb, init): Likewise.
* syscall.c (trace_syscall_exiting): Likewise.
* unwind.c: New file.
* strace.1: Document -k option.
* count.c (count_syscall): Add const qualifier to timeval argument and
rename it. Store the wall clock time spent while in syscall in separate
timeval variable.
* defs.h (count_syscall): Update prototype.
* syscall.c (trace_syscall_exiting): Update count_syscall invocation.
OABI is rarely used in ARM EABI systems nowadays, so disable its support
by default. Add --enable-arm-oabi option to enable ARM OABI support.
* configure.ac: New option --enable-arm-oabi.
* syscall.c (get_scno) [ARM]: Check ENABLE_ARM_OABI macro defined by
configure instead of undocumented STRACE_KNOWS_ONLY_EABI macro.
If an aarch64 strace is tracing a process using the arm personality, it
also needs to call the shuffle_scno function for the ARM-specific
syscalls.
* syscall.c (shuffle_scno): Define on AARCH64.
(get_scno) [AARCH64]: Call shuffle_scno when the tracee is in 32-bit mode.
Signed-off-by: Elliott Hughes <enh@google.com>
* syscall.c (get_scno) [POWERPC64]: Fix 64-bit process detection
on embedded powerpc.
Signed-off-by: James Yang <james.yang@freescale.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
The code base has settled on PTRACE_{PEEK,POKE}USER (with an E) and has
logic in defs.h to make sure it's set sanely. Delete this old logic as
the defs.h takes care of it now.
* process.c: Delete PTRACE_PEEKUSR/PTRACE_POKEUSR defines.
* signal.c: Likewise.
* syscall.c: Delete PTRACE_PEEKUSR define.
* util.c: Likewise.
Since glibc-2.18~39 <sys/ptrace.h> defines ptrace_peeksiginfo_args
which collides with <linux/ptrace.h>.
* configure.ac: Check for `struct ptrace_peeksiginfo_args' in
<sys/ptrace.h>.
* process.c: Work around potential conflict between <sys/ptrace.h>
and <linux/ptrace.h> by redefining ptrace_peeksiginfo_args.
* signal.c: Likewise.
* syscall.c: Likewise.
* util.c: Likewise.
Signed-off-by: Ali Polatel <alip@exherbo.org>
Take #2 on mainlining strace support for ARC (last one was 4.6 based back
in March 2011), see
http://sourceforge.net/p/strace/mailman/message/27210168/
The syscall ABI is asm-generic/unistd.h based (so no legacy syscalls),
hence very similar to metag port.
test/* all seem to work well.
* linux/arc/ioctlent.h.in: New file.
* linux/arc/syscallent.h: Likewise.
* Makefile.am (EXTRA_DIST): Add linux/arc/ioctlent.h.in and
linux/arc/syscallent.h.
* configure.ac: Add ARC to the list of supported architectures.
* defs.h: Add ARC support.
* process.c (struct_user_offsets): Likewise.
* signal.c (sys_sigreturn): Likewise.
* syscall.c (print_pc, get_regset, get_regs, get_scno, get_syscall_args,
get_syscall_result, get_error): Likewise.
* util.c (change_syscall): Likewise.
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
ARM in fact has 64 signals (1..64), and NSIG should be 65
(as usual, rememebr that NSIG_libc == NSIG_kernel+1).
I carefully reviewed all usages of NSIG. In syscall.c,
the only usage is:
for (i = 0; i <= NSIG; i++)
if (strcasecmp(s, signame(i) + 3) == 0)...
which is safe even if NSIG is way too big - signame(i)
returns a well-formed string for any i.
In signal.c, memcpy(&sigset, &sc.sc_mask, NSIG / 8) is used by
IA64 and TILE code, so ARM change can't affect it. And final
usage is:
struct new_sigaction::unsigned long sa_mask[NSIG / sizeof(long)];
It will grow on ARM (and become correct in the process).
Its only use is
memcpy(&sigset, &sa.sa_mask, NSIG / 8);
printsigmask(&sigset, 1);
which used to copy garbage in high bits, now it will copy actual data.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This includes decoding of 32-bit sigreturn by 64-bit strace,
which previously wasn't done.
Added a test for it.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Fix a number of differing signedness warnings when building on
powerpc.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Before this change, the logic was as follows:
syscall entry:
get_scno:
syscall_mode = GPR2
scno = syscall_mode unless syscall_mode == -ENOSYS
(if -ENOSYS, scn is retrieved by decoding current insn)
fixup:
gpr2 = GPR2
syscall_mode = scno unless syscall_mode == -ENOSYS
if (gpr2 != syscall_mode) stray_entry
syscall exit:
get_res:
gpr2 = GRP2
fixup:
syscall_mode = scno unless syscall_mode == -ENOSYS
if (WAITEXECVE && gpr2 in (-ENOSYS, scno)) gpr2 = 0;
get_error:
gpr2 is retval
Entry fixup's if() can never trigger:
regardless whether GPR2 is -ENOSYS or not, syscall_mode is always
equal to GRP2 value there. So it can be removed.
On sysexit path, syscall mode is never used.
Therefore, syscall_mode variable is deleted. grp2 is read from
GPR2 register in get_scno, redundant read in entry fixup is removed.
As a result, entry fixup's s390 code block vanishes completely.
gpr2 variable is renamed s390_gpr2 to match the convention used
by other arches.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
PTRACE_GETREGS was added to the ppc kernel in 2.6.23. In order to
provide backward compatibility for very old kernels, add a manual
fallback.
* syscall.c (powerpc_getreg, powerpc_getregs_old): New functions.
(get_regs): Call powerpc_getregs_old if PTRACE_GETREGS is not supported.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Tested with "./strace [-D] [-q] [-bexecve] env true",
all cases seem to work.
* defs.h: Declare new variable: bool hide_log_until_execve.
* strace.c: Define hide_log_until_execve.
Rename skip_startup_execve to skip_one_b_execve.
(startup_child): Do not set skip_one_b_execve = 1 here.
(init): If "strace PROG" case (as opposed to "strace -pPID"),
set skip_one_b_execve and hide_log_until_execve to 1.
(trace): Don't print signal messages if hide_log_until_execve == 1.
* syscall.c (trace_syscall_entering):
Skip syscall printing if hide_log_until_execve == 1.
Reset hide_log_until_execve if we enter execve syscall.
(trace_syscall_exiting): Skip syscall printing if hide_log_until_execve == 1.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* syscall.c [I386 || ARM || OR1K || METAG] (ARCH_REGS_FOR_GETREGSET):
New macro.
(get_regset): Implement for AARCH64, METAG, OR1K and X32.
(get_regs) [AARCH64 || METAG || OR1K || X32]: Use it.
Add support for Imagination Technologies Meta architecture (the
architecture/ABI is usually referred to as metag in code). The Meta
Linux kernel port is in the process of being upstreamed for v3.9 so it
uses generic system call numbers.
sys_lookup_dcookie writes a filename to buffer argument, so I've set
TF flag.
nfsservctl appears to be set to sys_ni_syscall in asm-generic/unistd.h
so I've left it blank.
truncate64/ftruncate64/pread64/pwrite64/readahead have unaligned 64bit
args which are packed tightly on metag, so less arguments on metag.
fchdir/llseek takes a file descriptor so s/TF/TD/
sync_file_range has 2 64bit args so uses 6 args, so s/4/6/
timerfd_create/msgget/msgctl/msgrcv/semget/segtimedop/semop/shmget/
shmctl/shmat/shmdt/recvmsg/migrate_pages have different number of args.
oldgetrlimit is just getrlimit for metag.
add TM flag to various memory syscalls.
metag doesn't directly use sys_mmap_pgoff for mmap2.
prlimit64/process_vm_readv/process_vm_writev take a pid so add TP flag.
fanotify_init doesn't appear to take a file descriptor so remove TD.
Add kcmp syscall.
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Christian Svensson <blue@cmd.nu>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This fixes regression introduced by commit v4.7-111-g9cbc15b.
* syscall.c: Merge all nsyscalls* enums into single enum.
Likewise merge nerrnos*, nsignals*, and nioctlents* into single enums.
There is no need to print literal strings through "%s".
Only untrusted strings such as filenames need that.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
MAX_QUALS was 2048, even though most arches used less than 500 entries
in it. MAX_QUALS had to be maintained by hand to be higher than syscall
count. It also limited the highest possible fd to track.
This change makes qual_flagsN[] arrays start sized to the required minimum
(number of syscalls) and grow dynamically if user requested
-e read=BIGNUM. As a precaution, BIGNUM should be < 2^15, but this limit
can be raised with no cost for normal strace invocations.
qual_flags is now a define to qual_vec[current_personality].
As a bonus, this patch aliases sysent, errnoent, signalent, ioctlent
names in one-personality arches to their corresponding <foo>0 arrays,
removing one indirection level.
text data bss dec hex filename
244471 700 12928 258099 3f033 strace.t7/strace
244627 680 10860 256167 3e8a7 strace.t8/strace
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>