]> granicus.if.org Git - strace/log
strace
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.

9 years agoarm: fix get_mempolicy, set_mempolicy, and timerfd_create syscall entries
Dmitry V. Levin [Thu, 26 Feb 2015 23:03:10 +0000 (23:03 +0000)]
arm: fix get_mempolicy, set_mempolicy, and timerfd_create syscall entries

* linux/arm/syscallent.h (320, 321, 350): Fix names and handlers.

9 years agohppa: sync syscall entry names with kernel
Dmitry V. Levin [Thu, 26 Feb 2015 22:42:09 +0000 (22:42 +0000)]
hppa: sync syscall entry names with kernel

* linux/hppa/syscallent.h (18, 28, 59, 84, 108, 109, 280):
Change syscall names to match __NR_* constants defined in
arch/parisc/include/uapi/asm/unistd.h.

9 years agosubcall.h: add sendmmsg entry
Dmitry V. Levin [Thu, 26 Feb 2015 22:07:14 +0000 (22:07 +0000)]
subcall.h: add sendmmsg entry

* linux/subcall.h: Add sys_sendmmsg entry.
(SYS_socket_nsubcalls): Update.

9 years agoarm: simplify ARM_FIRST_SHUFFLED_SYSCALL definition
Dmitry V. Levin [Thu, 26 Feb 2015 22:05:45 +0000 (22:05 +0000)]
arm: simplify ARM_FIRST_SHUFFLED_SYSCALL definition

* linux/arm/syscallent.h (ARM_FIRST_SHUFFLED_SYSCALL): Use SYS_ipc_subcall.

9 years agoia64: parametrize i386 syscallent size check
Dmitry V. Levin [Thu, 26 Feb 2015 22:03:19 +0000 (22:03 +0000)]
ia64: parametrize i386 syscallent size check

* linux/ia64/syscallent.h: Use (SYS_ipc_subcall + SYS_ipc_nsubcalls)
instead of numeric constant.

9 years agoCleanup linux/subcall.h
Dmitry V. Levin [Thu, 26 Feb 2015 21:45:47 +0000 (21:45 +0000)]
Cleanup linux/subcall.h

* linux/subcall.h: Use SYS_ipc_subcall.

9 years agoalpha: fix statfs decoding
Dmitry V. Levin [Thu, 26 Feb 2015 21:08:40 +0000 (21:08 +0000)]
alpha: fix statfs decoding

* statfs.c (printstatfs) [ALPHA]: Remove faulty code.

9 years agox32: fix build regression
Dmitry V. Levin [Thu, 26 Feb 2015 20:40:43 +0000 (20:40 +0000)]
x32: fix build regression

* linux/x32/arch_regs.h: New file.
* Makefile.am (EXTRA_DIST): Add it.

9 years agohppa: fix fanotify_mark decoding
Mike Frysinger [Thu, 26 Feb 2015 19:16:13 +0000 (14:16 -0500)]
hppa: fix fanotify_mark decoding

The parisc kernel has some legacy baggage here and decodes the 64bit
field in the reverse order.  Handle it in strace too.

* fanotify.c [HPPA] (sys_fanotify_mark): Reverse the mask bits.

9 years agoia64: fix decoding of getresuid/getresgid/setresgid
Mike Frysinger [Thu, 26 Feb 2015 07:25:27 +0000 (02:25 -0500)]
ia64: fix decoding of getresuid/getresgid/setresgid

Looks like the similarity of these names caused confusion when generating
the syscall table.  getresgid was wired to the wrong output while the other
two were wired up to printargs instead of the real printer.

* linux/ia64/syscallent.h: Connect getresuid to sys_getresuid, getresgid to
sys_getresgid, and setresgid to sys_setresgid.

9 years agoia64: fix up builds after 16bit uid support
Mike Frysinger [Thu, 26 Feb 2015 07:15:33 +0000 (02:15 -0500)]
ia64: fix up builds after 16bit uid support

The ia64 port pulls in the i386 syscall table so it can decode
32bit apps, so we need to enable the 16bit uid parsers for it.

* defs.h (NEED_UID16_PARSERS): Define to 1 for IA64.
* linux/ia64/syscallent.h: Undefine sys_stime to avoid redefine warnings.

9 years agov4l2: use uintmax_t for times
Mike Frysinger [Thu, 26 Feb 2015 05:57:18 +0000 (00:57 -0500)]
v4l2: use uintmax_t for times

There is no guarantee that the backing value for the various time fields
are ints or longs which makes printfs annoying.  Lets cast them to the
uintmax_t type so we can use the j flag and not worry about truncation.

* v4l2.c (v4l2_ioctl): Use j and uintmax_t when printing tv_sec/tv_usec.

9 years agoignore core/compile files
Mike Frysinger [Thu, 26 Feb 2015 05:35:38 +0000 (00:35 -0500)]
ignore core/compile files

Newer autotools includes a compile helper script.

* .gitignore: Add /compile and core.

9 years agoNEWS: Prepare for 4.10 release
Dmitry V. Levin [Mon, 23 Feb 2015 20:24:00 +0000 (20:24 +0000)]
NEWS: Prepare for 4.10 release

9 years agoRemove support for systems without PTRACE_SETOPTIONS
Dmitry V. Levin [Sun, 8 Feb 2015 13:05:53 +0000 (13:05 +0000)]
Remove support for systems without PTRACE_SETOPTIONS

Assume that the kernel is v2.5.46 or newer, i.e. PTRACE_SETOPTIONS
and PTRACE_O_TRACESYSGOOD|PTRACE_O_TRACEEXEC|PTRACE_O_TRACECLONE
are universally available.

