]> granicus.if.org Git - strace/log
strace
10 years agoCleanup socketpair decoding
Dmitry V. Levin [Tue, 11 Mar 2014 22:50:39 +0000 (22:50 +0000)]
Cleanup socketpair decoding

The only supported domain for socketpair syscall is AF_UNIX, so
no decoding related to other domains is required for socketpair.

* net.c (sys_socketpair): Remove support for PF_INET and PF_IPX domains,
print the protocol argument as is.

10 years agoprintsiginfo: add SIGSYS decoding
Dmitry V. Levin [Tue, 11 Mar 2014 22:18:40 +0000 (22:18 +0000)]
printsiginfo: add SIGSYS decoding

* configure.ac (AC_CHECK_MEMBERS): Check for siginfo_t.si_syscall.
* signal.c (SYS_SECCOMP): Define if not yet defined.
(sigsys_codes): new xlat structure.
(printsiginfo): Decode SIGSYS.

10 years agoUpdate siginfo codes
Dmitry V. Levin [Tue, 11 Mar 2014 01:57:02 +0000 (01:57 +0000)]
Update siginfo codes

* signal.c (siginfo_codes): Add SI_DETHREAD.

10 years agoFactor out printing of si_pid and si_uid members of siginfo_t
Dmitry V. Levin [Tue, 11 Mar 2014 00:05:19 +0000 (00:05 +0000)]
Factor out printing of si_pid and si_uid members of siginfo_t

* signal.c (printsigsource): New function.
(printsiginfo): Use it.

10 years agoImprove SI_TIMER decoding
Elliott Hughes [Mon, 10 Mar 2014 19:27:22 +0000 (19:27 +0000)]
Improve SI_TIMER decoding

Decode siginfo_t more clearly for si_code SI_TIMER.
The 'pid' is actually a POSIX timer id, and the 'uid' is actually the
overrun.
Also factor out the si_value dumping so it's the same for every si_code.

Signed-off-by: Elliott Hughes <enh@google.com>
10 years agoaarch64: fix decoding of arm syscall numbers
Elliott Hughes [Mon, 3 Mar 2014 23:45:26 +0000 (23:45 +0000)]
aarch64: fix decoding of arm syscall numbers

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>
10 years agoFix fcntl decoding
Dmitry V. Levin [Mon, 3 Mar 2014 23:09:47 +0000 (23:09 +0000)]
Fix fcntl decoding

Assume that F_SETLK64, F_SETLKW64, and F_GETLK64 are either defined or
not defined altogether.
Do not assume that sizeof(off_t) < sizeof(long long) when F_SETLK64 is
undefined.

This change fixes build with musl libc on x86.

* configure.ac: Define SIZEOF_OFF_T.
* desc.c (USE_PRINTFLOCK64): New macro.
(struct flock64, printflock64): Do not define on X32.
(printflock): Replace X32 specific workaround with SIZEOF_OFF_T check.
Fix printing off_t members of struct flock.
(sys_fcntl): Use USE_PRINTFLOCK64.

10 years agosys_fcntl: remove F_FREESP and F_FREESP64 support
Dmitry V. Levin [Sat, 1 Mar 2014 21:17:17 +0000 (21:17 +0000)]
sys_fcntl: remove F_FREESP and F_FREESP64 support

F_FREESP and F_FREESP64 fcntl commands are not available in Linux
and therefore the code implementing their decoding is useless.
Besides that, F_FREESP64 decoding is too complicated to support.

* desc.c (fcntlcmds): Remove F_FREESP and F_FREESP64.
Remove F_FREESP64 from the check whether to define struct flock64.
(sys_fcntl): Remove F_FREESP and F_FREESP64 support.

10 years agoAdd multi-personality support to struct old_sigaction decoding
Elliott Hughes [Fri, 28 Feb 2014 23:21:35 +0000 (23:21 +0000)]
Add multi-personality support to struct old_sigaction decoding

struct sigaction is another structure that contains members
whose size differs between 32-bit and 64-bit personalities.

* signal.c [HAVE_SIGACTION] (old_sigaction32): New structure.
[HAVE_SIGACTION] (decode_old_sigaction): Decode 32-bit struct
old_sigaction on a 64-bit host.

Signed-off-by: Elliott Hughes <enh@google.com>
10 years agoFix decoding of arm struct stat64 by aarch64 strace.
Elliott Hughes [Fri, 28 Feb 2014 23:16:32 +0000 (23:16 +0000)]
Fix decoding of arm struct stat64 by aarch64 strace.

aarch64's uapi header files have a struct stat but no struct stat64.
To correctly decode a 32-bit process' s struct stat64 we need
HAVE_STAT64, but then the build fails because there is no struct stat64.
Luckily, the aarch64 struct stat is structurally equivalent to the arm
struct stat64, so we can just reuse that.

* file.c [AARCH64] (stat64): Define to stat.

Signed-off-by: Elliott Hughes <enh@google.com>
10 years agoRemove obsolete ioctlsort.c
Dmitry V. Levin [Fri, 28 Feb 2014 22:44:43 +0000 (22:44 +0000)]
Remove obsolete ioctlsort.c

The generic version of ioctlsort.c became obsolete after commit
v4.6-240-g5afdf12 that removed its last non-Linux users.

* ioctlsort.c: Remove.
* Makefile.am (EXTRA_DIST): Remove ioctlsort.c.

Reported-by: Elliott Hughes <enh@google.com>
10 years agoAdd multi-personality support to stack_t decoding
Dmitry V. Levin [Wed, 26 Feb 2014 22:29:27 +0000 (22:29 +0000)]
Add multi-personality support to stack_t decoding

stack_t is one of many structures that contain members
whose size differs between 32-bit and 64-bit personalities.

* signal.c (print_stack_t): Decode 32-bit stack_t on a 64-bit host.

Reported-by: Elliott Hughes <enh@google.com>
10 years agoRewrite signal mask decoding without sigset_t
Dmitry V. Levin [Wed, 26 Feb 2014 16:51:28 +0000 (16:51 +0000)]
Rewrite signal mask decoding without sigset_t

