]> granicus.if.org Git - strace/log
strace
9 years agoarm: fix v4.10-25-g8497b62 fallout
Dmitry V. Levin [Mon, 23 Mar 2015 23:00:37 +0000 (23:00 +0000)]
arm: fix v4.10-25-g8497b62 fallout

Starting with commit v4.10-25-g8497b62,

arm$ ./strace true
pid 1234 stray syscall exit
Segmentation fault

Fix this by updating ARM syscall sanity check.
In particular, get_scno() should not set TCB_INSYSCALL flag because
other code assumes that s_ent is properly initialized when this flag
is set.

* linux/arm/get_scno.c: Check syscall number after fetching.
Do not apply the check to SCNO_IN_RANGE syscalls.
Do not set TCB_INSYSCALL flag.
Extend diagnostics and move it to debug level.

9 years agomips: fix pipe syscall decoding
Dmitry V. Levin [Mon, 23 Mar 2015 23:14:08 +0000 (23:14 +0000)]
mips: fix pipe syscall decoding

* linux/mips/arch_getrval2.c: New file.
* Makefile.am (EXTRA_DIST): Add it.
* defs.h [MIPS] (HAVE_GETRVAL2): Define.

9 years agosigreturn.c: split arch specific code into separate arch files
Dmitry V. Levin [Mon, 23 Mar 2015 21:16:07 +0000 (21:16 +0000)]
sigreturn.c: split arch specific code into separate arch files

Split code that use arch-specific registers to separate arch files.

* sigreturn.c (sys_sigreturn): Move arch-specific code
to linux/*/arch_sigreturn.c, include "arch_sigreturn.c".
* linux/arch_sigreturn.c: New file.
* Makefile.am (EXTRA_DIST): Add linux/arch_sigreturn.c
and linux/*/arch_sigreturn.c files.

9 years agosyscall.c: split arch specific code into separate arch files
Dmitry V. Levin [Sun, 22 Mar 2015 22:13:55 +0000 (22:13 +0000)]
syscall.c: split arch specific code into separate arch files

Split code that use arch-specific registers to separate arch files.

* syscall.c: Move definitions of variables containing fetched registers
to linux/*/arch_regs.c files.
[HAVE_GETRVAL2] (getrval2): Move arch-specific code
to linux/*/arch_getrval2.c, include "arch_getrval2.c".
(print_pc): Move arch-specific code to linux/*/print_pc.c files,
include "print_pc.c".
[X86_64] (x86_64_getregs_old): Rename to getregs_old, move to
linux/x86_64/getregs_old.c, include "getregs_old.c".
[POWERPC] (powerpc_getregs_old): Rename to getregs_old, move to
linux/powerpc/getregs_old.c, include "getregs_old.c".
(get_regs) [X86_64, POWERPC]: Update callers.
(get_scno): Move arch-specific code to linux/*/get_scno.c,
include "get_scno.c".
(get_syscall_args): Move arch-specific code
to linux/*/get_syscall_args.c, include "get_syscall_args.c".
(get_error): Move arch-specific code to linux/*/get_error.c,
include "get_error.c".
(get_syscall_result): Move arch-specific code
to linux/*/get_syscall_result.c, include "get_syscall_result.c".
* Makefile.am (EXTRA_DIST): Add new linux/*/*.c files.

9 years agosyscall.c: prepare for the split
Dmitry V. Levin [Sun, 22 Mar 2015 18:09:55 +0000 (18:09 +0000)]
syscall.c: prepare for the split

Move functions that use arch-specific registers to the end of file.

9 years agoMove get_regs error check from trace_syscall_entering to get_scno
Dmitry V. Levin [Mon, 23 Mar 2015 18:48:32 +0000 (18:48 +0000)]
Move get_regs error check from trace_syscall_entering to get_scno

Starting with commit v4.10-25-g8497b62, get_scno() can be called outside
trace_syscall_entering(), so move the get_regs_error check from
trace_syscall_entering() to get_scno().

* syscall.c (trace_syscall_entering): Move get_regs_error check ...
(get_scno): ... here.

9 years agoalpha, ia64, sh, sparc, sparc64: fix pipe and pipe2 syscalls decoding
Dmitry V. Levin [Mon, 23 Mar 2015 00:04:27 +0000 (00:04 +0000)]
alpha, ia64, sh, sparc, sparc64: fix pipe and pipe2 syscalls decoding

Fix pipe syscall decoding on alpha.
Fix pipe2 syscall decoding on ia64, sh, sparc, and sparc64.

* configure.ac (AC_CHECK_FUNCS): Add pipe2.
* defs.h [ALPHA || IA64 || SH || SPARC || SPARC64] (HAVE_GETRVAL2):
Define.
* net.c (do_pipe): Check HAVE_GETRVAL2 instead of architecture macros.
Do not use getrval2 for pipe2 decoding.
Print address if umove call fails.
* syscall.c (getrval2): Check HAVE_GETRVAL2 instead of architecture
macros.  Implement for [ALPHA].
* tests/pipe.c: New file.
* tests/pipe.expected: New file.
* tests/pipe.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add pipe.
(TESTS): Add pipe.test.
(EXTRA_DIST): Add pipe.expected.
* tests/.gitignore: Add pipe.

9 years agodecode_socket_subcall: fetch all arguments with a single umoven call
Dmitry V. Levin [Sun, 22 Mar 2015 15:52:40 +0000 (15:52 +0000)]
decode_socket_subcall: fetch all arguments with a single umoven call

* syscall.c (decode_socket_subcall): Replace umoven fetch loop
with a single umoven call.

9 years agoNew test: test/many_looping_threads.c
Denys Vlasenko [Sat, 21 Mar 2015 19:59:39 +0000 (20:59 +0100)]
New test: test/many_looping_threads.c

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agotest/.gitignore: add missing test targets
Denys Vlasenko [Sat, 21 Mar 2015 19:19:02 +0000 (20:19 +0100)]
test/.gitignore: add missing test targets

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoTrivial optimization in sys_sigreturn()
Denys Vlasenko [Sat, 21 Mar 2015 19:11:53 +0000 (20:11 +0100)]
Trivial optimization in sys_sigreturn()

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoChange last parameter of umoven() from char* to void*
Denys Vlasenko [Sat, 21 Mar 2015 18:50:53 +0000 (19:50 +0100)]
Change last parameter of umoven() from char* to void*