This change removes all code that implemented post-execve SIGTRAP
handling and fork/vfork/clone->CLONE_PTRACE substitution.

* defs.h (TCB_BPTSET, TCB_WAITEXECVE): Remove macros.
(need_fork_exec_workarounds, setbpt, clearbpt): Remove declarations.
* strace.c (need_fork_exec_workarounds,
test_ptrace_setoptions_followfork, test_ptrace_setoptions_for_all):
Remove.
(syscall_trap_sig): Set to (SIGTRAP | 0x80).
(ptrace_setoptions): Set to (PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEEXEC).
(detach): Do not test for TCB_BPTSET.
(init): Do not call test_ptrace_setoptions_followfork and
test_ptrace_setoptions_for_all.  Do not test for TCB_BPTSET.
* syscall.c (syscall_fixup_on_sysenter, internal_fork, internal_exec,
syscall_fixup_for_fork_exec, syscall_fixup_on_sysexit): Remove.
(trace_syscall_entering): Do not test for TCB_WAITEXECVE.  Do not call
syscall_fixup_on_sysenter and syscall_fixup_for_fork_exec.
(trace_syscall_exiting): Do not call syscall_fixup_on_sysexit and
syscall_fixup_for_fork_exec.
[IA64] (ia64_ia32mode): Make static.
* linux/ia64/arch_regs.h (ia64_ia32mode): Remove declaration.
* util.c: Do not include "syscall.h".
(arg_setup, get_arg0, get_arg1, set_arg0, set_arg1, restore_arg0,
restore_arg1, arg_finish_change, change_syscall, setbpt, clearbpt):
Remove.
* tests/ptrace_setoptions.test: Remove.
* tests/Makefile.am (TESTS): Remove it.

9 years agotests: robustify pc.test
Dmitry V. Levin [Mon, 23 Feb 2015 22:37:40 +0000 (22:37 +0000)]
tests: robustify pc.test

* tests/pc.c (main): Unmap larger memory region.
Dump process map for debug purposes.
* tests/pc.test: Update regexps to take CLD_DUMPED child process
into account.

9 years agotests: fix "make dist" regression
Dmitry V. Levin [Mon, 23 Feb 2015 21:47:15 +0000 (21:47 +0000)]
tests: fix "make dist" regression

* tests/Makefile.am (EXTRA_DIST): Add getrandom.awk.

9 years agotests: workaround broken awk
Dmitry V. Levin [Mon, 23 Feb 2015 21:42:16 +0000 (21:42 +0000)]
tests: workaround broken awk

* tests/getdents.out: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/getdents.test: Check whether awk is capable of matching long
regular expressions.

9 years agoFix compilation warnings about incompatible print formats
Dmitry V. Levin [Mon, 23 Feb 2015 21:35:20 +0000 (21:35 +0000)]
Fix compilation warnings about incompatible print formats

On some platforms printing of __s64 types with "%lld" format,
or __u64 types with "%llu" or "%llx" formats causes a warning
that __s64/__u64 type is not compatible with long long format.
From my PoV, this is nonsense, but the workaround costs nothing.

* scsi.c (print_sg_io_v4_req, print_sg_io_v4_res): Cast __u64 types
to (unsigned long long).
* v4l2.c (v4l2_ioctl): Likewise.  Cast __s64 type to (long long).

9 years agopowerpc64: fix build regression
Dmitry V. Levin [Mon, 23 Feb 2015 21:28:33 +0000 (21:28 +0000)]
powerpc64: fix build regression

* linux/powerpc64/arch_regs.h: New file.
* Makefile.am (EXTRA_DIST): Add it.

9 years agosignalent: update from linux v3.19
Dmitry V. Levin [Mon, 23 Feb 2015 20:53:12 +0000 (20:53 +0000)]
signalent: update from linux v3.19

* linux/alpha/signalent.h: Update from linux v3.19 signalent.sh.
* linux/hppa/signalent.h: Likewise.
* linux/mips/signalent.h: Likewise.
* linux/sparc/signalent.h: Likewise.

9 years agoCleanup auxiliary signalent files
Dmitry V. Levin [Mon, 23 Feb 2015 20:34:49 +0000 (20:34 +0000)]
Cleanup auxiliary signalent files

* linux/aarch64/signalent1.h: Include "signalent.h".
* linux/powerpc64/signalent1.h: Likewise.
* linux/sparc64/signalent2.h: Likewise.
* linux/tile/signalent1.h: Likewise.
* linux/x32/signalent1.h: Likewise.
* linux/x86_64/signalent1.h: Likewise.
* linux/x86_64/signalent2.h: Likewise.
* linux/sparc64/signalent.h: Include "sparc/signalent.h".
* linux/sparc64/signalent1.h: Include "sparc/signalent1.h".
* linux/x32/signalent.h: Remove.
* Makefile.am (EXTRA_DIST): Remove linux/x32/signalent.h.

9 years agox86_64, x32: fix sys_sigreturn
Dmitry V. Levin [Mon, 23 Feb 2015 16:18:09 +0000 (16:18 +0000)]
x86_64, x32: fix sys_sigreturn

On x86_64/x32, sys_sigreturn is defined only for i386 personality.

* signal.c (sys_sigreturn): Define for X32.
(sys_sigreturn) [X86_64 || X32]: Implement for i386 personality only.

9 years agosparc, x32: fix build regression
Dmitry V. Levin [Mon, 23 Feb 2015 13:43:20 +0000 (13:43 +0000)]
sparc, x32: fix build regression

* syscall.c (print_pc): Use current_wordsize iff it is defined.