The sigset_t provided by libc is not quite convenient.
In glibc, sigset_t is an array with space for 1024 bits, which is much
more than required: all architectures supported by Linux have only 64
signals except MIPS, which has 128.
In bionic libc, LP32 sigset_t is only 4 bytes long, which is less than
necessary.

With this change, signal mask is decoded without use of intermediate
sigset_t structure, which saves us some cpu cycles in case of glibc with
its inflated sigset_t, and enables build with libcs where sigset_t is
broken.

Old implementation used to check each signal number in the given signal
mask twice using sigismember().
New implementation is based on popcount and next_set_bit() so it's
noticeably faster.

* configure.ac: Check for __builtin_popcount.
* signal.c: Ensure that NSIG >= 32.
(sprintsigmask, sprintsigmask_long, printsigmask): Remove.
(popcount32, sprintsigmask_n): New functions.
(tprintsigmask_addr, sprintsigmask_val, tprintsigmask_val): New macros.
(print_sigset_addr_len, sys_sigsetmask, sys_sigreturn, sys_siggetmask,
sys_sigsuspend, sys_sigprocmask, decode_new_sigaction): Update to use
new signal mask decoding interface.
* tests/sigaction.c (main): Add a test with almost filled signal mask.
* tests/sigaction.awk: Update.

10 years agoFix build with Bionic libc
Dmitry V. Levin [Wed, 26 Feb 2014 00:01:00 +0000 (00:01 +0000)]
Fix build with Bionic libc

Add generic tests for fopen64 and fputs_unlocked functions to fix build
with Bionic libc that does not provide them.

* configure.ac (AC_CHECK_FUNCS): Add fopen64 and fputs_unlocked.
* strace.c [_LARGEFILE64_SOURCE]: Use fopen instead of fopen64
if !HAVE_FOPEN64.
Use fputs instead of fputs_unlocked if !HAVE_FPUTS_UNLOCKED.
* vsprintf.c: Use fputs instead of fputs_unlocked
if !HAVE_FPUTS_UNLOCKED.

Reported-by: Elliott Hughes <enh@google.com>
10 years agopowerpc64: fix 64-bit process detection on embedded
James Yang [Tue, 18 Feb 2014 21:32:43 +0000 (15:32 -0600)]
powerpc64: fix 64-bit process detection on embedded

* 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>
10 years agoDo not compile scsi ioctl decoding if <scsi/sg.h> is not available
Dmitry V. Levin [Tue, 25 Feb 2014 23:04:55 +0000 (23:04 +0000)]
Do not compile scsi ioctl decoding if <scsi/sg.h> is not available

Add a generic test for <scsi/sg.h> availability to fix build with
Bionic libc that does not provide <scsi/sg.h>.

* configure.ac (AC_CHECK_HEADERS): Add scsi/sg.h.
* ioctl.c (ioctl_decode): Do not call scsi_ioctl if !HAVE_SCSI_SG_H.
* scsi.c: Do not compile scsi ioctl decoding if !HAVE_SCSI_SG_H.

Reported-by: Elliott Hughes <enh@google.com>
10 years agoRevert "Add support for Altera's Nios-II softcore architecture"
Dmitry V. Levin [Fri, 14 Feb 2014 22:31:10 +0000 (22:31 +0000)]
Revert "Add support for Altera's Nios-II softcore architecture"

The patch originally submitted by Ezequiel García was OK, but I somehow
managed to mangle it so that most of the patch was not applied.

According to Ezequiel García, an architecture port based on the generic
syscall ABI is in progress.

This reverts commit 61e426e87ac81be4b4ff9de581635b4ea585624f.

10 years agotests: tighten sigaction check
Dmitry V. Levin [Sat, 8 Feb 2014 00:37:48 +0000 (00:37 +0000)]
tests: tighten sigaction check

* tests/sigaction.awk: Check that input conatins all expected lines.

10 years agoFix sigaction reporting on non-x86 architectures
Dmitry V. Levin [Sat, 8 Feb 2014 00:26:06 +0000 (00:26 +0000)]
Fix sigaction reporting on non-x86 architectures

If SA_RESTORER is not defined by libc headers but defined by kernel
headers, use the definition provided by kernel headers for proper
sigaction decoding.

* signal.c [!SA_RESTORER]: Define to ASM_SA_RESTORER if the latter is
defined, regardless of architecure.

10 years agoCheck for SA_RESTORER definition in <asm/signal.h>
Dmitry V. Levin [Sat, 8 Feb 2014 00:15:52 +0000 (00:15 +0000)]
Check for SA_RESTORER definition in <asm/signal.h>

Kernel header <asm/signal.h> cannot be included from regular code
because it conflicts with libc headers, but SA_RESTORER is needed in
signal.c, so SA_RESTORER value is forwarded from <asm/signal.h> to
config.h using a configure check.

* configure.ac (ASM_SA_RESTORER): Define if SA_RESTORER is defined
in <asm/signal.h>.

10 years agoarm: fix compilation warning
Dmitry V. Levin [Fri, 7 Feb 2014 18:02:39 +0000 (18:02 +0000)]
arm: fix compilation warning

Fix "dereferencing type-punned pointer will break strict-aliasing rules"
warning introduced by commit v4.8-54-g670b21b.

* signal.c (sys_sigreturn) [ARM]: Avoid dereferencing type-punned pointers.

10 years agokexec: fix typo
Dmitry V. Levin [Thu, 6 Feb 2014 21:13:36 +0000 (21:13 +0000)]
kexec: fix typo

* kexec.c (print_kexec_segments) [SUPPORTED_PERSONALITIES == 1]: Fix typo.

10 years agoAdd support for Altera's Nios-II softcore architecture
Ezequiel Garcia [Thu, 6 Feb 2014 17:53:54 +0000 (14:53 -0300)]
Add support for Altera's Nios-II softcore architecture

This commit adds strace support for Altera's Nios-II official
kernel port as found in git://git.rocketboards.org/linux-socfpga.git

Notice that this an out-of-tree kernel architectural port, and uses the
legacy (non-generic) system call ABI. In particular, the port doesn't
support PTRACE_GETREGSET, so the implementation is based on PTRACE_GETREGS.