Saves tons of casts.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoRemove unused struct tcb::inst field
Denys Vlasenko [Sat, 21 Mar 2015 18:30:53 +0000 (19:30 +0100)]
Remove unused struct tcb::inst field

It is unused since we dropped support for kernels without PTRACE_SETOPTIONS.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agotest/Makefile: add missing test targets
Denys Vlasenko [Sat, 21 Mar 2015 17:54:16 +0000 (18:54 +0100)]
test/Makefile: add missing test targets

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoMove the comment about termination logic where it belongs
Denys Vlasenko [Sat, 21 Mar 2015 17:40:53 +0000 (18:40 +0100)]
Move the comment about termination logic where it belongs

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agostartup_tcb() never fails, remove code which checks for failures
Denys Vlasenko [Sat, 21 Mar 2015 17:13:45 +0000 (18:13 +0100)]
startup_tcb() never fails, remove code which checks for failures

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoShow the syscall name in "resuming interrupted call" message
Denys Vlasenko [Sat, 21 Mar 2015 16:51:52 +0000 (17:51 +0100)]
Show the syscall name in "resuming interrupted call" message

When signal is received, or if we have attached to a process,
current syscall (if process is in one) gets restarted.

Some syscalls are restarted via "restart_syscall()" mechanism.
On such sycalls, we don't show _which_ syscall gets restarted.

IOW: users want to see "resuming interrupted nanosleep"
instead of "resuming interrupted call" when they attach to "sleep 999".

Kernel does expose this information. The only thing we need is
to fetch syscall# on attach, and save it.

This patch does this. It adds tcp->s_prev_ent, which is
a pointer to struct_sysent of the previous syscall of this tracee.
It can be NULL.

sys_restart_syscall() is made to use it when the message is generated.

To similarly handle restart_syscall() *after signals*, not just
on attach, on each syscall exit patch saves exited syscall's data
in the same member (tcp->s_prev_ent).

Example:

    $ sleep 3 & strace -p $!
    Process 8728 attached
    restart_syscall(<... resuming interrupted nanosleep ...>) = 0
    _exit(0)                                = ?
    +++ exited with 0 +++

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agotests: add a test for mmap/mprotect/munmap decoding
Dmitry V. Levin [Thu, 19 Mar 2015 22:03:32 +0000 (22:03 +0000)]
tests: add a test for mmap/mprotect/munmap decoding

* tests/mmap.c: New file.
* tests/mmap64.c: New file.
* tests/mmap.test: New test.
* tests/mmap64.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add mmap and mmap64.
(mmap64_CFLAGS): Define.
(TESTS): Add mmap.test and mmap64.test.
* tests/.gitignore: Add mmap and mmap64.

9 years agosparc, sparc64: fix decoding of mmap2
Dmitry V. Levin [Thu, 19 Mar 2015 22:58:22 +0000 (22:58 +0000)]
sparc, sparc64: fix decoding of mmap2

* linux/sparc/syscallent.h (mmap2): Decode with sys_mmap_4koff,
not sys_mmap.
* linux/sparc64/syscallent2.h (mmap2): Decode with sys_mmap_pgoff,
not sys_mmap.

9 years agotests: add a test for SECCOMP_MODE_FILTER decoding
Dmitry V. Levin [Thu, 19 Mar 2015 00:40:49 +0000 (00:40 +0000)]
tests: add a test for SECCOMP_MODE_FILTER decoding

* tests/seccomp.c: New file.
* tests/seccomp.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add seccomp.
(TESTS): Add seccomp.test.
* tests/.gitignore: Add seccomp.

9 years agotests: factor out common awk code
Dmitry V. Levin [Wed, 18 Mar 2015 19:14:02 +0000 (19:14 +0000)]
tests: factor out common awk code

Factor out awk code used in several tests to match.awk.

* tests/match.awk: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/caps.awk: Use it.
* tests/getdents.awk: Likewise.
* tests/getrandom.awk: Likewise.
* tests/select.awk: Likewise.
* tests/sigaction.awk: Likewise.
* tests/init.sh (match_awk): Use gawk not awk.  Define AWKPATH.
* tests/getdents.test: Likewise.

9 years agotests: skip netlink based tests when resources are not available
Dmitry V. Levin [Wed, 18 Mar 2015 20:18:27 +0000 (20:18 +0000)]
tests: skip netlink based tests when resources are not available

* tests/netlink_inet_diag.c (main): Return 77 if socket, bind,
or listen syscall fail.
* tests/netlink_unix_diag.c (main): Likewise.

9 years agoaarch64, arm: decode extra padded compat struct statfs64
Dmitry V. Levin [Wed, 18 Mar 2015 16:32:04 +0000 (16:32 +0000)]
aarch64, arm: decode extra padded compat struct statfs64

According to arch/arm/kernel/sys_oabi-compat.c,
struct statfs64 has extra padding with EABI.

* statfs.c [AARCH64 || defined ARM] (COMPAT_STATFS64_PADDED_SIZE):
Define.
(do_statfs64_fstatfs64): New function, factored out from sys_statfs64.
[COMPAT_STATFS64_PADDED_SIZE]: Check it in addition to
sizeof(struct compat_statfs64).
(sys_statfs64, sys_fstatfs64): Use do_statfs64_fstatfs64.

Reported-and-tested-by: Elliott Hughes <enh@google.com>
9 years agotests: factor out common shell code to functions
Dmitry V. Levin [Tue, 17 Mar 2015 17:07:57 +0000 (17:07 +0000)]
tests: factor out common shell code to functions

Factor out shell code used in several tests to common functions.