9 years agoChange errnoent.h files to use designated initializers
Dmitry V. Levin [Mon, 23 Feb 2015 03:10:25 +0000 (03:10 +0000)]
Change errnoent.h files to use designated initializers

* signal.c (printsiginfo): Allow elements of errnoent array to be zero.
* syscall.c (trace_syscall_exiting): Likewise.
* errnoent.sh: Output designated initializers.
* linux/errnoent.h: Regenerated.
* linux/alpha/errnoent.h: Regenerated.
* linux/hppa/errnoent.h: Regenerated.
* linux/mips/errnoent.h: Regenerated.
* linux/sparc/errnoent.h: Regenerated.
* linux/sparc/errnoent1.h: Regenerated.
* linux/powerpc/errnoent.h: New file.
* linux/powerpc64/errnoent.h: Include "powerpc/errnoent.h".
* Makefile.am (EXTRA_DIST): Add linux/powerpc/errnoent.h
and linux/powerpc64/errnoent.h.

9 years agoerrnoent: update from linux v3.19
Dmitry V. Levin [Mon, 23 Feb 2015 02:39:04 +0000 (02:39 +0000)]
errnoent: update from linux v3.19

* linux/errnoent.h: Update from linux v3.19 using errnoent.sh.
* linux/alpha/errnoent.h: Likewise.
* linux/hppa/errnoent.h: Likewise.
* linux/mips/errnoent.h: Likewise.
* linux/sparc/errnoent.h: Likewise.

9 years agoCleanup auxiliary errnoent files
Dmitry V. Levin [Mon, 23 Feb 2015 02:32:21 +0000 (02:32 +0000)]
Cleanup auxiliary errnoent files

* linux/aarch64/errnoent1.h: Include "errnoent.h".
* linux/powerpc64/errnoent1.h: Likewise.
* linux/sparc64/errnoent2.h: Likewise.
* linux/tile/errnoent1.h: Likewise.
* linux/x32/errnoent1.h: Likewise.
* linux/x86_64/errnoent1.h: Likewise.
* linux/x86_64/errnoent2.h: Likewise.
* linux/sparc64/errnoent.h: Include "sparc/errnoent.h".
* linux/sparc64/errnoent1.h: Include "sparc/errnoent1.h".
* linux/x32/errnoent.h: Remove.
* Makefile.am (EXTRA_DIST): Remove linux/x32/errnoent.h.

9 years agoevdev: update constants from linux v3.19
Dmitry V. Levin [Sun, 22 Feb 2015 00:30:50 +0000 (00:30 +0000)]
evdev: update constants from linux v3.19

* xlat/evdev_keycode.in: Update from linux v3.19.
* xlat/evdev_prop.in: Likewise.

9 years agoevdev: decode keycode value in EVIOC[GS]KEYCODE_V2 commands
Dmitry V. Levin [Sat, 21 Feb 2015 23:05:26 +0000 (23:05 +0000)]
evdev: decode keycode value in EVIOC[GS]KEYCODE_V2 commands

* evdev.c (keycode_V2_ioctl): Use evdev_keycode to print
input_keymap_entry.keycode.

9 years agoevdev: fix build with old kernel headers
Dmitry V. Levin [Sat, 21 Feb 2015 23:50:33 +0000 (02:50 +0300)]
evdev: fix build with old kernel headers

* configure.ac: Check whether struct input_absinfo.resolution is defined
in <linux/input.h>.
* evdev.c (SYN_MAX): Add fallback definition.
(abs_ioctl): Wrap use of struct input_absinfo.resolution in #ifdef check.
(keycode_V2_ioctl, mtslots_ioctl, repeat_ioctl): Wrap in #ifdef checks.
(evdev_read_ioctl): Wrap in #ifdef checks the code that uses EV_SW,
EVIOCGREP, EVIOCGKEYCODE_V2, EVIOCGMTSLOTS, EVIOCGPROP, and EVIOCGSW.
(evdev_write_ioctl): Wrap in #ifdef checks the code that uses EVIOCSREP,
EVIOCSKEYCODE_V2, EVIOCSCLOCKID, and EVIOCREVOKE.

9 years agoAdd decoding for evdev ioctls
Etienne Gemsa [Fri, 20 Feb 2015 16:14:10 +0000 (17:14 +0100)]
Add decoding for evdev ioctls

This patch introduces decoding for evdev ioctls.  For EVIOCSFF the five
first members are decoded, the union is not.  The code was compiled and
tested on x86_64 with Linux 3.13.

* evdev.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (evdev_ioctl): New prototype.
* ioctl.c (ioctl_decode): Call evdev_ioctl for 'E' ioctl commands.
* xlat/evdev_autorepeat.in: New file.
* xlat/evdev_ff_status.in: New file.
* xlat/evdev_ff_types.in: New file.
* xlat/evdev_keycode.in: New file.
* xlat/evdev_leds.in: New file.
* xlat/evdev_misc.in: New file.
* xlat/evdev_mtslots.in: New file.
* xlat/evdev_prop.in: New file.
* xlat/evdev_relative_axes.in: New file.
* xlat/evdev_snd.in: New file.
* xlat/evdev_switch.in: New file.
* xlat/evdev_sync.in: New file.

Signed-off-by: Etienne Gemsa <etienne.gemsa@lse.epita.fr>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
9 years agoFix build with old kernel headers
Dmitry V. Levin [Sun, 22 Feb 2015 02:13:04 +0000 (02:13 +0000)]
Fix build with old kernel headers