Given it's mandatory for new architectures to support the generic
syscall ABI and PTRACE_GETREGSET, if the nios2 architecure is ever
mainlined, the strace support will have to be re-factored accordingly.

* linux/nios2/ioctlent.h.in: New file.
* linux/nios2/syscallent.h: Likewise.
* Makefile.am (EXTRA_DIST): Add linux/nios2/ioctlent.h.in and
linux/nios2/syscallent.h.
* configure.ac: Add NIOS2 to the list of supported architectures.
* defs.h [NIOS2]: Use register reading system.
* process.c (struct_user_offsets): Add NIOS2 support.
* syscall.c (get_regs, get_scno, get_syscall_args,
get_syscall_result, get_error): Likewise.
* util.c (change_syscall): Likewise.
* mem.c (sys_getpagesize): Define on NIOS2.
* system.c [NIOS2] (sys_cacheflush, sys_nios2cmpxchg): New functions.

Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Mike Frysinger <vapier@gentoo.org>
10 years agoImplement add_key, keyctl, and request_key decoding
Dmitry V. Levin [Wed, 5 Feb 2014 22:41:45 +0000 (22:41 +0000)]
Implement add_key, keyctl, and request_key decoding

* keyctl.c: New file.
* linux/keyctl.h: Likewise.
* Makefile.am (strace_SOURCES): Add keyctl.c.
(EXTRA_DIST): Add linux/keyctl.h.
* linux/dummy.h (sys_add_key, sys_keyctl, sys_request_key): Remove.
* linux/syscall.h (sys_add_key, sys_keyctl, sys_request_key): New
prototypes.

10 years agoImplement ioprio_get and ioprio_set decoding
Dmitry V. Levin [Wed, 5 Feb 2014 17:27:43 +0000 (17:27 +0000)]
Implement ioprio_get and ioprio_set decoding

* ioprio.c: New file.
* Makefile.am (strace_SOURCES): Add ioprio.c.
* linux/dummy.h (sys_ioprio_get, sys_ioprio_set): Remove.
* linux/syscall.h (sys_ioprio_get, sys_ioprio_set): New prototypes.

10 years agoImplement finit_module decoding
Dmitry V. Levin [Wed, 5 Feb 2014 16:17:02 +0000 (16:17 +0000)]
Implement finit_module decoding

* bjm.c (module_init_flags): New xlat structure.
(sys_finit_module): New function.
* linux/dummy.h (sys_finit_module): Remove.
* linux/syscall.h (sys_finit_module): New prototype.

10 years agoCleanup inotify syscalls decoding
Dmitry V. Levin [Wed, 5 Feb 2014 15:43:04 +0000 (15:43 +0000)]
Cleanup inotify syscalls decoding

* linux/inotify.h: New file.
* file.c (inotify_modes, inotify_init_flags, sys_inotify_add_watch,
sys_inotify_rm_watch, sys_inotify_init1): Move...
* inotify.c: ... here.
(inotify_modes): Rename to inotify_flags, convert to XLAT form.
(inotify_init_flags): Convert to XLAT form.
* Makefile.am (strace_SOURCES): Add inotify.c.
(EXTRA_DIST): Add linux/inotify.h.

10 years agoEnhance reboot decoding
Dmitry V. Levin [Wed, 5 Feb 2014 14:51:19 +0000 (14:51 +0000)]
Enhance reboot decoding

* linux/reboot.h: New file.
* system.c (bootflags1, bootflags2, bootflags3, sys_reboot): Move...
* reboot.c: ... here.
(bootflags2, bootflags3): Update constants.
* Makefile.am (strace_SOURCES): Add reboot.c.
(EXTRA_DIST): Add linux/reboot.h.

10 years agoImplement kexec_load decoding
Dmitry V. Levin [Wed, 5 Feb 2014 13:48:26 +0000 (13:48 +0000)]
Implement kexec_load decoding

* kexec.c: New file.
* linux/kexec.h: Likewise.
* Makefile.am (strace_SOURCES): Add kexec.c.
(EXTRA_DIST): Add linux/kexec.h.
* linux/dummy.h (sys_kexec_load): Remove.
* linux/syscall.h (sys_kexec_load): New prototype.

10 years agoUse prepared editions of recently imported linux headers
Dmitry V. Levin [Wed, 5 Feb 2014 12:56:26 +0000 (12:56 +0000)]
Use prepared editions of recently imported linux headers

* linux/fanotify.h: Replace with edition prepared with headers_install.sh.
* linux/personality.h: Likewise.

10 years agoImplement fanotify_init and fanotify_mark decoding
Dmitry V. Levin [Wed, 5 Feb 2014 04:13:18 +0000 (04:13 +0000)]
Implement fanotify_init and fanotify_mark decoding

* fanotify.c: New file.
* linux/fanotify.h: Likewise.
* Makefile.am (strace_SOURCES): Add fanotify.c.
(EXTRA_DIST): Add linux/fanotify.h.
* defs.h (print_dirfd): New prototype.
* file.c (print_dirfd): Export.
* linux/dummy.h (sys_fanotify_init, sys_fanotify_mark): Remove.
* linux/syscall.h (sys_fanotify_init, sys_fanotify_mark): New
prototypes.
* pathtrace.c (pathtrace_match): Handle sys_fanotify_init and
sys_fanotify_mark.

10 years agoUse XLAT_END macro
Dmitry V. Levin [Wed, 5 Feb 2014 02:20:51 +0000 (02:20 +0000)]
Use XLAT_END macro

Automatically update all xlat structures using the following sed regexp:
s/^[[:space:]]*{[[:space:]]*0[[:space:]]*,[[:space:]]*NULL[[:space:]]*,\?[[:space:]]*}[[:space:]]*,\?[[:space:]]*/\tXLAT_END/

10 years agoItroduce XLAT_END macro to make xlat structures more compact
Dmitry V. Levin [Wed, 5 Feb 2014 02:18:52 +0000 (02:18 +0000)]
Itroduce XLAT_END macro to make xlat structures more compact

* defs.h (XLAT_END): New macro.