* tests/fanotify_mark.expected: New file.
* tests/ioctl.expected: New file.
* tests/net-fd.expected: New file.
* tests/net.expected: New file.
* tests/statfs.expected: New file.
* tests/sun_path.expected: New file.
* tests/uio.expected: New file.
* tests/ipc.sh: New file.
* tests/Makefile.am (EXTRA_DIST): Add them.
* tests/init.sh (dump_log_and_fail_with, run_prog,
run_prog_skip_if_failed, run_strace, run_strace_merge,
match_awk, match_diff, match_grep): New functions.
* tests/*.test: Use them.

9 years agoShow f_flags field in printstatfs
Elliott Hughes [Tue, 17 Mar 2015 23:00:31 +0000 (16:00 -0700)]
Show f_flags field in printstatfs

printstatfs64 was right, but printstatfs was missing f_flags.
Noticed on aarch64.

* statfs.c (printstatfs) [_STATFS_F_FLAGS]: Print statfs.f_flags.

Signed-off-by: Elliott Hughes <enh@google.com>
9 years agotests/uid*: use fchown* instead of chown*
Dmitry V. Levin [Mon, 16 Mar 2015 18:10:21 +0000 (18:10 +0000)]
tests/uid*: use fchown* instead of chown*

Newer architectures have no chown syscall, so use fchown* syscalls
for testing printuid.

* tests/uid.test: Use fchown instead of chown.
* tests/uid.c: Test __NR_fchown instead of __NR_chown.
(main): Use __NR_fchown instead of __NR_chown.
* tests/uid32.c: Test __NR_fchown32 instead of __NR_chown32.
(main): Use __NR_fchown32 instead of __NR_chown32.
* tests/uid16.c: Test __NR_fchown and __NR_fchown32 instead
of __NR_chown and __NR_chown32.
(main): Use __NR_fchown instead of __NR_chown.
* tests/uid.awk: Update regexp.

9 years agostat64-v.test: add newfstatat syscall support
Dmitry V. Levin [Mon, 16 Mar 2015 17:18:40 +0000 (17:18 +0000)]
stat64-v.test: add newfstatat syscall support

Newer architectures have no stat syscall, so stat() is implemented there
using newfstatat syscall.

* tests/stat.c (STAT_FNAME): Rename to STAT_PREFIX.  Update callers.
[_FILE_OFFSET_BITS == 64] (STAT_PREFIX): Add newfstatat support.
(main) [!NR_stat]: Add newfstatat support.

Reported-by: Andreas Schwab <schwab@suse.de>
9 years agoaarch64: properly decode generic syscalls
Andreas Schwab [Thu, 12 Mar 2015 15:17:45 +0000 (16:17 +0100)]
aarch64: properly decode generic syscalls

* linux/aarch64/syscallent1.h: Don't override entries 277 to 1023.

9 years agotests: verify that all patterns match
Andreas Schwab [Wed, 11 Mar 2015 16:49:06 +0000 (17:49 +0100)]
tests: verify that all patterns match

* tests/ipc_msg.test: Count matches to verify that all patterns match.
* tests/ipc_sem.test: Likewise.
* tests/ipc_shm.test: Likewise.
* tests/stat32-v.test: Likewise.
* tests/stat64-v.test: Likewise.

9 years agoFix stat64 st_[acm]time decoding for personalities with 32-bit time_t
Dmitry V. Levin [Thu, 12 Mar 2015 16:59:01 +0000 (16:59 +0000)]
Fix stat64 st_[acm]time decoding for personalities with 32-bit time_t

STRUCT_STAT.st_[acm]time are declared as unsigned int for some
personalities, while time_t is signed.

* printstat.h (DO_PRINTSTAT): If st_[acm]time have the same size as int,
explicitly cast them to int.
* tests/stat64-v.test: Test that negative time_t is decoded properly.

Reported-by: Andreas Schwab <schwab@suse.de>
9 years agosemctl: fix indirect syscall decoding
Dmitry V. Levin [Wed, 11 Mar 2015 14:57:57 +0000 (14:57 +0000)]
semctl: fix indirect syscall decoding

On architectures where the semctl call is implemented by the ipc syscall
the 4th argument is passed by reference.

* ipc.c (sys_semctl): Handle the indirect ipc subcall case.
* tests/ipc_sem.c (main): Optionally match indirection
in the 4th argument of semctl calls.

Reported-by: Andreas Schwab <schwab@suse.de>
9 years agotests/ipc_*: match IPC_64 flag
Andreas Schwab [Wed, 11 Mar 2015 16:47:56 +0000 (17:47 +0100)]
tests/ipc_*: match IPC_64 flag

* tests/ipc_msg.c (main): Optionally match "IPC_64|" in the third
argument of the ipc call.
* tests/ipc_sem.c (main): Likewise.
* tests/ipc_shm.c (main): Likewise.

9 years agoFix crash in ipc_sem test
Andreas Schwab [Wed, 11 Mar 2015 11:33:30 +0000 (12:33 +0100)]
Fix crash in ipc_sem test

Properly use union semun as argument of semctl.

* tests/ipc_sem.c (main): Properly use union semun as argument of
semctl.  Don't handle EFAULT specially.
* tests/ipc_sem.test: Revert last change.

9 years agom68k: fix sigreturn decoding
Andreas Schwab [Wed, 11 Mar 2015 14:08:42 +0000 (15:08 +0100)]
m68k: fix sigreturn decoding

* sigreturn.c (sys_sigreturn) [M68K]: Fetch the words of the
signal mask from the proper place.

9 years agoaarch64: fix ioctl decoding
Andreas Schwab [Thu, 12 Mar 2015 17:07:00 +0000 (18:07 +0100)]
aarch64: fix ioctl decoding

* linux/aarch64/ioctls_inc0.h: Rename from ioctls_inc1.h.
* linux/aarch64/ioctls_inc1.h: Rename from ioctls_inc0.h.
* linux/aarch64/ioctls_arch0.h: Rename from ioctls_arch1.h.
* linux/aarch64/ioctls_arch1.h: Rename from ioctls_arch0.h.

9 years agotests/select.test: handle architectures using pselect6 syscall
Andreas Schwab [Thu, 12 Mar 2015 15:47:38 +0000 (16:47 +0100)]
tests/select.test: handle architectures using pselect6 syscall

* tests/select.awk (BEGIN): Update regexps to match both select
and pselect6 syscalls.
* tests/select.test: Probe for both select and pselect6 syscall.

9 years agoDistribute linux/aarch64/arch_regs.h
Andreas Schwab [Thu, 12 Mar 2015 10:54:08 +0000 (11:54 +0100)]
Distribute linux/aarch64/arch_regs.h

* Makefile.am (EXTRA_DIST): Add linux/aarch64/arch_regs.h.

9 years agoFix decoding of mmap2 for arm
Andreas Schwab [Mon, 9 Mar 2015 15:55:06 +0000 (16:55 +0100)]
Fix decoding of mmap2 for arm

* syscallent.h (mmap2): Decode with sys_mmap_4koff, not
sys_mmap_pgoff.

9 years agom68k: define HAVE_SA_RESTORER
Andreas Schwab [Wed, 11 Mar 2015 13:15:34 +0000 (14:15 +0100)]
m68k: define HAVE_SA_RESTORER

On m68k the kernel sigaction structure has the sa_restorer member for
historical reasons.

* signal.c (HAVE_SA_RESTORER): Define for M68K.

9 years agoaarch64: fix rt_sigreturn decoding
Dmitry V. Levin [Wed, 11 Mar 2015 14:32:25 +0000 (14:32 +0000)]
aarch64: fix rt_sigreturn decoding

* sigreturn.c (sys_sigreturn) [AARCH64]: Fix personality check.

9 years agomaint: post-release administrivia
Dmitry V. Levin [Mon, 9 Mar 2015 22:05:40 +0000 (22:05 +0000)]
maint: post-release administrivia

* NEWS: Add header line for next release.

9 years agoPrepare for 4.10 release v4.10
Dmitry V. Levin [Fri, 6 Mar 2015 13:14:15 +0000 (13:14 +0000)]
Prepare for 4.10 release

* NEWS: Update for 4.10 release.
* debian/changelog: 4.10-1.
* strace.spec: 4.10-1.

9 years agoMove sigreturn/rt_sigreturn parser to a separate file
Dmitry V. Levin [Fri, 6 Mar 2015 01:47:18 +0000 (01:47 +0000)]
Move sigreturn/rt_sigreturn parser to a separate file

* sigreturn.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (sprintsigmask_n): New prototype.
(tprintsigmask_addr): New macro.
* signal.c (sprintsigmask_n): Make global.
(tprintsigmask_addr): Remove.
(sys_sigreturn): Move to sigreturn.c.

9 years agoia64: use PTRACE_GETREGS to fetch registers
Dmitry V. Levin [Thu, 5 Mar 2015 23:30:02 +0000 (23:30 +0000)]
ia64: use PTRACE_GETREGS to fetch registers

* linux/ia64/arch_regs.h: Stop including <asm/rse.h>.
(ia64_frame_ptr): New declaration.
* signal.c (sys_sigreturn) [IA64]: Use ia64_frame_ptr.
* syscall.c [IA64]: Include <asm/rse.h>.
[IA64] (ia64_regs, ia64_frame_ptr): New variable.
[IA64] (ARCH_REGS_FOR_GETREGS): New macro.
[IA64] (ia64_ia32mode): Convert to macro.
[IA64] (ia64_r8, ia64_r10): Remove.
(getrval2, print_pc, get_scno, get_syscall_args, get_error) [IA64]:
Use ia64_regs.
(get_syscall_result) [IA64]: Remove.

9 years agos390, s390x: use PTRACE_GETREGSET to fetch registers
Dmitry V. Levin [Thu, 5 Mar 2015 22:10:15 +0000 (22:10 +0000)]
s390, s390x: use PTRACE_GETREGSET to fetch registers

* linux/s390/arch_regs.h: New file.
* linux/s390x/arch_regs.h: New file.
* Makefile.am (EXTRA_DIST): Add them.
* signal.c (sys_sigreturn) [S390 || S390X]: Use s390_frame_ptr.
* syscall.c [S390 || S390X] (s390_regset, s390_frame_ptr): New variable.
[S390 || S390X] (ARCH_REGS_FOR_GETREGSET): New macro.
(print_pc) [S390 || S390X]: Use s390_regset.
(get_scno) [S390 || S390X]: Likewise.
(get_syscall_args) [S390 || S390X]: Likewise.
(get_error) [S390 || S390X]: Likewise.
(get_syscall_result) [S390 || S390X]: Remove.

9 years agoqemu_multiarch_testing: update
Dmitry V. Levin [Thu, 5 Mar 2015 19:36:52 +0000 (19:36 +0000)]
qemu_multiarch_testing: update

* qemu_multiarch_testing/README: Update statistics.

9 years agotests: robustify unix-yy.test
Dmitry V. Levin [Thu, 5 Mar 2015 17:30:23 +0000 (17:30 +0000)]
tests: robustify unix-yy.test

Implement additional synchronization between parent and child processes
to guarantee that the child starts closing connected socket only after
exiting of the parent's accept() syscall.
This guarantee seems to be necessary to reliably receive UNIX_DIAG_PEER
messages from NETLINK_SOCK_DIAG interface.

* tests/net-accept-connect.c: Implement additional synchronization
between parent and child processes.
* tests/unix-yy-connect.awk: Update.

9 years agoUse SIGRTMIN from kernel headers
Dmitry V. Levin [Thu, 5 Mar 2015 05:03:41 +0000 (05:03 +0000)]
Use SIGRTMIN from kernel headers

* configure.ac (ASM_SIGRTMIN): Define to SIGRTMIN from <asm/signal.h>.
* signal.c: Use ASM_SIGRTMIN instead of constants provided by libc.
* tests/sigreturn.c: Use ASM_SIGRTMIN instead of hardcoded value.
Use lower RT_* numbers to support pre-3.18 hppa kernels.
* tests/sigreturn.test: Update regexp.

9 years agoppc64: fix compilation warning
Dmitry V. Levin [Thu, 5 Mar 2015 04:29:37 +0000 (04:29 +0000)]
ppc64: fix compilation warning

Fix compilation warning introduced by commit
577be2593d4895ef941e1c4e5e1608f7dd13610d

* signal.c (sys_sigreturn) [POWERPC64]: Fix initialization of signal
mask on 32bit personality.

9 years agoaarch64: fix compilation warnings
Dmitry V. Levin [Thu, 5 Mar 2015 04:10:52 +0000 (04:10 +0000)]
aarch64: fix compilation warnings

Fix compilation warnings introduced by commit
5b9b7e1d347eb4556084cdccad75e8247c535ed5:

signal.c:702:45: warning: signed and unsigned type in conditional expression [-Wsign-compare]
syscall.c:746:34: warning: initialization from incompatible pointer type [enabled by default]

* syscall.c [AARCH64] (aarch64_sp_ptr): Add explicit cast.
[AARCH64] (arm_sp_ptr): Change pointer type to unsigned.
* linux/aarch64/arch_regs.h (arm_sp_ptr): Update.

Reported-by: Mike Frysinger <vapier@gentoo.org>
9 years agoi386: simplify sigreturn decoding
Dmitry V. Levin [Thu, 5 Mar 2015 01:14:33 +0000 (01:14 +0000)]
i386: simplify sigreturn decoding

* signal.c (sys_sigreturn) [X86_64 || X32 || I386]: Do not define
i386_sigcontext_struct and i386_fpstate structures.

9 years agotests: add a test for sigreturn/rt_sigreturn decoding
Dmitry V. Levin [Wed, 4 Mar 2015 12:31:18 +0000 (12:31 +0000)]
tests: add a test for sigreturn/rt_sigreturn decoding

Convert test/sigreturn.c into a regular test.

* test/Makefile (PROGS): Remove sigreturn.
* test/.gitignore: Likewise.
* test/sigreturn.c: Rewrite to ...
* tests/sigreturn.c: ... new file.
* tests/sigreturn.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add sigreturn.
(TESTS): Add sigreturn.test.
* tests/.gitignore: Add sigreturn.

9 years agosigreturn: print signal mask as a syscall argument
Dmitry V. Levin [Wed, 4 Mar 2015 23:55:25 +0000 (23:55 +0000)]
sigreturn: print signal mask as a syscall argument

Although sigreturn takes signal mask via frame pointer,
it's more convenient to display signal mask as a syscall argument
rather than an outstanding object of unknown nature:

Before this change:
    sigreturn() (mask [USR2 CHLD RT_2 RT_3 RT_4 RT_31 RT_32]) = 0

After this change:
    sigreturn({mask=[USR2 CHLD RT_2 RT_3 RT_4 RT_31 RT_32]}) = 0

* signal.c (sys_sigreturn): Display signal mask as a syscall argument.

9 years agoaarch64: implement rt_sigreturn decoding
Dmitry V. Levin [Wed, 4 Mar 2015 23:05:53 +0000 (23:05 +0000)]
aarch64: implement rt_sigreturn decoding

* linux/64/syscallent.h (139): Use sys_sigreturn for rt_sigreturn
decoding.
* syscall.c [ARM] (arm_regs): Make static.
[ARM] (arm_sp_ptr): New variable.
[AARCH64] (aarch64_sp_ptr, arm_sp_ptr): New variables.
* linux/aarch64/arch_regs.h: New file.
* linux/arm/arch_regs.h (arm_regs): Remove.
(arm_sp_ptr): New declaration.
* signal.c (sys_sigreturn) [ARM]: Use arm_sp_ptr.
[AARCH64]: Print signal mask.

9 years agoarm: simplify sigreturn decoding
Dmitry V. Levin [Wed, 4 Mar 2015 22:27:35 +0000 (22:27 +0000)]
arm: simplify sigreturn decoding

* signal.c (sys_sigreturn) [ARM]: Do not define sigcontext and ucontext
structures, fetch signal mask only, use print_sigset_addr_len.

9 years agos390: fix sigreturn decoding
Dmitry V. Levin [Wed, 4 Mar 2015 21:40:00 +0000 (21:40 +0000)]
s390: fix sigreturn decoding

* signal.c (sys_sigreturn) [S390]: Fix signal mask decoding.

9 years agomips o32: fix sigreturn decoding
Dmitry V. Levin [Wed, 4 Mar 2015 20:04:02 +0000 (20:04 +0000)]
mips o32: fix sigreturn decoding

* signal.c (sys_sigreturn) [LINUX_MIPSO32]: Fix the address of signal mask.
[MIPS] Use print_sigset_addr_len to print signal mask.

9 years agox86_64, x32: implement rt_sigreturn decoding
Dmitry V. Levin [Wed, 4 Mar 2015 12:19:55 +0000 (12:19 +0000)]
x86_64, x32: implement rt_sigreturn decoding

* syscall.c [X86_64 || X32] (x86_64_rsp_ptr): New variable.
* linux/x86_64/arch_regs.h (x86_64_rsp_ptr): New declaration.
* linux/x86_64/syscallent.h (15): Use sys_sigreturn for rt_sigreturn
decoding.
* linux/x32/syscallent.h (513): Likewise.
* signal.c (sys_sigreturn) [X86_64 || X32]: Print signal mask
for non-i386 personalities.

9 years agosparc, sparc64: fix sigreturn decoding
Dmitry V. Levin [Wed, 4 Mar 2015 17:52:42 +0000 (17:52 +0000)]
sparc, sparc64: fix sigreturn decoding

* linux/sparc/arch_regs.h (U_REG_FP): New macro.
* signal.c (sys_sigreturn) [SPARC || SPARC64]: Fix decoding
of upper 32 bits of the sigmask.

9 years agoppc, ppc64: fix sigreturn decoding
Dmitry V. Levin [Wed, 4 Mar 2015 16:01:47 +0000 (16:01 +0000)]
ppc, ppc64: fix sigreturn decoding

* signal.c (sys_sigreturn) [POWERPC]: Fix decoding of upper 32 bits
of the sigmask.

9 years agosigreturn: issue a less innocuous warning
Dmitry V. Levin [Wed, 4 Mar 2015 13:12:06 +0000 (13:12 +0000)]
sigreturn: issue a less innocuous warning

* signal.c (sys_sigreturn): Issue a less innocuous warning on
architectures for which signal mask decoding is not implemented yet.

9 years agobootstrap: do not link Makefile* files
Dmitry V. Levin [Wed, 4 Mar 2015 14:50:19 +0000 (14:50 +0000)]
bootstrap: do not link Makefile* files

* bootstrap: Do not symlink any Makefile* files, not just Makefile.am
and Makefile.in.

Reported-by: Christopher Covington <cov@codeaurora.org>
9 years agoia64: fix sigreturn decoding
Dmitry V. Levin [Wed, 4 Mar 2015 12:11:31 +0000 (12:11 +0000)]
ia64: fix sigreturn decoding

* signal.c (sys_sigreturn) [IA64]: Fix the address of signal mask.
Use print_sigset_addr_len to print signal mask.

9 years agoia64: use generic signalent
Dmitry V. Levin [Wed, 4 Mar 2015 12:04:57 +0000 (12:04 +0000)]
ia64: use generic signalent

This complements commit v4.9-321-gfcf7f8d.

* linux/ia64/signalent.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.

9 years agoDocument that -k is available only with libunwind
Giedrius Statkevičius [Tue, 3 Mar 2015 19:24:34 +0000 (21:24 +0200)]
Document that -k is available only with libunwind

Without this users might get confused why `man strace` describes
an option that doesn't work.

* strace.1: Note that -k is available only if strace is built
with libunwind.

9 years agodebian: update control file
Dmitry V. Levin [Tue, 3 Mar 2015 18:31:06 +0000 (18:31 +0000)]
debian: update control file

* debian/control (strace, strace-udeb): Add mips64 and mips64el
to architecture list.
Patch by James Cowgill <james410@cowgill.org.uk>

This fixes Debian bug #773375.

9 years agodebian: sync with 4.9-2 package
Dmitry V. Levin [Wed, 20 Aug 2014 17:00:09 +0000 (17:00 +0000)]
debian: sync with 4.9-2 package

* debian/changelog: Sync with 4.9-2.
* debian/control: Likewise.

9 years agoAdd arch-specific PTRACE_* constants
Dmitry V. Levin [Tue, 3 Mar 2015 22:53:25 +0000 (22:53 +0000)]
Add arch-specific PTRACE_* constants

* xlat/ptrace_cmds.in: Add arch-specific ptrace commands.
* xlat/ptrace_events.in: Add PTRACE_EVENT_MIGRATE for tile.
* xlat/ptrace_setoptions_flags.in: Add PTRACE_O_TRACEMIGRATE for tile.

This fixes Debian bug #734554.

9 years agoClarify bootstrap-vs-autoreconf usage
Mike Frysinger [Tue, 3 Mar 2015 01:42:04 +0000 (20:42 -0500)]
Clarify bootstrap-vs-autoreconf usage

* README-hacking: Tell people to run ./bootstrap.

9 years agomips n32: fix preadv/pwritev offset decoding
Dmitry V. Levin [Tue, 3 Mar 2015 01:36:29 +0000 (01:36 +0000)]
mips n32: fix preadv/pwritev offset decoding

In mips n32 abi, like in most of 32-bit architectures, offset
is passed to preadv/pwritev syscalls using two syscall arguments.

* io.c (print_llu_from_low_high_val) [LINUX_MIPSN32]: Remove.

9 years agotests: skip ipc_sem.test on broken kernels
Mike Frysinger [Tue, 3 Mar 2015 01:07:14 +0000 (20:07 -0500)]
tests: skip ipc_sem.test on broken kernels

Rather than trigger an ERROR which fails `make check`, go with SKIP
instead.  We don't want the testsuite failing due to kernel bugs.

* tests/ipc_sem.c (main): Change 99 to 77.

9 years agotests: skip pc.test on s390
Mike Frysinger [Tue, 3 Mar 2015 01:04:34 +0000 (20:04 -0500)]
tests: skip pc.test on s390

The s390 hardware can't support an exact si_addr, and the current kernels
don't handle text addresses correctly at all.  Until that improves, skip
the test on s390.

* tests/pc.c (main): Return 77 on s390 systems.

9 years agotests: note the kernel configs for -yy options
Mike Frysinger [Tue, 3 Mar 2015 00:51:30 +0000 (19:51 -0500)]
tests: note the kernel configs for -yy options

* tests/net-yy.test: Note CONFIG_INET_TCP_DIAG.
* tests/unix-yy.test: Note CONFIG_UNIX_DIAG.

9 years agoalpha: fix -yy decoding
Dmitry V. Levin [Mon, 2 Mar 2015 23:39:41 +0000 (23:39 +0000)]
alpha: fix -yy decoding

* socketutils.c (receive_responses): Align buffer on a sizeof(long) boundary.

Reported-and-tested-by: Mike Frysinger <vapier@gentoo.org>
9 years agoaarch64, x32: fix decoding of compat personality statfs64/fstatfs64
Dmitry V. Levin [Mon, 2 Mar 2015 21:34:02 +0000 (21:34 +0000)]
aarch64, x32: fix decoding of compat personality statfs64/fstatfs64

* statfs.c (struct compat_statfs64) [AARCH64 || X32]: Apply the same
attributes as on X86_64.

9 years agomips: fix compilation warning
Dmitry V. Levin [Mon, 2 Mar 2015 15:06:51 +0000 (15:06 +0000)]
mips: fix compilation warning

* syscall.c (get_scno) [MIPS]: Fix harmless compilation warning
about comparison between signed and unsigned integer expressions.

9 years agox32: fix compilation warnings
Dmitry V. Levin [Mon, 2 Mar 2015 14:34:25 +0000 (14:34 +0000)]
x32: fix compilation warnings

* sysinfo.c (sys_sysinfo): Use ll length format modifier
instead of l and cast kernel ulong types to unsigned long long.

9 years agoaarch64: add -i option support
Dmitry V. Levin [Mon, 2 Mar 2015 03:38:27 +0000 (03:38 +0000)]
aarch64: add -i option support

* syscall.c (print_pc): Add aarch64 support.

9 years agoioctl: use x32 specific ioctl entries on x32 personality
Dmitry V. Levin [Mon, 2 Mar 2015 02:38:50 +0000 (02:38 +0000)]
ioctl: use x32 specific ioctl entries on x32 personality

As ioctls_inc.h generated natively on x32 differs both from 32/ioctls_inc.h
(by 45 entries) and from linux/64/ioctls_inc.h (by 322 entries), use x32
specific ioctl entries on x32 personality.

* linux/x32/ioctls_inc0.h: Generate from linux v3.19 using ioctls_gen.sh.
* linux/x86_64/ioctlent2.h: Remove.
* linux/x86_64/ioctls_arch2.h: New file.
* linux/x86_64/ioctls_inc2.h: New file.
* Makefile.am (EXTRA_DIST): Remove linux/x86_64/ioctlent2.h, add
linux/x86_64/ioctls_arch2.h and linux/x86_64/ioctls_inc2.h.

9 years agotests/uid16: skip if real uid is larger than 16bit
Dmitry V. Levin [Mon, 2 Mar 2015 02:13:03 +0000 (02:13 +0000)]
tests/uid16: skip if real uid is larger than 16bit

* tests/uid16.c (main): Skip if the uid returned by getuid matches
/proc/sys/kernel/overflowuid.

9 years agotests: fix uid tests on big endian architectures
Dmitry V. Levin [Mon, 2 Mar 2015 01:13:47 +0000 (01:13 +0000)]
tests: fix uid tests on big endian architectures

* tests/uid.c (main): Ignore uids returned by getresuid to avoid
16bit vs 32bit issues on big endian architectures.
Change real UID instead of effective UID in setresuid test.
* tests/uid16.c (main): Likewise.
* tests/uid32.c (main): Change real UID instead of effective UID
in setresuid test to match uid.c
* tests/uid.awk: Update setresuid regexp.

Reported-by: Mike Frysinger <vapier@gentoo.org>
9 years agotests/getdents: handle older getdents calls
Mike Frysinger [Sun, 1 Mar 2015 08:11:35 +0000 (03:11 -0500)]
tests/getdents: handle older getdents calls

If the tools we use call older getdents syscalls where d_type isn't
passed back, or the arch is old (like Alpha) and can't pass back in
either version, make sure we don't fail.

* tests/getdents.awk (d_type_dir, d_type_reg): Accept DT_UNKNOWN.

9 years agoFix multiple personalities support in decoding syscall return values
Dmitry V. Levin [Sat, 28 Feb 2015 23:41:11 +0000 (23:41 +0000)]
Fix multiple personalities support in decoding syscall return values

* syscall.c (trace_syscall_exiting): When current personality is 32bit,
print 32bit return code.

9 years agoUpdate generic 64-bit ioctlent from linux v3.19
Dmitry V. Levin [Sat, 28 Feb 2015 18:37:12 +0000 (18:37 +0000)]
Update generic 64-bit ioctlent from linux v3.19

* linux/64/ioctls_inc.h: Update from linux v3.19 using ioctls_gen.sh.

9 years agosparc, sparc64: fix rt_sigaction decoding
Dmitry V. Levin [Sat, 28 Feb 2015 17:17:09 +0000 (17:17 +0000)]
sparc, sparc64: fix rt_sigaction decoding

Fix regression introduced by commit v4.9-9-gc3a5c01.

* signal.c (HAVE_SA_RESTORER): New macro.
[HPPA || IA64]: Do not undefine SA_RESTORER.
(old_sigaction, old_sigaction32, new_sigaction): Use HAVE_SA_RESTORER
instead of SA_RESTORER to check whether to define sa_restorer.
(decode_old_sigaction, decode_new_sigaction): Use HAVE_SA_RESTORER in
addition to SA_RESTORER to check whether to use sa_restorer.

9 years agoFix stack buffer overflow when specified command is too long
Dmitry V. Levin [Sat, 28 Feb 2015 14:50:09 +0000 (14:50 +0000)]
Fix stack buffer overflow when specified command is too long

* strace.c (startup_child): Check that the length of the command strace
is going to execute does not exceed PATH_MAX limit.

Reported-by: Cheolung Lee <chpie@grayhash.com>
9 years agobuild: include ptrace.h after regs.h
Dmitry V. Levin [Sat, 28 Feb 2015 12:20:21 +0000 (12:20 +0000)]
build: include ptrace.h after regs.h

Restore the order of including <sys/reg.h> and <linux/ptrace.h>
headers that was inadvertently changed by commit v4.9-280-g5503dd2.

This should fix build on platforms like m68k where some constants
are defined simultaneously as enums by <sys/reg.h> and as macros
by <asm/ptrace.h>.

* process.c: Include "ptrace.h" after "regs.h".
* signal.c: Likewise.
* syscall.c: Likewise.
* util.c: Likewise.

9 years agox32: fix decoding of timeval, timespec, and timex structures
Dmitry V. Levin [Fri, 27 Feb 2015 21:46:42 +0000 (21:46 +0000)]
x32: fix decoding of timeval, timespec, and timex structures

As time_t is a 64-bit type in x32 personality, it is not correct to
treat it as a long int type.

* time.c (current_time_t_is_compat): New macro.
(sprinttv, sprint_timespec, printitv_bitness, tprint_timex): Use it.
(tprint_timeval, do_sprinttv, sprint_timespec): Use j and uintmax_t
when printing tv_sec/tv_usec.
(tprint_timex): Use j and intmax_t/uintmax_t when printing struct timex
members of type kernel_long_t.

9 years agotests/ipc_sem: detect broken kernels
Mike Frysinger [Fri, 27 Feb 2015 06:39:25 +0000 (01:39 -0500)]
tests/ipc_sem: detect broken kernels

When running 32bit ipc tests on ppc/sparc with a 64bit kernel, the ipc
logic wrongly returns errors.  Detect that and throw an error.

* tests/ipc_sem.c: Return 99 when errno is EFAULT.
* tests/ipc_sem.test: Save output to $OUT and show it when failing.
Handle exit status 99 to throw an ERROR.

9 years agobuild: do not link strace with -ldl
Dmitry V. Levin [Fri, 27 Feb 2015 05:01:25 +0000 (05:01 +0000)]
build: do not link strace with -ldl

* configure.ac: Fix dladdr check.

9 years agoHandle broken PTRACE_EVENT_STOP values
Mike Frysinger [Fri, 27 Feb 2015 04:31:37 +0000 (23:31 -0500)]
Handle broken PTRACE_EVENT_STOP values

For a few linux releases (3.1 through 3.3), this define in the exported
headers were broken.  Redefine if that's the case.

* ptrace.h [PTRACE_EVENT_STOP]: Redefine if PTRACE_EVENT_STOP is 7.

9 years agobootstrap: always set up test dirs
Mike Frysinger [Fri, 27 Feb 2015 03:22:40 +0000 (22:22 -0500)]
bootstrap: always set up test dirs

When files get updated, the bootstrap script should make sure the
parallel dirs are kept in sync.

* bootstrap: Always generate the test$m.  Clean up symlinks first.
Don't link in Makefile.in files.

9 years agoFix cross-compiling of ioctlsort
Mike Frysinger [Fri, 27 Feb 2015 03:22:36 +0000 (22:22 -0500)]
Fix cross-compiling of ioctlsort

Use the AX_PROG_CC_FOR_BUILD helper to set up build settings when cross
compiling.  This way ioctlsort uses the build tools all the time.

* configure.ac: Call AX_PROG_CC_FOR_BUILD.
* Makefile.am (ioctlsort_CC): Set to CC_FOR_BUILD.
(ioctlsort_CPPFLAGS): Change CPPFLAGS to CPPFLAGS_FOR_BUILD.
(ioctlsort_CFLAGS): Change CFLAGS to CFLAGS_FOR_BUILD.
(ioctlsort_LDFLAGS): Change LDFLAGS to LDFLAGS_FOR_BUILD.
(ioctlsort_LD): Delete.
(ioctlsort%): Change to ioctlsort%$(BUILD_EXEEXT).  Use ioctlsort_CFLAGS.
* m4/ax_prog_cc_for_build.m4: Import from the autoconf-archive package.

9 years agotests: robustify pc.test
Dmitry V. Levin [Fri, 27 Feb 2015 04:09:56 +0000 (04:09 +0000)]
tests: robustify pc.test

* configure.ac: Check for dladdr in -ldl.
* tests/Makefile.am (pc_LDADD): Adde $(dl_LIBS).
* tests/pc.c: Include "config.h" and <dlfcn.h>.
(main): Use dladdr to find the address to unmap.

9 years agotests: drop support for alternative names of select syscall
Dmitry V. Levin [Fri, 27 Feb 2015 01:39:26 +0000 (01:39 +0000)]
tests: drop support for alternative names of select syscall

This mostly reverts commit 4a00fc4867bde7a4c333f238851e5cb03f02c824.

* tests/select.awk: Drop _newselect support.
* tests/select.test: Skip if select syscall is not supported.

9 years agoRename _newselect to select
Dmitry V. Levin [Fri, 27 Feb 2015 01:25:24 +0000 (01:25 +0000)]
Rename _newselect to select

As an exception to the general rules that syscall names should match
__NR_* constants defined in kernel headers, show select as "select"
and old select as "oldselect".

* linux/arm/syscallent.h (82): Change name to oldselect.
* linux/hppa/syscallent.h (142): Change name to select.
* linux/mips/syscallent-n32.h (6022): Likewise.
* linux/mips/syscallent-n64.h (5022): Likewise.
* linux/mips/syscallent-o32.h (4142): Likewise.
* linux/sparc/syscallent.h (230): Likewise.

9 years agosparc: sync syscall entries with kernel headers
Dmitry V. Levin [Fri, 27 Feb 2015 00:17:06 +0000 (00:17 +0000)]
sparc: sync syscall entries with kernel headers

* linux/sparc/syscallent.h: Fix syscall entries for vmsplice,
inotify_init, inotify_add_watch, inotify_rm_watch, inotify_rm_watch,
ioprio_set, ioprio_get, splice, sync_file_range, sched_getaffinity, and
sched_setaffinity.
(67, 68, 202, 230): Change syscall names to match __NR_* constants
defined in arch/sparc/include/uapi/asm/unistd.h.

9 years agos390, s390x: sync syscall entry names with kernel headers
Dmitry V. Levin [Thu, 26 Feb 2015 23:36:26 +0000 (23:36 +0000)]
s390, s390x: sync syscall entry names with kernel headers

* linux/s390/syscallent.h (1, 180, 181): Change syscall names to match
__NR_* constants defined in arch/s390/include/uapi/asm/unistd.h.
* linux/s390x/syscallent.h: Likewise.

9 years agoxlat: avoid fork bombing the build system
Mike Frysinger [Thu, 26 Feb 2015 23:06:16 +0000 (18:06 -0500)]
xlat: avoid fork bombing the build system

When there were fewer xlat headers, this didn't matter as much.
But now with >200, trying to run them all in parallel can easily
fork bomb smaller systems.

* xlat/gen.sh (main): Do not more jobs than # of cpus.

9 years agoarm: sync syscall entry names with kernel
Dmitry V. Levin [Thu, 26 Feb 2015 23:04:04 +0000 (23:04 +0000)]
arm: sync syscall entry names with kernel

* linux/arm/syscallent.h (82, 90, 180, 181, 327):
Change syscall names to match __NR_* constants defined
in arch/arm/include/uapi/asm/unistd.h.