* strace.c (print_debug_info, maybe_allocate_tcb, print_signalled,
print_exited): Remove "const" qualifier from status variable to
workaround some old implementations of WIFSIGNALED/WIFSTOPPED/WIFEXITED
macros.
* v4l2.c: Include <linux/types.h>.
(v4l2_ioctl): Check that V4L2_CTRL_FLAG_NEXT_CTRL and VIDIOC_S_EXT_CTRLS
macros are defined.
* tests/Makefile.am (AM_CPPFLAGS): Define.

9 years agoFix "make dist" regression
Dmitry V. Levin [Sun, 22 Feb 2015 01:06:57 +0000 (01:06 +0000)]
Fix "make dist" regression

* Makefile.am (EXTRA_DIST): Remove README-linux.

9 years agotest/sfd.c: add missing includes
Elliott Hughes [Fri, 20 Feb 2015 05:27:55 +0000 (21:27 -0800)]
test/sfd.c: add missing includes

9 years agoRemove linux/fanotify.h
Dmitry V. Levin [Thu, 19 Feb 2015 21:55:09 +0000 (21:55 +0000)]
Remove linux/fanotify.h

* linux/fanotify.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* fanotify.c: Do not include <linux/fanotify.h>.
* xlat/fan_classes.in: Add default values.
* xlat/fan_event_flags.in: Likewise.
* xlat/fan_init_flags.in: Likewise.
* xlat/fan_mark_flags.in: Likewise.

9 years agoRemove linux/keyctl.h
Dmitry V. Levin [Thu, 19 Feb 2015 21:42:31 +0000 (21:42 +0000)]
Remove linux/keyctl.h

* linux/keyctl.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* keyctl.c: Do not include <linux/keyctl.h>.
* xlat/key_perms.in: Add default values.
* xlat/key_reqkeys.in: Likewise.
* xlat/key_spec.in: Likewise.
* xlat/keyctl_commands.in: Likewise.

9 years agoRemove linux/kexec.h
Dmitry V. Levin [Thu, 19 Feb 2015 21:16:45 +0000 (21:16 +0000)]
Remove linux/kexec.h

* linux/kexec.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* kexec.c: Do not include <linux/kexec.h>.
* xlat/kexec_arch_values.in: Add default values.
* xlat/kexec_flags.in: Rename to kexec_load_flags.in, add default
values.

9 years agoRemove linux/inotify.h
Dmitry V. Levin [Thu, 19 Feb 2015 21:00:41 +0000 (21:00 +0000)]
Remove linux/inotify.h

* linux/inotify.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* inotify.c: Do not include <linux/inotify.h>.
* xlat/inotify_flags.in: Add default values.

9 years agoRemove linux/reboot.h
Dmitry V. Levin [Thu, 19 Feb 2015 20:47:36 +0000 (20:47 +0000)]
Remove linux/reboot.h

* linux/reboot.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* reboot.c: Do not include <linux/reboot.h>.
* xlat/bootflags1.in: Add default values.
* xlat/bootflags2.in: Likewise.
* xlat/bootflags3.in: Likewise.

9 years agoseccomp: fix fallback definitions of some SECCOMP_* constants
Dmitry V. Levin [Thu, 19 Feb 2015 20:30:01 +0000 (20:30 +0000)]
seccomp: fix fallback definitions of some SECCOMP_* constants

* seccomp.c (SECCOMP_SET_MODE_STRICT, SECCOMP_SET_MODE_FILTER,
SECCOMP_FILTER_FLAG_TSYNC): Remove fallback definitions.
* xlat/seccomp_filter_flags.in: Add default value.
* xlat/seccomp_ops.in: Add default values.

9 years agois_negated_errno: sync MAX_ERRNO with the kernel
Dmitry V. Levin [Thu, 19 Feb 2015 16:58:52 +0000 (16:58 +0000)]
is_negated_errno: sync MAX_ERRNO with the kernel

Linux kernel used to guarantee that the largest errno value will not
exceed 4095, but SECCOMP_RET_ERRNO support introduced by kernel commit
v3.4-rc2-13-gacf3b2c71ed20c53dc69826683417703c2a88059 inadvertently
broke it.  The guarantee is back with kernel commit
v3.19-8275-g580c57f1076872ebc2427f898b927944ce170f2d.

* syscall.c (is_negated_errno): Set maximum errno value to 4095.

9 years agoREADME-linux: punt
Mike Frysinger [Thu, 19 Feb 2015 05:04:13 +0000 (00:04 -0500)]
README-linux: punt

Considering we're requiring linux-2.6 era kernels, the discussion of
header troubles that plagued 2.2 and 2.4 are no longer relevant.

* README-linux: Delete.

9 years agoImprove prctl decoding
Dmitry V. Levin [Sat, 14 Feb 2015 01:51:03 +0000 (01:51 +0000)]
Improve prctl decoding

* configure.ac (AC_CHECK_HEADERS): Add linux/securebits.h.
* prctl.c (sys_prctl): Implement full decoding of all PR_* constants
as defined in linux v3.19.
(sys_arch_prctl): Fix decoding of unknown commands.
* xlat/cap.in: New file.
* xlat/pr_mce_kill.in: New file.
* xlat/pr_mce_kill_policy.in: New file.
* xlat/pr_set_mm.in: New file.
* xlat/pr_tsc.in: New file.
* xlat/pr_unalign_flags.in: New file.
* xlat/secbits.in: New file.
* xlat/prctl_options.in: Remove non-linux constants, add fallback
definitions.
* xlat/seccomp_mode.in: Add fallback definitions.

9 years agoxlat: extend syntax
Dmitry V. Levin [Wed, 18 Feb 2015 03:47:17 +0000 (03:47 +0000)]
xlat: extend syntax