10 years agoConvert personality_options to XLAT form
Dmitry V. Levin [Wed, 5 Feb 2014 02:09:49 +0000 (02:09 +0000)]
Convert personality_options to XLAT form

* linux/personality.h: New file.
* Makefile.am (EXTRA_DIST): Add it.
* system.c: Include <linux/personality.h>.
(personality_options): Update PER_* constants, convert to XLAT form.

10 years agoConvert futexops to XLAT form
Dmitry V. Levin [Wed, 5 Feb 2014 02:01:16 +0000 (02:01 +0000)]
Convert futexops to XLAT form

* process.c: Define FUTEX_*_PRIVATE macros.
(futexops): Convert to XLAT form.

10 years agoConvert sigev_value to XLAT form
Dmitry V. Levin [Wed, 5 Feb 2014 01:46:10 +0000 (01:46 +0000)]
Convert sigev_value to XLAT form

* time.c (sigev_value): Convert to XLAT form.
(printsigevent32, printsigevent): Update use of sigev_value.

10 years agoUse XLAT macro
Dmitry V. Levin [Wed, 5 Feb 2014 01:33:50 +0000 (01:33 +0000)]
Use XLAT macro

Automatically convert all xlat structures to XLAT form
using the following sed regexp:
s/^[[:space:]]*{[[:space:]]*\([^",}[:space:]]\+\)[[:space:]]*,[[:space:]]*"\1",\?[[:space:]]*}[[:space:]]*/\tXLAT(\1)/

10 years agoIntroduce XLAT macro to ease maintenance of xlat structures
Dmitry V. Levin [Wed, 5 Feb 2014 01:28:45 +0000 (01:28 +0000)]
Introduce XLAT macro to ease maintenance of xlat structures

* defs.h (XLAT): New macro.

Suggested-by: Mike Frysinger <vapier@gentoo.org>
10 years agoDecode ptp ioctls
Stefan Sørensen [Fri, 31 Jan 2014 11:01:01 +0000 (12:01 +0100)]
Decode ptp ioctls

* defs.h (ptp_ioctl): New prototype.
* ioctl.c (ioctl_decode): Call ptp_ioctl when code is '='.
* Makefile.am (strace_SOURCES): Add ptp.c.
(EXTRA_DIST): Add linux/ptp_clock.h.
* ptp.c: New file.
* linux/ptp_clock.h: New file.

Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
10 years agoDecode dynamic posix clocks
Stefan Sørensen [Mon, 3 Feb 2014 09:01:27 +0000 (10:01 +0100)]
Decode dynamic posix clocks

* time.c (cpuclocknames): New xlat structure.
(printclockname): New function that decodes posix clock names,
including dynamic fd encoded clocks.
(sys_clock_settime, sys_clock_gettime, sys_clock_nanosleep,
sys_clock_adjtime, sys_timer_create, sys_timerfd, sys_timerfd_create):
Use it.

Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
10 years agoUpdate ADJ_* constants
Stefan Sørensen [Fri, 31 Jan 2014 11:01:02 +0000 (12:01 +0100)]
Update ADJ_* constants

* time.c (adjtimex_modes): Add ADJ_TAI, ADJ_SETOFFSET, ADJ_MICRO,
ADJ_NANO, ADJ_OFFSET_SS_READ.

Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
10 years agoAdd decoding of sockets descriptor 'paths' for network calls
Philippe Ombredanne [Sat, 1 Feb 2014 17:57:45 +0000 (09:57 -0800)]
Add decoding of sockets descriptor 'paths' for network calls

* net.c (sys_bind, sys_listen, do_accept, sys_send, sys_sendto,
sys_sendmsg, sys_sendmmsg, sys_recv, sys_recvfrom, sys_recvmsg,
sys_recvmmsg, sys_shutdown, sys_getsockopt, sys_setsockopt): Decode
socket descriptor arguments using printfd.
* pathtrace.c (pathtrace_match): Also check TRACE_NETWORK syscalls
that take socket descriptor arguments.
* tests/net-fd.test: New test for socket descriptor arguments decoding.
* tests/Makefile.am (TESTS): Add net-fd.test.
(net-fd.log): New dependency on net.log.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
10 years agotests: rename all tests so that their names end in .test suffix
Dmitry V. Levin [Sun, 2 Feb 2014 15:20:11 +0000 (15:20 +0000)]
tests: rename all tests so that their names end in .test suffix

Due to automake limitations, some features work only for tests
that end in one of the suffixes listed in TEST_EXTENSIONS.

* tests/detach-running: Rename to detach-running.test.
* tests/detach-sleeping: Rename to detach-sleeping.test.
* tests/detach-stopped: Rename to detach-stopped.test.
* tests/net: Rename to net.test.
* tests/ptrace_setoptions: Rename to ptrace_setoptions.test.
* tests/qual_syscall: Rename to qual_syscall.test.
* tests/sigaction.sh: Rename to sigaction.test.
* tests/stat: Rename to stat.test.
* tests/strace-f: Rename to strace-f.test.
* tests/Makefile.am (TESTS): Update.
(LOG_COMPILER): Rename to TEST_LOG_COMPILER.

10 years agonet: add more sockopt options
Mike Frysinger [Thu, 30 Jan 2014 23:53:43 +0000 (18:53 -0500)]
net: add more sockopt options

This syncs with the defines as available in linux-3.13.

* net.c (sockipoptions): Add IP_IPSEC_POLICY, IP_XFRM_POLICY,
IP_PASSSEC, IP_TRANSPARENT, IP_ORIGDSTADDR, IP_RECVORIGDSTADDR,
IP_MINTTL, IP_NODEFRAG, IP_UNBLOCK_SOURCE, IP_BLOCK_SOURCE,
IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP, MCAST_JOIN_GROUP,
MCAST_BLOCK_SOURCE, MCAST_UNBLOCK_SOURCE, MCAST_LEAVE_GROUP,
MCAST_JOIN_SOURCE_GROUP, MCAST_LEAVE_SOURCE_GROUP, IP_MULTICAST_ALL,
IP_UNICAST_IF.

10 years agomips: fix sigaction reporting
Chris Dearman [Tue, 10 Dec 2013 03:58:42 +0000 (19:58 -0800)]
mips: fix sigaction reporting

MIPS userland uses the same sigaction structure with a full signal
mask for old_sigaction and new_sigaction and does does not have
an sa_restorer field.

These changes have been tested on MIPS O32 big/little endian, MIPS N64
big endian and x86-64.

* signal.c (old_sigaction) [MIPS]: Add definition for MIPS.
(decode_old_sigaction) [MIPS]: Print sa_mask according to its definition.
(new_sigaction) [MIPS]: Add definition for MIPS.

Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
10 years agoFactor out struct sigaction printing code
Dmitry V. Levin [Tue, 7 Jan 2014 22:41:30 +0000 (22:41 +0000)]
Factor out struct sigaction printing code

* signal.c [HAVE_SIGACTION] (decode_old_sigaction): New function.
[HAVE_SIGACTION] (sys_sigaction): Use it.
(decode_new_sigaction): New function.
(sys_rt_sigaction): Use it.

10 years agotests: add a test for rt_sigaction output
Dmitry V. Levin [Tue, 7 Jan 2014 19:32:32 +0000 (19:32 +0000)]
tests: add a test for rt_sigaction output

Since "struct sigaction" varies between architectures, rt_sigaction
decoding sometimes produces incorrect output.  This test is expected
to catch basic rt_sigaction decoding bugs.

Based on a patch proposed by Chris Dearman.

* tests/sigaction.c: New file.
* tests/sigaction.awk: Likewise.
* tests/sigaction.sh: New test.
* tests/Makefile.am (check_PROGRAMS): Add sigaction.
(TESTS): Add sigaction.sh.
(EXTRA_DIST): Add sigaction.awk.
* tests/.gitignore: Add sigaction.

10 years agomem: add missed MAP_HUGETLB mmap flag
Kirill A. Shutemov [Thu, 2 Jan 2014 11:15:32 +0000 (13:15 +0200)]
mem: add missed MAP_HUGETLB mmap flag

* mem.c (mmap_flags): Add MAP_HUGETLB mmap flag.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
10 years agoDelete old PTRACE_{PEEK,POKE}USR logic
Mike Frysinger [Tue, 31 Dec 2013 07:43:17 +0000 (02:43 -0500)]
Delete old PTRACE_{PEEK,POKE}USR logic

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.

10 years agoDecode the O_PATH flag
Mike Frysinger [Tue, 31 Dec 2013 06:13:27 +0000 (01:13 -0500)]
Decode the O_PATH flag

* file.c (open_mode_flags): Add O_PATH.

10 years agoRemove unused configure checks
Dmitry V. Levin [Wed, 13 Nov 2013 22:50:32 +0000 (22:50 +0000)]
Remove unused configure checks

* configure.ac (AC_CHECK_FUNCS): Remove _sys_siglist and sys_siglist.
(AC_CHECK_DECLS): Likewise.

10 years agoAssume that <sys/ptrace.h> provides a valid ptrace prototype
Dmitry V. Levin [Wed, 13 Nov 2013 18:09:04 +0000 (18:09 +0000)]
Assume that <sys/ptrace.h> provides a valid ptrace prototype

We used to explicitly list architectures where <sys/ptrace.h> from glibc
is known to provide a valid prototype for ptrace, and use a homegrown
replacement for all the rest.  Situation seems to be better nowadays,
glibc is not the only libc available, so let's use ptrace prototype from
<sys/ptrace.h> by default, leaving the replacement for rare broken cases
if any.

* defs.h: Use ptrace prototype workaround iff
NEED_PTRACE_PROTOTYPE_WORKAROUND is defined.

10 years agoStop using _LFS64_LARGEFILE
Dmitry V. Levin [Tue, 12 Nov 2013 22:34:42 +0000 (22:34 +0000)]
Stop using _LFS64_LARGEFILE

There is only one place left in the code where strace guesses whether
libc provides LFS64 functions and structures.  The most natural thing to
do there is to check for _LARGEFILE64_SOURCE - the macro provided by
glibc.  Other libc implementations that provide nondegenerate LFS64
interfaces are expected to define this macro as well.

* defs.h (_LFS64_LARGEFILE): Remove.
* strace.c: Use _LARGEFILE64_SOURCE instead of _LFS64_LARGEFILE.

10 years agoDefine truncate64, ftruncate64, and getdents64 decoders unconditionally
Dmitry V. Levin [Tue, 12 Nov 2013 22:25:06 +0000 (22:25 +0000)]
Define truncate64, ftruncate64, and getdents64 decoders unconditionally

These decoders are referenced by most architectures, there were no
undefined references so far because _LFS64_LARGEFILE appears to be
always defined by glibc when _GNU_SOURCE is defined.

* file.c (sys_truncate64, sys_ftruncate64, sys_getdents64): Define
unconditionally.

10 years agoDefine printflock64 only if it is referenced by other code
Dmitry V. Levin [Tue, 12 Nov 2013 21:49:03 +0000 (21:49 +0000)]
Define printflock64 only if it is referenced by other code

* configure.ac (AC_CHECK_TYPES): Add struct flock64.
* desc.c (HAVE_F_SETLK64, HAVE_F_SETLKW64, HAVE_F_GETLK64): New macros.
[!HAVE_STRUCT_FLOCK64] (struct flock64): Define.
(printflock64): Define only if referenced by other code.
(sys_fcntl): Handle F_FREESP64, F_SETLK64, F_SETLKW64, and F_GETLK64 iff
these constants are defined and differ from their non-64bit versions.

10 years agoMake PTRACE_PEEKUSER/PTRACE_POKEUSER checks less glibc specific
Dmitry V. Levin [Tue, 12 Nov 2013 21:20:50 +0000 (21:20 +0000)]
Make PTRACE_PEEKUSER/PTRACE_POKEUSER checks less glibc specific

* configure.ac (AC_CHECK_DECLS): Add PTRACE_PEEKUSER and
PTRACE_POKEUSER.
* defs.h: Define PTRACE_PEEKUSER and PTRACE_POKEUSER only if
they are not provided by <sys/ptrace.h>.

Reported by John Spencer.

10 years agoRemove unneeded redefinitions of IPPROTO_* macros
Dmitry V. Levin [Tue, 12 Nov 2013 16:13:43 +0000 (16:13 +0000)]
Remove unneeded redefinitions of IPPROTO_* macros

IPPROTO_* macros are defined by <netinet/in.h>, no need to redefine
them.

* net.c (IPPROTO_EGP, IPPROTO_PUP, IPPROTO_IDP, IPPROTO_IGMP,
IPPROTO_RAW, IPPROTO_MAX): Remove.

Reported by John Spencer.

10 years agoRemove unused AC_OFF_T_IS_LONG_LONG configure check
Dmitry V. Levin [Tue, 12 Nov 2013 15:43:06 +0000 (15:43 +0000)]
Remove unused AC_OFF_T_IS_LONG_LONG configure check

* configure.ac: Remove AC_OFF_T_IS_LONG_LONG.
* m4/long_long.m4: Likewise.

10 years agoRemove unused code
Dmitry V. Levin [Tue, 12 Nov 2013 15:39:09 +0000 (15:39 +0000)]
Remove unused code

* configure.ac (AC_CHECK_TYPES): Remove struct opthdr and
struct t_opthdr.
* net.c (print_sock_optmgmt): Remove.

10 years agoUse struct sigcontext instead of struct sigcontext_struct
Dmitry V. Levin [Tue, 12 Nov 2013 15:27:38 +0000 (15:27 +0000)]
Use struct sigcontext instead of struct sigcontext_struct

* configure.ac (AC_CHECK_TYPES): Remove struct sigcontext_struct.
* signal.c (sys_sigreturn) [S390 || S390X || POWERPC || ALPHA): Replace
struct sigcontext_struct with struct sigcontext.

Reported by John Spencer.

10 years agoUse standard names of sched_param structure members
Dmitry V. Levin [Tue, 12 Nov 2013 15:09:56 +0000 (15:09 +0000)]
Use standard names of sched_param structure members

* process.c (sys_sched_setscheduler, sys_sched_getparam,
sys_sched_setparam): Use portable struct sched_param member name
sched_priority instead of glibc specific __sched_priority.

Reported by John Spencer.

10 years agoMake SIGEV_THREAD_ID decoding less glibc specific
Dmitry V. Levin [Mon, 11 Nov 2013 23:54:30 +0000 (23:54 +0000)]
Make SIGEV_THREAD_ID decoding less glibc specific

SIGEV_THREAD_ID decoding requires access to an internal member of
struct sigevent.  There seems to be no portable way to do it besides
adding a configure check.

* configure.ac (AC_CHECK_MEMBERS): Check for
struct sigevent._sigev_un._pad and struct sigevent.__pad.
* time.c (printsigevent): Use an appropriate struct sigevent member
to print thread id.

Reported by John Spencer.

10 years agoRemove unused configure checks
Dmitry V. Levin [Mon, 11 Nov 2013 15:59:49 +0000 (15:59 +0000)]
Remove unused configure checks

* configure.ac (AC_CHECK_MEMBERS): Remove T_conn_res.QUEUE_ptr,
T_conn_res.ACCEPTOR_id, dqblk.dqb_curblocks, sigcontext.sc_hi2.

10 years agoAssume "long long" availability
Dmitry V. Levin [Mon, 11 Nov 2013 15:52:37 +0000 (15:52 +0000)]
Assume "long long" availability

Most of the code already uses long long types unconditionally.

* configure.ac: Remove the check for long long.
* file.c (printstat64): Remove HAVE_LONG_LONG checks, use %llu format
string unconditionally.

10 years agoInclude <sys/poll.h> only if there is no <poll.h>
Dmitry V. Levin [Wed, 6 Nov 2013 01:17:05 +0000 (01:17 +0000)]
Include <sys/poll.h> only if there is no <poll.h>

* pathtrace.c: Do not include <sys/poll.h> if <poll.h> is available.
* stream.c: Likewise.

10 years agoMove io_* syscalls decoding to a separate file
Dmitry V. Levin [Mon, 11 Nov 2013 15:06:18 +0000 (15:06 +0000)]
Move io_* syscalls decoding to a separate file

* desc.c (sys_io_setup, sys_io_destroy, sys_io_submit, sys_io_cancel,
sys_io_getevents, declarations from libaio.h): Move to ...
* aio.c: new file.
* Makefile.am (strace_SOURCES): Add aio.c.

10 years agoStop using external libaio.h.
Denys Vlasenko [Mon, 11 Nov 2013 11:50:47 +0000 (12:50 +0100)]
Stop using external libaio.h.

This change incorporates a partial copy instead
of using external libaio.h.
Why?
Because we want to properly decode 32-bit aio calls
by 64-bit strace. For that, we need more definitions than
libaio.h provides.
(These defs are not done yet, but will eventually be done).
Keeping our local 32-bit compat defs in sync with libaio.h
_without seeing libaio structs_ is hard/more bug prone.
A smaller benefit is that we don't need libaio installed.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
10 years agosys_io_submit: simplify iocb_cmd_lookup() helper.
Denys Vlasenko [Mon, 11 Nov 2013 11:31:18 +0000 (12:31 +0100)]
sys_io_submit: simplify iocb_cmd_lookup() helper.

This helper returns two values (a string and an enum).
The caller prints the string. It's simpler to just print
the string in the caller itself. This eliminates
"return by reference" and more importantly, an intermediate
static string buffer for the string result.

Since function of the helper is different now,
it is renamed to tprint_lio_opcode().

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
10 years agosys_io_submit: stop traversing iocb vector after first failure.
Denys Vlasenko [Mon, 11 Nov 2013 11:24:29 +0000 (12:24 +0100)]
sys_io_submit: stop traversing iocb vector after first failure.

The program may use a very large nr but supply either outright
invalid iocbpp[], or one with far fewer elements than nr.
We used to try reading iocbpp[i] until i == nr.
With this change, we stop on the first failure.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
10 years agoFix pathtrace_match() to match recent fixes to select decoding.
Denys Vlasenko [Sat, 9 Nov 2013 19:46:55 +0000 (20:46 +0100)]
Fix pathtrace_match() to match recent fixes to select decoding.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
10 years agoFix select decoding on e.g. 32-bit ppc process by 64-bit strace.
Denys Vlasenko [Sat, 9 Nov 2013 19:40:31 +0000 (20:40 +0100)]
Fix select decoding on e.g. 32-bit ppc process by 64-bit strace.

Added next_set_bit() function which finds the next set bit,
properly taking into account word size of the traced process.
Use it in decode_select() instead of fd_isset().
Also, properly round fdsize up to word size of traced process,
not to strace's word size.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoSpeed up and explain fd_isset()
Denys Vlasenko [Wed, 6 Nov 2013 10:34:02 +0000 (11:34 +0100)]
Speed up and explain fd_isset()

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoAdd a test for the latest select decoding fix
Dr. David Alan Gilbert [Tue, 5 Nov 2013 23:28:56 +0000 (23:28 +0000)]
Add a test for the latest select decoding fix

* test/select.c (main): Add a test for nfds larger than FD_SETSIZE.

11 years agoFix select decoding for glibc in _FORTIFY_SOURCE mode
Dmitry V. Levin [Tue, 5 Nov 2013 23:00:22 +0000 (23:00 +0000)]
Fix select decoding for glibc in _FORTIFY_SOURCE mode

glibc in _FORTIFY_SOURCE mode raises SIGABRT when descriptor greater
or equal to FD_SETSIZE is passed to FD_ISSET.  Select family syscalls,
however, can legitimately accept such descriptors.  To overcome this
limitation, we have to replace FD_ISSET with an equivalent that imposes
no such restrictions.

* desc.c (fd_isset): New function.
(decode_select): Use it instead of FD_ISSET.

11 years agoMore select decoding fixes
Dmitry V. Levin [Tue, 5 Nov 2013 22:46:43 +0000 (22:46 +0000)]
More select decoding fixes

* desc.c (decode_select): Actually print arg[0] as int on entering
syscall.  When arg[0] is negative, do not attempt to fetch and decode
descriptor sets on entering syscall, kernel will reject it anyway.
On exiting syscall, stop checking descriptor sets as soon as all
returned descriptors are found.

11 years agoTruncate arg[0] to int in select decoding.
Denys Vlasenko [Tue, 5 Nov 2013 15:20:16 +0000 (16:20 +0100)]
Truncate arg[0] to int in select decoding.

This matches kernel's behavior.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agotest/select.c: make comment more understandable.
Denys Vlasenko [Tue, 5 Nov 2013 11:44:55 +0000 (12:44 +0100)]
test/select.c: make comment more understandable.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoFix select decoding with bogus (huge or negative) nfds.
Dr. David Alan Gilbert [Tue, 5 Nov 2013 10:54:51 +0000 (11:54 +0100)]
Fix select decoding with bogus (huge or negative) nfds.

We used to allocate and fetch bit arrays using a sanitized
length, but then iterate over them with "j < arg[0]" condition,
where arg[0] is not sanitized. This segfaults if arg[0] is huge
or negative. This change fixes this.

Add test/select.c to capture the case.

Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoWork around conflict between <sys/ptrace.h> and <linux/ptrace.h>
Ali Polatel [Tue, 24 Sep 2013 17:04:32 +0000 (20:04 +0300)]
Work around conflict between <sys/ptrace.h> and <linux/ptrace.h>

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>
11 years agoAdd support for ARC Cores from Synopsys
Vineet Gupta [Fri, 16 Aug 2013 07:17:06 +0000 (12:47 +0530)]
Add support for ARC Cores from Synopsys

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>
11 years agoAdd support for decoding sync_file_range
William Manley [Fri, 9 Aug 2013 17:04:11 +0000 (18:04 +0100)]
Add support for decoding sync_file_range

* file.c (sync_file_range_flags): New xlat structure.
(sys_sync_file_range, sys_sync_file_range2): New functions.
* linux/syscall.h (sys_sync_file_range, sys_sync_file_range2): New
prototypes.
* linux/dummy.h (sys_sync_file_range, sys_sync_file_range2): Remove.
* linux/mips/syscallent-o32.h: Set the number of sync_file_range
arguments to 7.

11 years agofanotify_mark: fix number of args for 32bit arches
Mike Frysinger [Mon, 19 Aug 2013 05:00:39 +0000 (01:00 -0400)]
fanotify_mark: fix number of args for 32bit arches

The fanotify_mark func takes a 64bit mask, so 32bit arches have to split
it up into two fields.  When the syscall was added, it was listed as only
having 5 fields total (since that's correct for 64bit systems).

* linux/arm/syscallent.h: Set the number of fanotify_mark arguments to 6.
* linux/bfin/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/metag/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/mips/syscallent-o32.h: Likewise.
* linux/or1k/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/tile/syscallent1.h: Likewise.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: Chris Metcalf <cmetcalf@tilera.com> [for tile]
11 years agox86, x86_64: fix compilation warnings
Dmitry V. Levin [Wed, 11 Sep 2013 13:26:17 +0000 (13:26 +0000)]
x86, x86_64: fix compilation warnings

Fix "dereferencing type-punned pointer will break strict-aliasing rules"
warnings introduced by commit v4.8-52-gb51f364.

* signal.c (sys_sigreturn): Avoid dereferencing type-punned pointers.

11 years agoRemove rt parameter from [s]printsigmask()
Denys Vlasenko [Thu, 18 Jul 2013 18:42:41 +0000 (20:42 +0200)]
Remove rt parameter from [s]printsigmask()

In almost all cases, the parameter was 1 ("decode RT sigs too").
This change hardwires it to be 1.

The cases where it was 0 are, and why the change to "decode RT sigs too"
is fine:

IA64: 64-bit arch, all 64 signals fit in one word in any case.
S390[x]: sc.oldmask is a sigset_t on kernel side,
(sigset_t *)&sc.oldmask[0] does contain all 64 signals.
TILE: uc.uc_sigmask is a sigset_t on kernel side,
memcpy(&sigm, &uc.uc_sigmask, NSIG / 8) copies all 64 signals.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoConvert some uses of long_to_sigmask+printsigmask to sprintsigmask_long
Denys Vlasenko [Thu, 18 Jul 2013 18:37:06 +0000 (20:37 +0200)]
Convert some uses of long_to_sigmask+printsigmask to sprintsigmask_long

This allows to drop long_to_sigmask function,
and a whole bunch of sigset_t variables.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoSimplify some sigmask manipulations
Denys Vlasenko [Thu, 18 Jul 2013 18:12:33 +0000 (20:12 +0200)]
Simplify some sigmask manipulations

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoAdd compat support for sys_pselect6
Denys Vlasenko [Thu, 18 Jul 2013 16:10:13 +0000 (18:10 +0200)]
Add compat support for sys_pselect6

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoI386: fix signedness mismatch warning
Denys Vlasenko [Thu, 18 Jul 2013 15:40:45 +0000 (17:40 +0200)]
I386: fix signedness mismatch warning

&i386_regs.esp is a pointer to long, not unsigned long.
It needs a cast.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoFix sigset printing via print_sigset().
Denys Vlasenko [Thu, 18 Jul 2013 15:02:21 +0000 (17:02 +0200)]
Fix sigset printing via print_sigset().

Replace print_sigset() with print_sigset_addr_len(),
which takes not only addr, but also len parameter.
This allows us to drop "do we need to print RT signals?" parameter,
and this fixes RT signals printing in many syscalls.

sys_epoll_pwait: print RT signals too, print sigmask size argument.

sys_sigprocmask: print_sigset -> print_sigset_addr_len(current_wordsize),
no change in functionality.

sys_sigpending: use print_sigset_addr_len(current_wordsize)
instead of open-coding it.

sys_rt_sigprocmask: use print_sigset_addr_len instead of open-coding it.
sys_rt_sigpending: ditto.
sys_rt_sigsuspend: ditto.
sys_rt_sigtimedwait: ditto.

do_signalfd: print_sigset -> print_sigset_addr_len. This fixes
RT signals printing (wasn't showing them before).

sys_ppoll: ditto.

copy_sigset_len() is folded into its only user, print_sigset_addr_len(),
and copy_sigset() is gone.

While at it, checked kernel sources and noted where kernel enforces
sigset_size == NSIG / 8 (== sizeof(kernel_sigset_t)),
and where it allows word-sized sigset_size ([rt_]sigpending).

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agosys_rt_sigaction: fix sigset copying
Denys Vlasenko [Thu, 18 Jul 2013 08:10:46 +0000 (10:10 +0200)]
sys_rt_sigaction: fix sigset copying

In practice, we always copy as many bytes as syscall param says
(8, or 16 on mips). However, malicious program can call sigaction
with wrong sigset size. Such syscall will result in EINVAL,
but we (strace) end up copying 128 bytes (sizeof(sigset_t)),
which copyes some garbage from stack after struct sigaction.

Now we always copy NSIG / 8 bytes (which is 8 bytes, or 16 on mips).

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoARM: remove wrong NSIG = 32 define
Denys Vlasenko [Thu, 18 Jul 2013 07:41:20 +0000 (09:41 +0200)]
ARM: remove wrong NSIG = 32 define

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>
11 years agoARM: fix sigreturn decoding
Denys Vlasenko [Wed, 17 Jul 2013 15:26:56 +0000 (17:26 +0200)]
ARM: fix sigreturn decoding

Decoding of test/sigreturn testcase:
Was:
sigreturn() (mask [QUIT TRAP ABRT BUS SEGV USR2 PIPE STKFLT STOP XCPU VTALRM PROF WINCH IO PWR RTMIN]) = 0
Now:
sigreturn() (mask [CHLD RT_1 RT_3 RT_31 RT_32]) = 0

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoGroup USE_CUSTOM_PRINTF define with other tweakables
Denys Vlasenko [Tue, 16 Jul 2013 10:18:59 +0000 (12:18 +0200)]
Group USE_CUSTOM_PRINTF define with other tweakables

No code changes.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoImprove sigreturn decoding on x86 to show RT signal bits too.
Denys Vlasenko [Tue, 16 Jul 2013 10:06:25 +0000 (12:06 +0200)]
Improve sigreturn decoding on x86 to show RT signal bits too.

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>
11 years agopowerpc: enhance 32/64bit detection
Anton Blanchard [Thu, 11 Jul 2013 02:03:57 +0000 (12:03 +1000)]
powerpc: enhance 32/64bit detection

We were using uname to determine if userspace was 32 or 64bit.
This fails when we have a 64bit kernel and a 32bit userspace.

* configure.ac (powerpc*): Similar to x86, use a runtime test
to determine if we are 32 or 64bit.

Signed-off-by: Anton Blanchard <anton@samba.org>
11 years agopowerpc: fix some compiler warnings
Anton Blanchard [Fri, 12 Jul 2013 10:24:02 +0000 (12:24 +0200)]
powerpc: fix some compiler warnings

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>
11 years agopowerpc: fix iflag build issue (static -> extern)
Anton Blanchard [Fri, 12 Jul 2013 10:22:06 +0000 (12:22 +0200)]
powerpc: fix iflag build issue (static -> extern)

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoPTRACE_SEIZE can set ptrace options immediately, use this feature
Denys Vlasenko [Wed, 10 Jul 2013 12:33:05 +0000 (14:33 +0200)]
PTRACE_SEIZE can set ptrace options immediately, use this feature

This eliminates some rare bugs, such as post-execve SIGTRAP
generation when we attach to a process, and it manages to finish
execve'ing before we set TRACEEXEC option to suppress that.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoIf -o|logger is in use, exit trace loop if nprocs == 0.
Denys Vlasenko [Mon, 8 Jul 2013 11:55:04 +0000 (13:55 +0200)]
If -o|logger is in use, exit trace loop if nprocs == 0.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
11 years agoExit trace loop if got ECHILD, not if nprocs == 0.
Denys Vlasenko [Mon, 8 Jul 2013 09:28:27 +0000 (11:28 +0200)]
Exit trace loop if got ECHILD, not if nprocs == 0.

Comment gives a testcase which wasn't handled correctly
by the old code.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>