* xlat/gen.sh (gen_header): If the name of constant is specified with a
value, generate a default definition for the constant using this value.
* xlat/timerfdflags.in: Use extended syntax.

9 years agoMove CAP_* definitions out to header files
Dmitry V. Levin [Wed, 18 Feb 2015 23:59:50 +0000 (23:59 +0000)]
Move CAP_* definitions out to header files

* Makefile.am (strace_SOURCES): Add caps0.h and caps1.h.
* caps0.h: New file.
* caps1.h: New file.
* capability.c: Remove CAP_* definitions, include "caps0.h"
and "caps1.h" instead.
Include "xlat/cap_mask0.h" instead of "xlat/capabilities.h".
Include "xlat/cap_mask1.h" instead of "xlat/capabilities1.h".
(print_cap_bits): Update callers.
* xlat/capabilities.in: Rename to xlat/cap_mask0.in.
* xlat/capabilities1.in: Rename to xlat/cap_mask1.in.

9 years agoDeclare all format printers with printf format attribute
Dmitry V. Levin [Tue, 17 Feb 2015 22:47:25 +0000 (22:47 +0000)]
Declare all format printers with printf format attribute

* defs.h (printllval, printnum_int, printnum_long): Mark with
format(printf) attribute.
* sock.c (sock_ioctl): Fix format string.

9 years agoRename printnum to printnum_long to avoid confusion
Dmitry V. Levin [Tue, 17 Feb 2015 22:03:17 +0000 (22:03 +0000)]
Rename printnum to printnum_long to avoid confusion

* defs.h (printnum): Rename to printnum_long.
* util.c (printnum): Likewise.
* process.c (sys_ptrace): Likewise.
* time.c (sys_time): Likewise.

9 years agoUse printnum_int consistently
Dmitry V. Levin [Tue, 17 Feb 2015 22:00:45 +0000 (22:00 +0000)]
Use printnum_int consistently

* sock.c (sock_ioctl): Use printnum_int instead of printnum to print
integer type.
* stream.c (sys_getpmsg): Likewise.

9 years agoprint_pc: fix multiple personalities support
Dmitry V. Levin [Sun, 15 Feb 2015 15:52:02 +0000 (15:52 +0000)]
print_pc: fix multiple personalities support

* syscall.c (print_pc): Choose instruction pointer format depending
on current_wordsize, not the size of long integer type.
* tests/pc.c: New file.
* tests/pc.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add pc.
(TESTS): Add pc.test.
* tests/.gitignore: Add pc.

9 years agomips: use PTRACE_GETREGS to fetch all registers
Dmitry V. Levin [Sun, 15 Feb 2015 03:27:13 +0000 (03:27 +0000)]
mips: use PTRACE_GETREGS to fetch all registers

* linux/mips/arch_regs.h (struct mips_regs): New structure.
(mips_REG_*): New macros.
* signal.c (sys_sigreturn) [MIPS]: Use mips_REG_SP.
* syscall.c [MIPS] (struct mips_regs): New variable.
[MIPS] (ARCH_REGS_FOR_GETREGS): New macro.
(mips_a3, mips_r2): Remove.
(print_pc) [MIPS]: Use mips_REG_EPC.
(get_scno) [MIPS]: Use mips_REG_V0 and mips_REG_A3.
(get_syscall_args) [MIPS]: Use mips_REG_A[0-5].
(get_syscall_result) [MIPS]: Remove.
(get_error) [MIPS]: Use mips_REG_A3 and mips_REG_V0.

9 years agomips: move ABI check to configure.ac
Dmitry V. Levin [Sun, 15 Feb 2015 01:08:48 +0000 (01:08 +0000)]
mips: move ABI check to configure.ac

* configure.ac [MIPS]: Check for MIPS ABI.
* defs.h [MIPS]: Remove MIPS ABI check.
* ioctlsort.c: Likewise.

9 years agotests: support alternative names of select syscall
Dmitry V. Levin [Mon, 16 Feb 2015 01:23:00 +0000 (01:23 +0000)]
tests: support alternative names of select syscall

* tests/select.awk: Recognize "_newselect" as another name of "select".
* tests/select.test: Try alternative names of select syscall.

9 years agoi386: fix compilation warning
Dmitry V. Levin [Sun, 15 Feb 2015 00:08:11 +0000 (00:08 +0000)]
i386: fix compilation warning

Some gcc versions complain about assigning long* to uint32_t* on i386.

* syscall.c [I386] (i386_esp_ptr): Change type from uint32_t* to long*.
* linux/i386/arch_regs.h (i386_esp_ptr): Likewise.
* linux/x86_64/arch_regs.h: Do not include "i386/arch_regs.h".
(i386_esp_ptr): New prototype.

9 years agoDo not reset get_regs_error unnecessarily
Dmitry V. Levin [Fri, 13 Feb 2015 22:45:33 +0000 (22:45 +0000)]
Do not reset get_regs_error unnecessarily

As get_regs() is now guaranteed to set get_regs_error,
there is no need to reset get_regs_error before get_regs() call.

* strace.c (trace): Call clear_regs() iff !WIFSTOPPED.

9 years agoget_syscall_result: remove redundant ifdefs
Dmitry V. Levin [Fri, 13 Feb 2015 23:06:36 +0000 (23:06 +0000)]
get_syscall_result: remove redundant ifdefs

As get_regs() is now guaranteed to fetch registers when either
ARCH_REGS_FOR_GETREGSET or ARCH_REGS_FOR_GETREGS is defined, we can
safely replace all checks for architectures where these macros are defined
with a single check for these macros.

* syscall.c (get_syscall_result): Check for [ARCH_REGS_FOR_GETREGSET ||
ARCH_REGS_FOR_GETREGS].  Remove all checks for architectures where
nothing has to be done after get_regs().

9 years agoget_regs: define for all architectures
Dmitry V. Levin [Fri, 13 Feb 2015 21:56:50 +0000 (21:56 +0000)]
get_regs: define for all architectures

* defs.h (get_regs_error): Remove.
(clear_regs): Update prototype, declare unconditionally.
(get_regs): Declare unconditionally.
* syscall.c (clear_regs): New function.
(get_regs): Define unconditionally.
(get_regs_error): Define unconditionally, change scope to static.

9 years agoget_regs: unify code for architectures that use PTRACE_GETREGS
Dmitry V. Levin [Fri, 13 Feb 2015 23:56:54 +0000 (23:56 +0000)]
get_regs: unify code for architectures that use PTRACE_GETREGS

* syscall.c [I386, POWERPC, ARM, AVR32, SPARC, SPARC64, TILE]
(ARCH_REGS_FOR_GETREGS): New macro.
(get_regs): Unify code for ARCH_REGS_FOR_GETREGS architectures.

9 years agoget_regset: define iff PTRACE_GETREGSET is used
Dmitry V. Levin [Fri, 13 Feb 2015 23:41:04 +0000 (23:41 +0000)]
get_regset: define iff PTRACE_GETREGSET is used

* syscall.c [AARCH64, X86_64, X32] (ARCH_REGS_FOR_GETREGSET,
ARCH_IOVEC_FOR_GETREGSET): New macros.
(get_regset): Define iff ARCH_REGS_FOR_GETREGSET is defined; change
return type to long, return ptrace() return code instead of assigning it
to get_regs_error; do not list individual architectures, implement
constant and variable iovec cases depending on ARCH_IOVEC_FOR_GETREGSET.
(get_regs): Assign get_regset() return code to get_regs_error.

9 years agoarm, i386: switch back to use PTRACE_GETREGS
Dmitry V. Levin [Fri, 13 Feb 2015 23:22:56 +0000 (23:22 +0000)]
arm, i386: switch back to use PTRACE_GETREGS

PTRACE_GETREGSET and PTRACE_GETREGS methods are equally good on arm and
i386 architectures, but PTRACE_GETREGSET with fallback to PTRACE_GETREGS
is a bit more costly, so choose the method that costs less.
This partially reverts commit v4.7-149-gfaa177e.

* syscall.c [ARM, I386] (ARCH_REGS_FOR_GETREGSET): Remove.
(get_regset) [ARM || I386]: Remove.
(get_regs) [ARM || I386]: Use PTRACE_GETREGS unconditionally.

9 years agosyscall.c: remove obsolete ifdefs
Dmitry V. Levin [Fri, 13 Feb 2015 22:57:31 +0000 (22:57 +0000)]
syscall.c: remove obsolete ifdefs

* syscall.c (get_regset, get_regs): Do not check for availability
of PTRACE_GETREGSET and NT_PRSTATUS macros.

9 years agosyscall.c: ensure that NT_PRSTATUS is defined
Dmitry V. Levin [Fri, 13 Feb 2015 22:53:00 +0000 (22:53 +0000)]
syscall.c: ensure that NT_PRSTATUS is defined

* syscall.c: Do not include <elf.h>.
(NT_PRSTATUS): New macro.

9 years agoMove regs-related macros and declarations from defs.h to regs.h
Dmitry V. Levin [Fri, 13 Feb 2015 02:12:14 +0000 (02:12 +0000)]
Move regs-related macros and declarations from defs.h to regs.h

* regs.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/arch_regs.h: New file.
* linux/alpha/arch_regs.h: Likewise.
* linux/arm/arch_regs.h: Likewise.
* linux/hppa/arch_regs.h: Likewise.
* linux/i386/arch_regs.h: Likewise.
* linux/ia64/arch_regs.h: Likewise.
* linux/mips/arch_regs.h: Likewise.
* linux/powerpc/arch_regs.h: Likewise.
* linux/sh64/arch_regs.h: Likewise.
* linux/sparc/arch_regs.h: Likewise.
* linux/sparc64/arch_regs.h: Likewise.
* linux/tile/arch_regs.h: Likewise.
* linux/x86_64/arch_regs.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* defs.h: Remove definitions of PTRACE_*, REG_*, PT_*, U_REG_*,
and ARM_* macros.
Remove declarations of struct pt_regs variables.
[SPARC]: Do not include <asm/psr.h>.
[SPARC64]: Do not include <asm/psrcompat.h>.
* bjm.c: Do not include <sys/user.h>.
* process.c: Include "regs.h".
Do not include <sys/user.h> and <sys/reg.h>.
[IA64]: Do not include <asm/ptrace_offsets.h> and <asm/rse.h>.
* util.c: Likewise.
* syscall.c: Likewise.
[AARCH64]: Define struct arm_pt_regs and ARM_* macros.
[SPARC]: Include <asm/psr.h>.
[SPARC64]: Include <asm/psrcompat.h>.
* signal.c: Include "regs.h".
Do not include <sys/user.h> and <sys/reg.h>.
[IA64]: Do not include <asm/ptrace_offsets.h>.
* strace.c [IA64]: Do not include <asm/ptrace_offsets.h>.

9 years agoMove all ptrace-related macros and declarations from defs.h to ptrace.h
Dmitry V. Levin [Fri, 13 Feb 2015 00:26:38 +0000 (00:26 +0000)]
Move all ptrace-related macros and declarations from defs.h to ptrace.h

* ptrace.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* configure.ac (AC_CHECK_HEADERS): Remove linux/ptrace.h and sys/ptrace.h.
* defs.h: Do not include <sys/ptrace.h> and <asm/ptrace.h>.
Remove definitions of PTRACE_* macros.
* process.c: Remove <linux/ptrace.h> workarounds, include "ptrace.h".
* signal.c: Likewise.
* syscall.c: Likewise.
* util.c: Likewise.
* strace.c: Include "ptrace.h".
* wait.c: Likewise.

9 years agoEnhance wait status decoding
Dmitry V. Levin [Thu, 12 Feb 2015 22:43:02 +0000 (22:43 +0000)]
Enhance wait status decoding

* xlat/ptrace_events.in: New file.
* wait.c: Include "xlat/ptrace_events.h".
(printstatus): In case of WIFSTOPPED, print 0x80 flag separately from
the stop signal name.
[WIFCONTINUED]: Add WIFCONTINUED support.
Decode PTRACE_EVENT_* events.

9 years agoscsi: add bsg support
Bart Van Assche [Fri, 6 Feb 2015 12:37:03 +0000 (13:37 +0100)]
scsi: add bsg support

The Linux kernel supports two different versions of the SG_IO API,
namely v3 and v4. This patch adds support for version 4 of this API.
At least the sg3_utils package supports version 4 of this API.  Version
4 of this API is used if /dev/bsg/H:C:I:L is used as device name.

This patch has been tested by inspecting the output of the following
commands:

modprobe scsi_debug dev_size_mb=16 delay=0
dev=$(lsscsi | sed -n '/ scsi_debug /s,^[^/]*,,p')
./strace -eioctl -s256 sg_inq $dev
echo 'Test XDWRITEREAD(10)'
bsg=/dev/bsg/$(lsscsi | sed -n '/ scsi_debug /s,^\[\([^]]\+\)\].*,\1,p')
dd if=/dev/zero bs=512 count=1 |
  ./strace -eioctl -s256 sg_raw -s 512 -r 1024 $bsg 53 00 00 00 00 01 00 00 01 00

* configure.ac (AC_CHECK_HEADERS): Add linux/bsg.h.
* xlat/bsg_protocol.in: New file.
* xlat/bsg_subprotocol.in: Likewise.
* scsi.c: Include them and <linux/bsg.h>.
(print_sg_io_v3_req, print_sg_io_v3_res, print_sg_io_v4_req,
print_sg_io_v4_res): New functions.
(print_sg_io_req, print_sg_io_res): Use them.
(scsi_ioctl): Update callers.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
9 years agoscsi: Add iovec support
Bart Van Assche [Fri, 6 Feb 2015 12:36:26 +0000 (13:36 +0100)]
scsi: Add iovec support

* scsi.c (print_sg_io_req, print_sg_io_res): Add support for decoding
iovecs passed via the SG I/O v3 interface.  Decode the "data in" and
"data out" buffers in hex instead of in ASCII.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
9 years agoscsi: on exit, print only initialized part of the buffer
Bart Van Assche [Fri, 6 Feb 2015 12:36:26 +0000 (13:36 +0100)]
scsi: on exit, print only initialized part of the buffer

* scsi.c (print_sg_io_res): Only print that part of the data in buffer
that has been initialized by the SCSI LLD driver.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
9 years agoscsi: make print_sg_io_buffer() print square brackets instead of its callers
Bart Van Assche [Fri, 6 Feb 2015 12:36:26 +0000 (13:36 +0100)]
scsi: make print_sg_io_buffer() print square brackets instead of its callers

* scsi.c (print_sg_io_buffer): Print square brackets in this function.
(print_sg_io_req, print_sg_io_res): Update callers.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
9 years agoscsi: improve consistency with other decoding functions
Bart Van Assche [Fri, 6 Feb 2015 12:36:26 +0000 (13:36 +0100)]
scsi: improve consistency with other decoding functions

Pass pointers to tracee's memory as integers instead of pointers.

* scsi.c (print_sg_io_buffer): Change second argument's type to
unsigned long.
(print_sg_io_req, print_sg_io_res): Update callers.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
9 years agotests: extend getdents to support all filesystems regardless of file order
Dmitry V. Levin [Sun, 8 Feb 2015 01:34:08 +0000 (01:34 +0000)]
tests: extend getdents to support all filesystems regardless of file order

* tests/getdents.awk: Include all 6 possible permutations of 3
direntries to regexps.

9 years agoprint_setsockopt: fix fall-through bug in SOL_IP switch case
Dmitry V. Levin [Sun, 8 Feb 2015 01:19:06 +0000 (01:19 +0000)]
print_setsockopt: fix fall-through bug in SOL_IP switch case

This fixes the bug introduced by commit v4.9-250-ga0a4909.

* net.c (print_setsockopt): Separate SOL_IP case from SOL_PACKET.

Reported-by: Ben Noordhuis <info@bnoordhuis.nl>
9 years agoDo not watch for post-execve SIGTRAP if PTRACE_O_TRACEEXEC is enabled
Dmitry V. Levin [Sat, 7 Feb 2015 23:26:44 +0000 (23:26 +0000)]
Do not watch for post-execve SIGTRAP if PTRACE_O_TRACEEXEC is enabled

If PTRACE_O_TRACEEXEC option is enabled, then post-execve SIGTRAPs are
suppressed and we can safely skip -ENOSYS heuristics.  This partially
reverts commits v4.9-258-g8e398b6 and v4.9-261-gd70c41d.

* syscall.c (syscall_fixup_on_sysenter): Skip if PTRACE_O_TRACEEXEC
flag is set in ptrace_setoptions.  Remove all SECCOMP_RET_ERRNO
workarounds as they are not needed when PTRACE_O_TRACEEXEC is not
supported by the kernel.

9 years agoWhen the process stared by strace exits/terminates, forget its pid
Dmitry V. Levin [Sat, 7 Feb 2015 19:41:48 +0000 (19:41 +0000)]
When the process stared by strace exits/terminates, forget its pid

The process stared by strace can exit/terminate only once.  When this
happens, forget its pid, so that any other event or action related to a
process with the same pid as the pid of that first process would not be
confused with that first process.

* strace.c (print_signalled, print_exited): Clear strace_child when it
equals to the given pid.

9 years ago-b execve: avoid misleading warning about unknown pid
Dmitry V. Levin [Sat, 7 Feb 2015 18:48:55 +0000 (18:48 +0000)]
-b execve: avoid misleading warning about unknown pid

* strace.c (maybe_allocate_tcb): If detach_on_execve is set, do not warn
about !WIFSTOPPED process with pid == strace_child.
* tests/bexecve.test: New test.
* tests/Makefile.am (TESTS): Add it.

9 years ago-b execve: do not use struct tcb after detach
Dmitry V. Levin [Sat, 7 Feb 2015 17:47:53 +0000 (17:47 +0000)]
-b execve: do not use struct tcb after detach

* strace.c (trace): Do not proceed after detach.

9 years agotrace: split into several functions
Dmitry V. Levin [Sat, 7 Feb 2015 17:31:54 +0000 (17:31 +0000)]
trace: split into several functions

This change moves the main loop back to main() and splits trace()
into several functions.  There are no algorithmic changes.

* strace.c (print_debug_info, maybe_allocate_tcb, maybe_switch_tcbs,
print_signalled, print_exited, print_stopped, startup_tcb): New
functions.
(trace) Use them.  Move the main loop ...
(main): ... here.

9 years agoprintsiginfo: constify the first argument
Dmitry V. Levin [Sat, 7 Feb 2015 15:47:24 +0000 (15:47 +0000)]
printsiginfo: constify the first argument

* signal.c (printsiginfo): Make the first argument a pointer to a const type.
* defs.h (printsiginfo): Likewise.
(printsiginfo, printsiginfo_at): Always define these prototypes.
* configure.ac (AC_CHECK_TYPES): Remove siginfo_t, as HAVE_SIGINFO_T
is no longer used.

9 years agotest: add a manual test for seccomp decoding
Dmitry V. Levin [Fri, 6 Feb 2015 01:52:59 +0000 (01:52 +0000)]
test: add a manual test for seccomp decoding

* test/.gitignore: Add seccomp.
* test/Makefile (PROGS): Likewise.
* test/seccomp.c: New file.
* test/README: Mention ../tests/.

9 years agoImplement seccomp decoding
Dmitry V. Levin [Wed, 4 Feb 2015 23:50:50 +0000 (23:50 +0000)]
Implement seccomp decoding

* configure.ac (AC_CHECK_HEADERS): Add linux/filter.h
and linux/seccomp.h.
* defs.h (print_seccomp_filter): New prototype.
* linux/dummy.h (sys_seccomp): Remove.
* linux/syscall.h (sys_seccomp): New prototype.
* prctl.c: Include <linux/seccomp.h>.
(sys_prctl): Decode PR_SET_SECCOMP.
* seccomp.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/bpf_class.in: New file.
* xlat/bpf_miscop.in: Likewise.
* xlat/bpf_mode.in: Likewise.
* xlat/bpf_op_alu.in: Likewise.
* xlat/bpf_op_jmp.in: Likewise.
* xlat/bpf_rval.in: Likewise.
* xlat/bpf_size.in: Likewise.
* xlat/bpf_src.in: Likewise.
* xlat/seccomp_filter_flags.in: Likewise.
* xlat/seccomp_mode.in: Likewise.
* xlat/seccomp_ops.in: Likewise.
* xlat/seccomp_ret_action.in: Likewise.

9 years agois_negated_errno: support large errno values
Dmitry V. Levin [Thu, 5 Feb 2015 23:47:36 +0000 (23:47 +0000)]
is_negated_errno: support large errno values

Thanks to SECCOMP_RET_DATA == 0xffff, abnormally large errno
values could be easily seen when a seccomp filter is used, e.g.
BPF_STMT(BPF_RET, SECCOMP_RET_ERRNO | SECCOMP_RET_DATA)

* syscall.c (is_negated_errno): Allow errno values as large as 0xffff.

9 years agox86, x32, x86_64: print SECCOMP_RET_ERRNO filtered syscalls
Dmitry V. Levin [Thu, 5 Feb 2015 23:43:06 +0000 (23:43 +0000)]
x86, x32, x86_64: print SECCOMP_RET_ERRNO filtered syscalls

This is required to process SECCOMP_RET_ERRNO filtered syscalls on
systems where linux kernel does not change the syscall number to -1.

* syscall.c (is_negated_errno): Move before syscall_fixup_on_sysenter.
(syscall_fixup_on_sysenter) [I386 || X32 || X86_64] : Use it to check
AX register.

9 years agois_negated_errno: merge x86_64 and x32 definitions
Dmitry V. Levin [Thu, 5 Feb 2015 18:50:24 +0000 (18:50 +0000)]
is_negated_errno: merge x86_64 and x32 definitions

* syscall.c (kernel_long_t, kernel_ulong_t): New types.
(is_negated_errno): Merge [X32] and [!X32] definitions.
(get_error): Merge [X86_64] and [X32] code.