]> granicus.if.org Git - strace/log
strace
7 years agoUpdate NEWS
Eugene Syromyatnikov [Wed, 30 Nov 2016 21:31:25 +0000 (00:31 +0300)]
Update NEWS

7 years agotests: use kernel_ulong_t as argument type in setfsuid/setfsgid tests
Eugene Syromyatnikov [Mon, 28 Nov 2016 19:00:05 +0000 (22:00 +0300)]
tests: use kernel_ulong_t as argument type in setfsuid/setfsgid tests

* setfsugid.c: Include "kernel_types.h".
(main): Change type of entries of the "tests" array from long to
kernel_ulong_t.

7 years agouid: print size as signed in setgroups/getgroups
Eugene Syromyatnikov [Sun, 27 Nov 2016 23:51:04 +0000 (02:51 +0300)]
uid: print size as signed in setgroups/getgroups

As this is the type used in kernel.

* uid.c (SYS_FUNC(setgroups), SYS_FUNC(getgroups)): Print size parameter
as "%d".
* tests/getgroups.c: Update expected output.
* tests/setgroups.c: Likewise.

Co-authored-by: Elvira Khabirova <lineprinter0@gmail.com>
7 years agouid: use printuid for printing UID/GID value
Eugene Syromyatnikov [Sun, 27 Nov 2016 23:50:03 +0000 (02:50 +0300)]
uid: use printuid for printing UID/GID value

* uid.c (setfsuid, get_print_uid, print_gid): Use printuid.
* tests/setfsugid.c (printuid): New function.
(main): Use it to print UID/GID values.
* tests/setgroups.c: Likewise.
* tests/setugid.c (ugid2int): Remove.
(printuid): New function.
(main): Use it to print UID/GID values.

Co-authored-by: Elvira Khabirova <lineprinter0@gmail.com>
7 years agotests: additional check for PTRACE_SETSIGINFO ptrace command
Eugene Syromyatnikov [Wed, 30 Nov 2016 20:50:26 +0000 (23:50 +0300)]
tests: additional check for PTRACE_SETSIGINFO ptrace command

* tests/ptrace.c (main): Add an additional PTRACE_SETSIGINFO check.

7 years agosyscall_name: clear __X32_SYSCALL_BIT from syscall number on x32
Dmitry V. Levin [Thu, 1 Dec 2016 01:01:02 +0000 (01:01 +0000)]
syscall_name: clear __X32_SYSCALL_BIT from syscall number on x32

* linux/x86_64/get_scno.c (X32_PERSONALITY_NUMBER): New macro.
* syscall.c (syscall_name) [X32_PERSONALITY_NUMBER && __X32_SYSCALL_BIT]:
Clear __X32_SYSCALL_BIT from scno on x32 personality.

7 years agoPrint syscall names only for defined syscalls
Eugene Syromyatnikov [Wed, 30 Nov 2016 20:43:51 +0000 (23:43 +0300)]
Print syscall names only for defined syscalls

The string literal "__NR_syscall_4294967295" is semantically incorrect
as there is no such constant defined.

* syscall.c (syscall_name): Return NULL if there is no syscall
corresponding to the given number.
* defs.h (syscall_name): Document this behaviour.
* printsiginfo.c (print_si_info): Print syscall name with "__NR_" prefix
only if there is a syscall corresponding to si_syscall number; print
a plain syscall number otherwise.
* tests/ptrace.c (main): Update expected output.

7 years agoaffinity: print cpu set as an array
Eugene Syromyatnikov [Wed, 30 Nov 2016 10:42:13 +0000 (13:42 +0300)]
affinity: print cpu set as an array

* affinity.c: Add comma between elements of cpu set.
* tests/sched_xetaffinity.c (main): Update expected output.

7 years agostatfs: fix printing format of f_fsid field
Eugene Syromyatnikov [Wed, 30 Nov 2016 10:32:47 +0000 (13:32 +0300)]
statfs: fix printing format of f_fsid field

* print_statfs.c: Print f_fsid as a structure containing field "val"
which, in turn, is an array of two elements that used to be printed
as members of f_fsid structure.
* tests/statfs.expected: Update expected output.
* tests/xstatfsx.c (print_statfs): Likewise.

7 years agoswap: always print priority value
Eugene Syromyatnikov [Wed, 30 Nov 2016 07:20:50 +0000 (10:20 +0300)]
swap: always print priority value

* swapon.c (SYS_FUNC(swapon)): Do not check for non-zero the value
of the prio variable in order to print it.
* tests/swap.c (main): Update expected output.

7 years agotests: show pattern line number in match_grep
Elvira Khabirova [Fri, 19 Aug 2016 15:36:06 +0000 (18:36 +0300)]
tests: show pattern line number in match_grep

This makes debugging of failing test  a bit easier.

* tests/init.sh (match_grep): Add the cnt variable, increment it on every
pattern line read, print it as a prefix for non-matched pattern.

7 years agofutex: make output of the val3 argument of the FUTEX_WAKE_OP command more structured
Eugene Syromyatnikov [Sun, 27 Nov 2016 15:07:36 +0000 (18:07 +0300)]
futex: make output of the val3 argument of the FUTEX_WAKE_OP command more structured

It is a number which consists of several xlat values, not a structure.

* futex.c (SYS_FUNC(futex)): Modify output of the val3 argument
of the FUTEX_WAKE_OP futex syscall command.
* tests/futex.c (main): Update expected output.

Co-authored-by: Elvira Khabirova <lineprinter0@gmail.com>
7 years agotests: additional checks for prctl-* tests
Eugene Syromyatnikov [Fri, 18 Nov 2016 17:51:44 +0000 (20:51 +0300)]
tests: additional checks for prctl-* tests

* tests/prctl-pdeathsig.c (main): Additional checks.
* tests/prctl-tsc.c (main): Likewise.
* tests/prctl-pdeathsig.test: Update value of -a argument.
* tests/prctl-tsc.test: Likewise.

7 years agotests: add prctl-pdeathsig.test and prctl-tsc.test
JingPiao Chen [Thu, 17 Nov 2016 13:15:51 +0000 (21:15 +0800)]
tests: add prctl-pdeathsig.test and prctl-tsc.test

* tests/prctl-pdeathsig.c: New file.
* tests/prctl-tsc.c: Likewise.
* tests/prctl-pdeathsig.test: New test.
* tests/prctl-tsc.test: Likewise.
* tests/.gitignore: Add prctl-pdeathsig and prctl-tsc.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add prctl-pdeathsig.test and prctl-tsc.test.

7 years agosyscall: Simplify strip_prefix
Dmitry V. Levin [Wed, 30 Nov 2016 16:50:56 +0000 (16:50 +0000)]
syscall: Simplify strip_prefix

* syscall.c (strip_prefix): Use strncmp instead of strlen+memcmp.

7 years agoutil: fix integer overflow check in string_to_uint_ex
Dmitry V. Levin [Wed, 30 Nov 2016 14:39:02 +0000 (14:39 +0000)]
util: fix integer overflow check in string_to_uint_ex

* util.c (string_to_uint_ex): Fix the check for integer overflow
on systems where LONG_MAX == INT_MAX.

7 years agoCheck dumping of io syscalls when descriptor arguments are sensibly large
Dmitry V. Levin [Wed, 30 Nov 2016 00:56:04 +0000 (00:56 +0000)]
Check dumping of io syscalls when descriptor arguments are sensibly large

* tests/tests.h (pipe_maxfd): New prototype.
* tests/pipe_maxfd.c: New file.
* tests/print_maxfd.c: Likewise.
* tests/.gitignore: Add print_maxfd.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(libtests_a_SOURCES): Add pipe_maxfd.c.
* tests/readv.c (main): Use pipe_maxfd() instead of pipe(),
fds[0] instead of 0, fds[1] instead of 1.
* tests/readv.test: Use print_maxfd to specify dump descriptor numbers.

7 years agodumpio: remove useless check
Dmitry V. Levin [Wed, 30 Nov 2016 00:04:03 +0000 (00:04 +0000)]
dumpio: remove useless check

* syscall.c (dumpio): Remove SEN_printargs check.  Use tcp->s_ent->sen
directly.

7 years agoFix dumping of io syscalls when descriptor argument has unused bits set
Dmitry V. Levin [Tue, 29 Nov 2016 22:56:49 +0000 (22:56 +0000)]
Fix dumping of io syscalls when descriptor argument has unused bits set

* syscall.c (dumpio): Explicitly cast the first argument of syscall
to "int", the same way as the kernel does.
* tests/read-write.c: Include <asm/unistd.h> and "kernel_types.h".
(k_read, k_write): New functions.
(test_dump, main): Use them.

7 years agox32: fix preadv2-pwritev2.test
Dmitry V. Levin [Tue, 29 Nov 2016 19:51:15 +0000 (19:51 +0000)]
x32: fix preadv2-pwritev2.test

* tests/preadv2-pwritev2.c: Include "kernel_types.h".
(main): Use kernel_ulong_t instead of unsigned long as types
of arguments of preadv2 and pwritev2 syscalls.

7 years agox32: wire up preadv2 and pwritev2 syscalls
Dmitry V. Levin [Tue, 29 Nov 2016 09:39:39 +0000 (09:39 +0000)]
x32: wire up preadv2 and pwritev2 syscalls

* linux/x32/syscallent.h [546]: Add preadv2 entry.
[547]: Add pwritev2 entry.

7 years agosignal: fix omission of field names in sigaction printers
Eugene Syromyatnikov [Mon, 28 Nov 2016 19:02:52 +0000 (22:02 +0300)]
signal: fix omission of field names in sigaction printers

* signal.c (decode_old_sigaction, decode_new_sigaction): Add printing
of the field names.
* tests/sigaction.awk: Update expected output.

Co-authored-by: Elvira Khabirova <lineprinter0@gmail.com>
7 years agoMake date output format conform to ISO 8601
Elvira Khabirova [Sat, 13 Aug 2016 17:27:38 +0000 (20:27 +0300)]
Make date output format conform to ISO 8601

* util.c (sprinttime): Make date output conform to ISO 8601.
* tests/utime.c (print_tm): Update expected output.
* tests/xstatx.c (print_time): Likewise.

7 years agotests: rewrite utime.test without relying on libc utime wrapper
Dmitry V. Levin [Tue, 29 Nov 2016 04:08:47 +0000 (04:08 +0000)]
tests: rewrite utime.test without relying on libc utime wrapper

* tests/utime.c (k_utime): New function, a thin wrapper around
syscall(__NR_utime).
(main): Use it instead of utime.
* tests/utime.test: Update.

7 years agoFix meaning of negated sets in fault expressions
Dmitry V. Levin [Tue, 29 Nov 2016 02:11:48 +0000 (02:11 +0000)]
Fix meaning of negated sets in fault expressions

Change the parser of fault expression to follow the POLA:
-e fault=!SET
means that all syscalls except those from SET are subject to fault
injection;
-e fault=!SET1:error=ERRNO1, -e fault=!SET2:error=ERRNO2
means that all syscalls except those from SET2 are subject to fault
injection with error code ERRNO2, and all syscalls from SET2 that are
not in SET1 are subject to fault injection with error code ERRNO1.

* syscall.c (qualify_scno, qualify_syscall_class, qualify_syscall_name):
Handle negated QUAL_FAULT case differently.
* tests/fault_syntax.test: Add checks of negated sets.

7 years agoprint_sigevent: fix field names of sigev_value structure
Eugene Syromyatnikov [Mon, 28 Nov 2016 19:12:12 +0000 (22:12 +0300)]
print_sigevent: fix field names of sigev_value structure

* print_sigevent.c (print_sigevent): Change "int" to "sival_int", "ptr"
to "sival_ptr".
* tests/mq_sendrecv.c (main): Update expected output in accordance with
fixed field names.
* tests/timer_create.c (main): Likewise.

7 years agotests: add more utime checks
Eugene Syromyatnikov [Mon, 28 Nov 2016 09:44:54 +0000 (12:44 +0300)]
tests: add more utime checks

* tests/utime.c: Include <unistd.h> and <asm/unistd.h>.
(main): Add checks for invalid pointers.

7 years agoutime: fix omission of field names in utimbuf structure printing
Eugene Syromyatnikov [Mon, 28 Nov 2016 09:26:13 +0000 (12:26 +0300)]
utime: fix omission of field names in utimbuf structure printing

* utime.c (SYS_FUNC(utime)): Print struct utimbuf as a structure,
not as an array (use curly brackets instead of square ones).
Add field names to the output.
* tests/utime.c (main): Update expected output.

7 years agomem: print mincore output as an array
Eugene Syromyatnikov [Mon, 28 Nov 2016 01:28:53 +0000 (04:28 +0300)]
mem: print mincore output as an array

* mem.c (SYS_FUNC(minore)): Print commas between elements.
* tests/mincore.c (print_mincore): Update expected output in accordance
with syscall decoder formatting change.

7 years agoutil: provide information whether xlat value has been found
Eugene Syromyatnikov [Sun, 27 Nov 2016 15:04:58 +0000 (18:04 +0300)]
util: provide information whether xlat value has been found

This is necessary for the upcoming change in the output format
of the val3 argument of the FUTEX_WAKE_OP futex command.

* defs.h (printxvals, printxval_searchn): Change return type to int.
(printxval64, printxval, printxval_long): Likewise.  Forward the value
returned by printxvals call.
* util.c (printxvals, printxval_searchn): Change return type to int,
return 1 if xlat value has been found, 0 otherwise.

7 years agoutil: check dflt argument for NULL in printxvals
Eugene Syromyatnikov [Sun, 27 Nov 2016 15:03:38 +0000 (18:03 +0300)]
util: check dflt argument for NULL in printxvals

This is necessary for the upcoming change in the output format
of the val3 argument of the FUTEX_WAKE_OP futex command.

* util.c (printxvals): Do not print dflt if it is NULL.

7 years agocapability: fix omission of capability structure field names
Eugene Syromyatnikov [Sun, 27 Nov 2016 00:35:02 +0000 (03:35 +0300)]
capability: fix omission of capability structure field names

* capability.c (print_cap_header, print_cap_data): Add field names
to the output.
* tests/caps.awk: Update test output.

7 years agotests: fix "comparison between signed and unsigned" compilation warnings
Dmitry V. Levin [Mon, 28 Nov 2016 20:55:10 +0000 (20:55 +0000)]
tests: fix "comparison between signed and unsigned" compilation warnings

* tests/readv.c (main): Cast r_len to int.
* tests/preadv2-pwritev2.c (dumpio): Likewise.

7 years agoaarch64, arm, sparc: add comments on fault injection support in kernel
Dmitry V. Levin [Mon, 28 Nov 2016 19:46:50 +0000 (19:46 +0000)]
aarch64, arm, sparc: add comments on fault injection support in kernel

* linux/aarch64/set_scno.c: Note the kernel commit that introduced
NT_ARM_SYSTEM_CALL support.
* linux/arm/set_scno.c: Note the kernel commit that introduced
PTRACE_SET_SYSCALL support.
* linux/sparc/set_scno.c: Note the kernel commit that introduced
reloading from the syscall number register.

7 years agotests: check -C option
Dmitry V. Levin [Mon, 28 Nov 2016 16:57:30 +0000 (16:57 +0000)]
tests: check -C option

* tests/strace-C.expected: New file.
* tests/strace-C.test: New test.
* tests/Makefile.am (MISC_TESTS): Add strace-C.test.
(EXTRA_DIST): Add strace-C.expected.

7 years agotests: check basic options syntax
Dmitry V. Levin [Mon, 28 Nov 2016 12:35:51 +0000 (12:35 +0000)]
tests: check basic options syntax

* tests/options-syntax.test: New file.
* tests/Makefile.am (MISC_TESTS): Add it.

7 years agoFix -r option syntax
Dmitry V. Levin [Mon, 28 Nov 2016 15:03:08 +0000 (15:03 +0000)]
Fix -r option syntax

While -r option implies -t, it should not literally have the effect
of -t option, e.g. -rr should not increment tflag twice.

* strace.c (init): In the getopt loop, do not increment tflag for each
occurrence of -r option.  After the getopt loop, if rflag is set, set
tflag to 1.  Issue a warning that -tt has no effect with -r.

7 years agoPrint timeval pair as an array of timeval entries
Eugene Syromyatnikov [Sun, 27 Nov 2016 20:24:12 +0000 (23:24 +0300)]
Print timeval pair as an array of timeval entries

* print_timeval.c (print_timeval_item): New function.
(print_timeval_pair): Use it as a print_function in print_array call.
* tests/futimesat.c (main): Update to test new behaviour.
* tests/utimes.c (main): Likewise.

7 years agotests: treat tv_sec/tv_usec as signed types in futimesat and utimes tests
Eugene Syromyatnikov [Sun, 27 Nov 2016 15:46:31 +0000 (18:46 +0300)]
tests: treat tv_sec/tv_usec as signed types in futimesat and utimes tests

* tests/futimesat.c: Print tv_sec and tv_usec fields as signed types.
* tests/utimes.c: Likewise.

7 years agoalpha: print struct timeval32 consistently
Dmitry V. Levin [Mon, 28 Nov 2016 04:21:11 +0000 (04:21 +0000)]
alpha: print struct timeval32 consistently

* defs.h [ALPHA] (timeval32_t): New type.
[ALPHA] (print_timeval32_t): New prototype.
* print_timeval.c [ALPHA] (timeval32_t): Remove.
[ALPHA] (print_timeval32_t): Remove static keyword.
* printrusage.c [ALPHA] (printrusage32): Use timeval32_t instead
of local definition of struct timeval32.  Use print_timeval32_t.

7 years agoPrint struct timeval consistently
Dmitry V. Levin [Mon, 28 Nov 2016 04:07:37 +0000 (04:07 +0000)]
Print struct timeval consistently

Use print_struct_timeval interface to print struct timeval.

* print_timeval.c (print_struct_timeval): New mpers printer.
* print_timex.c (print_timex): Use it.
* printrusage.c (printrusage): Likewise.
* v4l2.c (print_v4l2_buffer): Likewise.
* tests/getrusage.c (main): Print tv_sec and tv_usec fields as signed.
* tests/waitid.c (sprint_rusage): Likewise.

Suggested-by: Eugene Syromyatnikov <evgsyr@gmail.com>
7 years agoSplit print_time.c
Dmitry V. Levin [Mon, 28 Nov 2016 02:45:13 +0000 (02:45 +0000)]
Split print_time.c

After commit v4.14-136-g151d1d1 that removed the last object common
for timespec and timeval parsers there is no need to keep them all
in a single file.

* print_timespec.c: New file.
* print_timeval.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* print_time.c: Move all timespec related code to print_timespec.c.
Move all timeval related code to print_timeval.c.

7 years agotests: check decoding of threads when a non-leader thread invokes execve
Dmitry V. Levin [Mon, 28 Nov 2016 00:31:59 +0000 (00:31 +0000)]
tests: check decoding of threads when a non-leader thread invokes execve

* tests/threads-execve.c: New file.
* tests/threads-execve.test: New test.
* tests/.gitignore: Add threads-execve.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(threads_execve_LDADD): New variable.
(MISC_TESTS): Add threads-execve.test.

7 years agotests: check decoding of fault injected exit_group syscall
Dmitry V. Levin [Sun, 27 Nov 2016 00:02:18 +0000 (00:02 +0000)]
tests: check decoding of fault injected exit_group syscall

* tests/answer.c: New file.
* tests/fault_injection-exit_group.expected: Likewise.
* tests/fault_injection-exit_group.test: New test.
* tests/.gitignore: Add answer.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add fault_injection-exit_group.test.
(EXTRA_DIST): Add fault_injection-exit_group.expected.

7 years agoSet PTRACE_O_TRACEEXIT option and handle PTRACE_EVENT_EXIT events
Dmitry V. Levin [Sat, 26 Nov 2016 23:45:05 +0000 (23:45 +0000)]
Set PTRACE_O_TRACEEXIT option and handle PTRACE_EVENT_EXIT events

Do not assume that some syscalls do not generate syscall-exit-stops.
When syscalls fail for any reason they may generate syscall-exit-stops.

The solution is to wait for an actual exit reported by PTRACE_EVENT_EXIT
and print the end of unfinished exiting syscall properly.

* exit.c: Remove.
* Makefile.am (strace_SOURCES): Remove exit.c.
* linux/dummy.h (sys_exit): Alias to printargs_d.
* strace.c (ptrace_setoptions): Add PTRACE_O_TRACEEXIT bit.
(print_event_exit): New function.
(trace): Use it in case of PTRACE_EVENT_EXIT.
* syscall.c (trace_syscall_entering): Remove special handling
of SEN_exit.

7 years agoChange printargs to return RVAL_DECODED
Dmitry V. Levin [Sun, 27 Nov 2016 14:19:09 +0000 (14:19 +0000)]
Change printargs to return RVAL_DECODED

As printargs is invoked as a generic syscall decoder only and
it is not supposed to print anything on exiting, change printargs
to return RVAL_DECODED so it would not be called on exiting at all.

* util.c (printargs): Print args unconditionally, return RVAL_DECODED.

7 years agoEnhance error diagnostics of exit/exit_group decoder
Dmitry V. Levin [Sat, 26 Nov 2016 20:51:52 +0000 (20:51 +0000)]
Enhance error diagnostics of exit/exit_group decoder

* exit.c (SYS_FUNC(exit)): Print the name of syscall that has returned.

7 years agoRestrain from fault injection while the trace executes strace code
Dmitry V. Levin [Sat, 26 Nov 2016 18:30:26 +0000 (18:30 +0000)]
Restrain from fault injection while the trace executes strace code

There is little use in injections of faults into syscalls made by strace.

* syscall.c (trace_syscall_entering): Clear QUAL_FAULT bit from
tcp->qual_flg when tcp->flags has TCB_HIDE_LOG bit set.

7 years agoMove two global flags to tracee scope
Dmitry V. Levin [Sat, 26 Nov 2016 18:08:01 +0000 (18:08 +0000)]
Move two global flags to tracee scope

A simultaneous use of -p option and tracing of a command available
since commit v4.11-183-gfa8c286 introduces a race condition because
the flags whether the first exec has happened are global.

Fix the race by moving hide_log_until_execve and hide_log_until_execve
global variables to TCB_HIDE_LOG and TCB_SKIP_DETACH_ON_FIRST_EXEC bits
in struct tcb.flags, correspondingly.

* defs.h (TCB_HIDE_LOG, TCB_SKIP_DETACH_ON_FIRST_EXEC, hide_log):
New macros.
(hide_log_until_execve): Remove prototype.
* strace.c (skip_one_b_execve, hide_log_until_execve): Remove.
(startup_child): Set TCB_HIDE_LOG and TCB_SKIP_DETACH_ON_FIRST_EXEC bits
in the allocated tcb structure.
(init): Remove initialization of hide_log_until_execve and
skip_one_b_execve.
(print_stopped): Use hide_log() instead of hide_log_until_execve.
(trace): Check and clear TCB_SKIP_DETACH_ON_FIRST_EXEC flag instead
of skip_one_b_execve.
* syscall.c (trace_syscall_entering): Clear TCB_HIDE_LOG flag instead of
hide_log_until_execve.
(trace_syscall_entering, trace_syscall_exiting): Check hide_log()
instead of hide_log_until_execve.

7 years agoTreat execveat as an execve family syscall
Dmitry V. Levin [Sat, 26 Nov 2016 16:08:10 +0000 (16:08 +0000)]
Treat execveat as an execve family syscall

* syscall.c (trace_syscall_entering): Clear hide_log_until_execve flag
also when SEN_execveat is encountered.

7 years agoChange parser of fault expressions to conform the documentation
Dmitry V. Levin [Fri, 25 Nov 2016 23:47:32 +0000 (23:47 +0000)]
Change parser of fault expressions to conform the documentation

Make expressions like fault=SYSCALL1,SYSCALL2:error=EPERM work
as documented, i.e. fail both SYSCALL1 and SYSCALL2 with EPERM.

* syscall.c (parse_fault_expression): Remove const qualifier from
"name" and "token: variables, as well as from the return value.
(qual_fault): Remove const qualifier from "name" variables.
Split "name" into comma delimited tokens and pass each token
to individual qual_syscall_ex call.
(qualify): For QUAL_FAULT options, pass the whole option value
to their qualify methods without prior splitting into comma
delimited tokens.
* tests/fault_injection.test: Check it.
* tests/fault_syntax.test: Check empty syscall sets.

7 years agoSimplify parse_fault_expression
Dmitry V. Levin [Thu, 24 Nov 2016 21:35:05 +0000 (21:35 +0000)]
Simplify parse_fault_expression

* syscall.c (parse_fault_expression): Rewrite iterator over strtok_r
in a more concise way.

7 years agoFix omission of field names in printers of timeval structure
Eugene Syromyatnikov [Thu, 24 Nov 2016 21:48:00 +0000 (00:48 +0300)]
Fix omission of field names in printers of timeval structure

* print_time.c (time_fmt): Remove.
(timeval_fmt): New constant.
(print_timeval_t, sprint_timeval, print_timeval32_t, sprint_timeval32):
Use it instead of time_fmt.
* print_timex.c (print_timex): Print field names of the time field.
* printrusage.c (printrusage, printrusage32): Print field names
of ru_utime and ru_stime fields.
* tests/adjtimex.c (main): Add field names to expected output.
* tests/clock_nanosleep.c (main): Likewise.
* tests/futimesat.c (main): Likewise.
* tests/getrusage.c (main): Likewise.
* tests/nanosleep.c (main): Likewise.
* tests/oldselect.expected: Likewise.
* tests/utimes.c (main): Likewise.
* tests/wait4.c (sprint_rusage): Likewise.
* tests/waitid.c (sprint_rusage): Likewise.
* tests/xetitimer.c (main): Likewise.
* tests/xettimeofday.c (main): Likewise.
* tests/xselect.c (main): Likewise.

7 years agoFix omission of field names in printers of timespec structure
Eugene Syromyatnikov [Thu, 24 Nov 2016 21:48:00 +0000 (00:48 +0300)]
Fix omission of field names in printers of timespec structure

* print_time.c (timespec_fmt): New constant.
(print_timespec_t, sprint_timespec): Use it instead of time_fmt.
* tests/aio.c: Add field names to expected output.
* tests/clock_nanosleep.c (main): Likewise.
* tests/clock_xettime.c (main): Likewise.
* tests/futex.c (main): Likewise.
* tests/mq_sendrecv.c (do_send, do_recv): Likewise.
* tests/nanosleep.c (main): Likewise.
* tests/ppoll-v.expected: Likewise.
* tests/ppoll.expected: Likewise.
* tests/pselect6.c (main): Likewise.
* tests/recvmmsg-timeout.c (main): Likewise.
* tests/restart_syscall.c (main): Likewise.
* tests/rt_sigtimedwait.c (iterate, main): Likewise.
* tests/sched_rr_get_interval.c (main): Likewise.
* tests/semop.c (main): Likewise.
* tests/strace-T.expected: Likewise.
* tests/timer_xettime.c (main): Likewise.
* tests/timerfd_xettime.c (main): Likewise.
* tests/utimensat.c (print_ts): Likewise.

7 years agotests: robustify prctl-name.test against unrelated prctl invocations
Dmitry V. Levin [Wed, 23 Nov 2016 00:38:03 +0000 (00:38 +0000)]
tests: robustify prctl-name.test against unrelated prctl invocations

* tests/prctl-name.test: Filter out unrelated PR_GET_* prctl calls.

7 years agotests: cleanup prctl-name.c
Dmitry V. Levin [Tue, 22 Nov 2016 01:46:07 +0000 (01:46 +0000)]
tests: cleanup prctl-name.c

* tests/prctl-name.c (main): Remove "len" variable, rename "len1"
to "len".  Remove "name1" variable, use "name" instead.

7 years agoMove KVM_* ioctl entries from ioctls_inc*.h to ioctls_arch*.h
Dmitry V. Levin [Mon, 21 Nov 2016 19:44:14 +0000 (19:44 +0000)]
Move KVM_* ioctl entries from ioctls_inc*.h to ioctls_arch*.h

* linux/32/ioctls_inc_align32.h: Regenerate.
* linux/32/ioctls_inc_align64.h: Likewise.
* linux/64/ioctls_inc.h: Likewise.
* linux/arm/ioctls_arch0.h: Likewise.
* linux/i386/ioctls_arch0.h: Likewise.
* linux/powerpc/ioctls_arch0.h: Likewise.
* linux/s390/ioctls_arch0.h: Likewise.
* linux/s390x/ioctls_arch0.h: Likewise.
* linux/x32/ioctls_inc0.h: Likewise.
* linux/x86_64/ioctls_arch0.h: Likewise.

7 years agomaint: add more workarounds for alpha and powerpc
Dmitry V. Levin [Tue, 22 Nov 2016 00:20:49 +0000 (00:20 +0000)]
maint: add more workarounds for alpha and powerpc

* maint/ioctls_sym.sh: Skip asm/core_*.h.  Filter out from
asm-generic/ioctls.h those macros that are defined using unavailable
struct termios2 on alpha and powerpc.

7 years agoAdd ioctl definitions for 16-bit alignment
Andreas Schwab [Sat, 12 Nov 2016 14:58:26 +0000 (15:58 +0100)]
Add ioctl definitions for 16-bit alignment

* Makefile.am (EXTRA_DIST): Add linux/32/ioctls_inc_align16.h.
* linux/32/ioctls_inc_align16.h: New file.
* linux/32/ioctls_inc.h [M68K]: Include it.

7 years agomaint: move KVM_* constants from ioctls_inc.h to ioctls_arch.h
Dmitry V. Levin [Mon, 21 Nov 2016 16:23:14 +0000 (16:23 +0000)]
maint: move KVM_* constants from ioctls_inc.h to ioctls_arch.h

* maint/ioctls_gen.sh: Place constants defined in linux/kvm.h
into ioctls_arch.h instead of ioctls_inc.h.

7 years agomaint: harmonize use of ioctls_sym.sh
Dmitry V. Levin [Mon, 21 Nov 2016 16:14:03 +0000 (16:14 +0000)]
maint: harmonize use of ioctls_sym.sh

* maint/ioctls_gen.sh: Consistently specify INCLUDES for all
ioctls_sym.sh invocations.  Use $mydir to specify ioctls_sym.sh
location.

7 years agomaint: rework workarounds for linux/kvm.h
Dmitry V. Levin [Mon, 21 Nov 2016 16:08:08 +0000 (16:08 +0000)]
maint: rework workarounds for linux/kvm.h

* maint/ioctls_sym.sh: Remove pre-include linux/kvm.h workarounds.
Skip linux/kvm.h on those architectures that have no asm/kvm.h file.
Introduce post-process workarounds, add post-process workarounds
for linux/kvm.h.

7 years agoRestructure strace.1
Elvira Khabirova [Sun, 20 Nov 2016 00:17:10 +0000 (03:17 +0300)]
Restructure strace.1

* strace.1 (OPTIONS): Add subsections.
(PROBLEMS): Rename to REPORTING BUGS.
(SEE ALSO): Move to the bottom.

7 years agoprctl: implement decoding of PR_SET_FP_MODE and PR_GET_FP_MODE options
Eugene Syromyatnikov [Sat, 19 Nov 2016 20:10:01 +0000 (23:10 +0300)]
prctl: implement decoding of PR_SET_FP_MODE and PR_GET_FP_MODE options

* xlat/pr_fp_mode.in: New file.
* prctl.c: Include "xlat/pr_fp_mode.h".
(SYS_FUNC(prctl)): Add handling for PR_SET_FP_MODE and PR_GET_FP_MODE
options.

7 years agoprctl: add braces for conditional blocks with else/else-if blocks having braces
Eugene Syromyatnikov [Fri, 18 Nov 2016 18:00:02 +0000 (21:00 +0300)]
prctl: add braces for conditional blocks with else/else-if blocks having braces

7 years agoprctl: cast arg2 to int in PR_SET_PTRACER handler
Eugene Syromyatnikov [Fri, 18 Nov 2016 17:36:21 +0000 (20:36 +0300)]
prctl: cast arg2 to int in PR_SET_PTRACER handler

Kernel code does this when compares it with -1 (apart from comparing it with
PR_SET_PTRACER_ANY, which is also -1) in security/yama/yama_lsm.c.

* prctl.c (SYS_FUNC(prctl)) <PR_SET_PTRACER>: Cast arg2 to int before
comparing it with -1.

7 years agoprctl: use getarg_ull for option value retrieval
Eugene Syromyatnikov [Fri, 18 Nov 2016 17:25:13 +0000 (20:25 +0300)]
prctl: use getarg_ull for option value retrieval

The prctl syscall does not use compat on x32/n32, so argument types
are in fact kernel_ulong_t.

* prctl.c (print_prctl_args): Use getarg_ull, print as "%#llx" instead
of "%#lx".
(SYS_FUNC(prctl)): Use getarg_ull to store call arguments in arg2, arg3,
arg4, arg5 variables of type unsigned long long.  Use them in printing
routines.
(SYS_FUNC(arch_prctl)): Use getarg_ull to store call argument in addr
variable of type unsigned long long.  Print it as "%#llx" instead of
"%#lx".

7 years agoblock: add some definitions from <linux/blkpg.h>
Eugene Syromyatnikov [Sun, 13 Nov 2016 16:00:27 +0000 (19:00 +0300)]
block: add some definitions from <linux/blkpg.h>

This is done in order to fix build error on old distributions where
struct blkpg_ioctl_arg declaration is broken:

In file included from block.c:35:
/usr/include/linux/blkpg.h:36: error: expected ':', ',', ';', '}' or '__attribute__' before '*' token
block.c: In function 'print_blkpg_req':
block.c:113: error: 'struct_blkpg_ioctl_arg' has no member named 'data'

(from SLE10)

* block.c: Include <linux/ioctl.h> instead of <linux/blkpg.h>.
(BLKPG, BLKPG_DEVNAMELTH, BLKPG_VOLNAMELTH): New macros.
(struct_blkpg_ioctl_arg, struct_blkpg_partition): New definitions,
copied from blkpg_ioctl_arg and blkpg_partition structures defined
in <linux/blkpg.h>.

7 years agoxlat: add values to new ARCH_* constants
Eugene Syromyatnikov [Sat, 19 Nov 2016 00:36:22 +0000 (03:36 +0300)]
xlat: add values to new ARCH_* constants

Since UAPI header declares them under CONFIG_CHECKPOINT_RESTORE
and they would never be defined in user space.

* xlat/archvals.in: Add numeric values to ARCH_MAP_VDSO_* constants.

7 years agoprctl: include <linux/prctl.h> instead of <sys/prctl.h>
Dmitry V. Levin [Sun, 20 Nov 2016 02:00:35 +0000 (02:00 +0000)]
prctl: include <linux/prctl.h> instead of <sys/prctl.h>

There are no users of prctl function in prctl.c, and all the rest
is provided by <linux/prctl.h> anyway.

* prctl.c: Include <linux/prctl.h> instead of <sys/prctl.h>.

7 years agotests: check decoding of prctl PR_GET_NAME/PR_SET_NAME operations
Dmitry V. Levin [Sat, 19 Nov 2016 23:25:54 +0000 (23:25 +0000)]
tests: check decoding of prctl PR_GET_NAME/PR_SET_NAME operations

* tests/prctl-name.c: New file.
* tests/prctl-name.test: New test.
* tests/.gitignore: Add prctl-name.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add prctl-name.test.

7 years agoprctl: fix printing of PR_SET_NAME's argument
Dmitry V. Levin [Sun, 20 Nov 2016 00:38:34 +0000 (00:38 +0000)]
prctl: fix printing of PR_SET_NAME's argument

* prctl.c (SYS_FUNC(prctl)): Use printstr_ex with QUOTE_0_TERMINATED
instead of printstr to print the argument of PR_SET_NAME and PR_GET_NAME
operations.

7 years agoprintstr_ex: fix handling of last byte when QUOTE_0_TERMINATED bit set
Dmitry V. Levin [Sun, 20 Nov 2016 00:29:46 +0000 (00:29 +0000)]
printstr_ex: fix handling of last byte when QUOTE_0_TERMINATED bit set

* util.c (printstr_ex): Simplify handling of size == 0 case.
Do not artificially decrement size when QUOTE_0_TERMINATED bit is set.
Ensure that str[size] byte is non-zero if it hasn't been fetched.

7 years agoprintstr_ex: handle QUOTE_0_TERMINATED bit consistently
Dmitry V. Levin [Sat, 19 Nov 2016 21:01:03 +0000 (21:01 +0000)]
printstr_ex: handle QUOTE_0_TERMINATED bit consistently

When user_style has QUOTE_0_TERMINATED bit set, printstr_ex prints
the fetched string as a NUL-terminated.
After this change, the string is being fetched as a NUL-terminated, too.

* util.c (printstr_ex): Use umovestr instead of umoven
if QUOTE_0_TERMINATED bit is set.

7 years agoCleanup fetch part of printstr_ex
Dmitry V. Levin [Sat, 19 Nov 2016 16:33:37 +0000 (16:33 +0000)]
Cleanup fetch part of printstr_ex

* util.c (printstr_ex): Initialize "style" early, unify error handling.

7 years agoUpdate prctl ARCH_* constants
Dmitry V. Levin [Fri, 18 Nov 2016 13:32:39 +0000 (13:32 +0000)]
Update prctl ARCH_* constants

* xlat/archvals.in: Add ARCH_MAP_VDSO_X32, ARCH_MAP_VDSO_32, and
ARCH_MAP_VDSO_64 introduced by linux kernel commit v4.9-rc1~155^2~6.

7 years agoUpdate V4L2_* constants
Dmitry V. Levin [Fri, 18 Nov 2016 13:23:03 +0000 (13:23 +0000)]
Update V4L2_* constants

* xlat/v4l2_device_capabilities_flags.in: Add V4L2_CAP_TOUCH introduced
by linux kernel commit v4.9-rc4~7^2~422.
* xlat/v4l2_input_types.in: Add V4L2_CAP_TOUCH introduced
by linux kernel commit v4.9-rc4~7^2~422.

7 years agoUpdate fs *_MAGIC constants
Dmitry V. Levin [Fri, 18 Nov 2016 13:17:22 +0000 (13:17 +0000)]
Update fs *_MAGIC constants

* xlat/fsmagic.in: Add DAXFS_MAGIC introduced by linux kernel commit
v4.9-rc1~45^2^2~5.

7 years agoUpdate MS_* constants
Dmitry V. Levin [Fri, 18 Nov 2016 13:13:31 +0000 (13:13 +0000)]
Update MS_* constants

* xlat/mount_flags.in: Add MS_NOREMOTELOCK introduced
by linux kernel commit v4.9-rc1~57^2~1^2~7.

7 years agoUpdate FALLOC_* constants
Dmitry V. Levin [Fri, 18 Nov 2016 13:11:04 +0000 (13:11 +0000)]
Update FALLOC_* constants

* xlat/falloc_flags.in: Add FALLOC_FL_UNSHARE_RANGE introduced
by linux kernel commit v4.9-rc1~31^2~69.

7 years agoUpdate BTRFS_* constants
Dmitry V. Levin [Fri, 18 Nov 2016 13:08:27 +0000 (13:08 +0000)]
Update BTRFS_* constants

* xlat/btrfs_features_compat_ro.in: Add
BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID introduced
by linux kernel commit v4.9-rc1~7^2^2~4.

7 years agoUpdate BPF_* constants
Dmitry V. Levin [Fri, 18 Nov 2016 13:05:23 +0000 (13:05 +0000)]
Update BPF_* constants

* xlat/bpf_prog_types.in: Add BPF_PROG_TYPE_PERF_EVENT introduced
by linux kernel commit v4.9-rc1~127^2~302^2~4.

7 years agomake-dist: use HEAD for making distribution package
Eugene Syromyatnikov [Thu, 27 Oct 2016 20:43:36 +0000 (23:43 +0300)]
make-dist: use HEAD for making distribution package

* make-dist: Use HEAD commit instead of master branch by default.

7 years agotests: fix btrfs build error on some old systems
Dmitry V. Levin [Fri, 18 Nov 2016 00:51:37 +0000 (00:51 +0000)]
tests: fix btrfs build error on some old systems

Fix the following build error on SLE 11 SP4:

btrfs.c: In function 'btrfs_test_dev_replace_ioctl':
btrfs.c:1570: error: unknown field 'start' specified in initializer

* tests/btrfs.c (btrfs_test_dev_replace_ioctl): Move initialization
of struct btrfs_ioctl_dev_replace_args.start.srcdevid out of the
designated initializer.

7 years agotests: check decoding of ERESTARTSYS error code
Dmitry V. Levin [Fri, 18 Nov 2016 00:28:29 +0000 (00:28 +0000)]
tests: check decoding of ERESTARTSYS error code

* tests/erestartsys.c: New file.
* tests/erestartsys.test: New test.
* tests/.gitignore: Add erestartsys.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add erestartsys.test.

7 years agoFix signame usage in qual_signal
Dmitry V. Levin [Fri, 18 Nov 2016 00:11:39 +0000 (00:11 +0000)]
Fix signame usage in qual_signal

Do not assume that the string returned by signame starts with "SIG"
prefix, this is not always the case.

* syscall.c (qual_signal): Skip signame return value
when it does not have "SIG" prefix.

7 years agotests: check -e signal=set syntax
Dmitry V. Levin [Fri, 18 Nov 2016 00:11:27 +0000 (00:11 +0000)]
tests: check -e signal=set syntax

* tests/qual_signal.c: New file.
* tests/qual_signal.test: New test.
* tests/.gitignore: Add qual_signal.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add qual_signal.test.

7 years agoMake -e fault= expressions cumulative
Dmitry V. Levin [Thu, 17 Nov 2016 15:44:21 +0000 (15:44 +0000)]
Make -e fault= expressions cumulative

Change the way how subsequent -e fault= expressions are interpreted
to implement a cumulative behavior.  For example,
-e fault=file:when=3+ -e fault=chdir
now specifies that all chdir syscalls and 3+ file related syscalls
except chdir are subject for fault injection.

* syscall.c (qualify): Do not reset qual_vec for QUAL_FAULT.
* tests/fault_injection.test: Check it.

7 years agotests: check syscall fault injection
Dmitry V. Levin [Wed, 16 Nov 2016 17:27:46 +0000 (17:27 +0000)]
tests: check syscall fault injection

* tests/fault_injection.c: New file.
* tests/fault_injection.test: New test.
* tests/fault_syntax.test: Likewise.
* tests/.gitignore: Add fault_injection.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add fault_injection.test and fault_syntax.test.

7 years agoImplement syscall fault injection
Dmitry V. Levin [Wed, 16 Nov 2016 17:26:58 +0000 (17:26 +0000)]
Implement syscall fault injection

Introduce new -e fault=EXPR syntax that can be used to specify a subset
of syscalls that are subject of syscall fault injection, an error code
that has to be injected, and a frequency of injection.

The expression specifying syscall fault injection has the following
format: SET[:error=ERRNO][:when=FIRST[+[STEP]]]
where only SET is a required part and all the rest is optional.

The method used to implement syscall fault injection is the following:
on entering syscall the syscall number is substituted by an invalid
syscall number -1, and on exiting syscall the error code returned by
the kernel is substituted with the error code specified in the fault
expression.

This implementaion is based on the prototype developed
by Nahim El Atmani as a part of his GSoC 2016 strace project.

* defs.h (struct fault_opts): New forward declaration.
(struct tcb): Add fault_vec field.
(TCB_FAULT_INJ, QUAL_FAULT): New macros.
* strace.1: Document -e fault expression syntax.
* strace.c (usage): Mention -e fault expression.
(droptcb): Deallocate fault_vec member.
* syscall.c (qual_fault, arch_set_scno, arch_set_error): New prototypes.
(qual_options): Add "fault" option.
(struct fault_opts): New structure.
(num_faults): New variable.
(fault_vec): New array.
(syscall_fault_injected, tcb_fault_opts, reallocate_fault,
find_errno_by_name, qual_syscall_ex, strip_prefix, parse_fault_token,
parse_fault_expression, qual_fault, inject_syscall_fault_entering,
update_syscall_fault_exiting): New functions.
(qual_syscall): Use qual_syscall_ex.
(qualify_one): Add argument: a pointer to struct fault_opts, all callers
changed.  Copy struct fault_opts from the pointer to fault_vec.
Use reallocate_fault.
(qualify_scno, qualify_syscall_class, qualify_syscall_name): Add
argument: a pointer to struct fault_opts.
(qualify): Use reallocate_fault.  Do not check "all" class for
QUAL_FAULT qualifier.
(lookup_class): Check for "all" class.
(trace_syscall_entering): Use inject_syscall_fault_entering.
(trace_syscall_exiting): Use update_syscall_fault_exiting.  Clear
TCB_FAULT_INJ flag along with TCB_INSYSCALL.  Print " (INJECTED)" suffix
when the syscall has been injected successfully.
[ARCH_REGS_FOR_GETREGSET && !HAVE_GETREGS_OLD]
(ptrace_setregset): New function.
(ptrace_setregset_or_setregs): Define to ptrace_setregset.
[ARCH_REGS_FOR_GETREGS && !HAVE_GETREGS_OLD]
(ptrace_setregs): New function.
(ptrace_setregset_or_setregs): Define to ptrace_setregs.
[ptrace_setregset_or_setregs] (set_regs): New function.
Include "set_scno.c" and "set_error.c"
* NEWS: Mention this enhancement.

7 years agoImplement arch specific methods of changing syscall number and error code
Dmitry V. Levin [Tue, 15 Nov 2016 17:38:21 +0000 (17:38 +0000)]
Implement arch specific methods of changing syscall number and error code

This introduces arch_set_error and arch_set_scno functions for each
supported architecture, needed to implement syscall fault injection.

* linux/aarch64/set_error.c: New file.
* linux/aarch64/set_scno.c: Likewise.
* linux/alpha/set_error.c: Likewise.
* linux/alpha/set_scno.c: Likewise.
* linux/arc/set_error.c: Likewise.
* linux/arc/set_scno.c: Likewise.
* linux/arm/set_error.c: Likewise.
* linux/arm/set_scno.c: Likewise.
* linux/avr32/set_error.c: Likewise.
* linux/avr32/set_scno.c: Likewise.
* linux/bfin/set_error.c: Likewise.
* linux/bfin/set_scno.c: Likewise.
* linux/crisv10/set_error.c: Likewise.
* linux/crisv10/set_scno.c: Likewise.
* linux/crisv32/set_error.c: Likewise.
* linux/crisv32/set_scno.c: Likewise.
* linux/hppa/set_error.c: Likewise.
* linux/hppa/set_scno.c: Likewise.
* linux/i386/set_error.c: Likewise.
* linux/i386/set_scno.c: Likewise.
* linux/ia64/set_error.c: Likewise.
* linux/ia64/set_scno.c: Likewise.
* linux/m68k/set_error.c: Likewise.
* linux/m68k/set_scno.c: Likewise.
* linux/metag/set_error.c: Likewise.
* linux/metag/set_scno.c: Likewise.
* linux/microblaze/set_error.c: Likewise.
* linux/microblaze/set_scno.c: Likewise.
* linux/mips/set_error.c: Likewise.
* linux/mips/set_scno.c: Likewise.
* linux/nios2/set_error.c: Likewise.
* linux/nios2/set_scno.c: Likewise.
* linux/or1k/set_error.c: Likewise.
* linux/or1k/set_scno.c: Likewise.
* linux/powerpc/set_error.c: Likewise.
* linux/powerpc/set_scno.c: Likewise.
* linux/powerpc64/set_error.c: Likewise.
* linux/powerpc64/set_scno.c: Likewise.
* linux/riscv/set_error.c: Likewise.
* linux/riscv/set_scno.c: Likewise.
* linux/s390/set_error.c: Likewise.
* linux/s390/set_scno.c: Likewise.
* linux/s390x/set_error.c: Likewise.
* linux/s390x/set_scno.c: Likewise.
* linux/sh/set_error.c: Likewise.
* linux/sh/set_scno.c: Likewise.
* linux/sh64/set_error.c: Likewise.
* linux/sh64/set_scno.c: Likewise.
* linux/sparc/set_error.c: Likewise.
* linux/sparc/set_scno.c: Likewise.
* linux/sparc64/set_error.c: Likewise.
* linux/sparc64/set_scno.c: Likewise.
* linux/tile/set_error.c: Likewise.
* linux/tile/set_scno.c: Likewise.
* linux/x32/set_error.c: Likewise.
* linux/x32/set_scno.c: Likewise.
* linux/x86_64/set_error.c: Likewise.
* linux/x86_64/set_scno.c: Likewise.
* linux/xtensa/set_error.c: Likewise.
* linux/xtensa/set_scno.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.

7 years agocris: add syscall tables
Dmitry V. Levin [Wed, 16 Nov 2016 02:25:47 +0000 (02:25 +0000)]
cris: add syscall tables

The incomplete CRIS support introduced by commit v4.5.18-77-gea0e6e8
should not have been merged because it lacks essential parts, e.g.
syscall tables.

This change adds missing syscall tables for crisv10 and crisv32.

* linux/crisv10/syscallent.h: New file.
* linux/crisv32/syscallent.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.

7 years agoIntroduce string_to_uint_ex and string_to_uint_upto functions
Dmitry V. Levin [Wed, 16 Nov 2016 00:58:05 +0000 (00:58 +0000)]
Introduce string_to_uint_ex and string_to_uint_upto functions

* defs.h (string_to_uint_ex): New prototype.
(string_to_uint_upto): New function, a thin wrapper around
string_to_uint_ex.
* util.c (string_to_uint_ex): New function.
(string_to_uint): Change into a thin wrapper around string_to_uint_upto.
* strace.c (init): Use string_to_uint_upto.
* syscall.c (qualify_scno, qual_signal, qual_desc): Use
string_to_uint_upto instead of string_to_uint.

7 years agoSplit qual_syscall into separate functions
Dmitry V. Levin [Tue, 15 Nov 2016 22:57:33 +0000 (22:57 +0000)]
Split qual_syscall into separate functions

Split qual_syscall into qualify_scno, qualify_syscall_class,
and qualify_syscall_name.
This might be needed later to implement syscall fault injection.

* syscall.c (qualify_scno, qualify_syscall_class, qualify_syscall_name):
New functions.
(qual_syscall): Use them.

7 years agoxtensa: wire up new syscalls
Dmitry V. Levin [Tue, 15 Nov 2016 01:09:51 +0000 (01:09 +0000)]
xtensa: wire up new syscalls

* linux/xtensa/syscallent.h [342..347]: New entries.

7 years agoarc: wire up new syscalls
Dmitry V. Levin [Mon, 14 Nov 2016 01:07:59 +0000 (01:07 +0000)]
arc: wire up new syscalls

* linux/arc/syscallent.h [247, 248]: New entries.

7 years agotests: fix potential compilation warning in ioctl_block.c
Dmitry V. Levin [Sun, 13 Nov 2016 22:29:30 +0000 (22:29 +0000)]
tests: fix potential compilation warning in ioctl_block.c

ioctl_block.c:48: warning: 'init_magic' defined but not used

* tests/ioctl_block.c (init_magic): Define only for
[BLKTRACESETUP && HAVE_STRUCT_BLK_USER_TRACE_SETUP].

7 years agoAdd support for pkey_mprotect, pkey_alloc, pkey_free syscalls
Eugene Syromyatnikov [Sat, 12 Nov 2016 17:54:56 +0000 (20:54 +0300)]
Add support for pkey_mprotect, pkey_alloc, pkey_free syscalls

* linux/32/syscallent.h: Add syscall entries for pkey_* calls.
* linux/64/syscallent.h: Likewise.
* linux/arm/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/mips/syscallent-n32.h: Likewise.
* linux/mips/syscallent-n64.h: Likewise.
* linux/mips/syscallent-o32.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* mem.c (do_mprotect): New function, common handler for mprotect and
pkey_mprotect.
(SYS_FUNC(mprotect)): Convert to wrapper around do_mprotect.
(SYS_FUNC(pkey_mprotect)): New function.
* xlat/pkey_access.in: New file.
* pkeys.c: New file containing implementation of pkey_alloc and
pkey_free.
* Makefile.am: Add it.
* NEWS: Mention this enhancement.
* tests/.gitignore: Add pkey_alloc, pkey_free, and pkey_mprotect.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add pkey_alloc.test, pkey_free.test, and
pkey_mprotect.test.
* tests/pkey_alloc.c: New file.
* tests/pkey_free.c: Likewise.
* tests/pkey_mprotect.c: Likewise.
* tests/pkey_alloc.test: New test.
* tests/pkey_free.test: Likewise.
* tests/pkey_mprotect.test: Likewise.

7 years agotests: fix "constant is too large" compilation warnings
Eugene Syromyatnikov [Sun, 13 Nov 2016 16:14:46 +0000 (19:14 +0300)]
tests: fix "constant is too large" compilation warnings

alarm.c: In function 'main':
alarm.c:41: warning: integer constant is too large for 'long' type
aio.c: In function 'main':
aio.c:162: warning: integer constant is too large for 'long' type
btrfs.c: In function 'btrfs_test_sync_ioctls':
btrfs.c:202: warning: integer constant is too large for 'long' type
btrfs.c: In function 'btrfs_test_subvol_ioctls':
btrfs.c:289: warning: integer constant is too large for 'long' type
btrfs.c:290: warning: integer constant is too large for 'long' type
dup2.c: In function 'main':
dup2.c:12: warning: integer constant is too large for 'long' type
dup2.c:13: warning: integer constant is too large for 'long' type
dup3.c: In function 'main':
dup3.c:13: warning: integer constant is too large for 'long' type
dup3.c:14: warning: integer constant is too large for 'long' type
epoll_create.c: In function 'main':
epoll_create.c:12: warning: integer constant is too large for 'long' type
epoll_ctl.c: In function 'invoke_syscall':
epoll_ctl.c:14: warning: integer constant is too large for 'long' type
faccessat.c: In function 'main':
faccessat.c:13: warning: integer constant is too large for 'long' type
fchdir.c: In function 'main':
fchdir.c:12: warning: integer constant is too large for 'long' type
struct_flock.c: In function 'invoke_test_syscall':
struct_flock.c:48: warning: integer constant is too large for 'long' type
struct_flock.c: In function 'test_flock_einval':
struct_flock.c:58: warning: integer constant is too large for 'long' type
struct_flock.c:59: warning: integer constant is too large for 'long' type
fcntl64.c: In function 'test_flock64_einval':
fcntl64.c:44: warning: integer constant is too large for 'long' type
fcntl64.c:45: warning: integer constant is too large for 'long' type
fcntl.c: In function 'test_flock64_einval':
fcntl.c:44: warning: integer constant is too large for 'long' type
fcntl.c:45: warning: integer constant is too large for 'long' type
fdatasync.c: In function 'main':
fdatasync.c:12: warning: integer constant is too large for 'long' type
flock.c: In function 'main':
flock.c:13: warning: integer constant is too large for 'long' type
xstatx.c: In function 'main':
xstatx.c:255: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatfsx.c: In function 'main':
xstatfsx.c:113: warning: integer constant is too large for 'long' type
fsync.c: In function 'main':
fsync.c:12: warning: integer constant is too large for 'long' type
ftruncate64.c: In function 'main':
ftruncate64.c:39: warning: integer constant is too large for 'long' type
futimesat.c: In function 'main':
futimesat.c:52: warning: integer constant is too large for 'long' type
futimesat.c:59: warning: integer constant is too large for 'long' type
get_mempolicy.c: In function 'main':
get_mempolicy.c:83: warning: integer constant is too large for 'long' type
get_mempolicy.c:84: warning: integer constant is too large for 'long' type
get_mempolicy.c:85: warning: integer constant is too large for 'long' type
get_mempolicy.c:86: warning: integer constant is too large for 'long' type
getdents.c: In function 'main':
getdents.c:109: warning: integer constant is too large for 'long' type
getdents.c:110: warning: integer constant is too large for 'long' type
getdents.c:114: warning: integer constant is too large for 'long' type
getdents64.c: In function 'main':
getdents64.c:114: warning: integer constant is too large for 'long' type
getdents64.c:115: warning: integer constant is too large for 'long' type
getdents64.c:119: warning: integer constant is too large for 'long' type
xgetrlimit.c: In function 'main':
xgetrlimit.c:71: warning: integer constant is too large for 'long' type
ioctl_block.c:44: warning: integer constant is too large for 'long' type
ioctl_block.c: In function 'main':
ioctl_block.c:136: warning: integer constant is too large for 'long' type
ioctl_block.c:137: warning: integer constant is too large for 'long' type
ioctl_block.c:161: warning: integer constant is too large for 'long' type
ioctl_block.c:170: warning: integer constant is too large for 'long' type
ioctl_block.c:171: warning: integer constant is too large for 'long' type
ioctl_evdev.c:42: warning: integer constant is too large for 'long' type
ioctl_mtd.c:46: warning: integer constant is too large for 'long' type
ioctl_rtc.c:40: warning: integer constant is too large for 'long' type
ioperm.c: In function 'main':
ioperm.c:12: warning: integer constant is too large for 'long' type
ioctl_v4l2.c: In function 'main':
ioctl_v4l2.c:409: warning: integer constant is too large for 'long' type
ipc.c: In function 'ipc_call':
ipc.c:52: warning: integer constant is too large for 'long' type
kill.c: In function 'main':
kill.c:59: warning: integer constant is too large for 'long' type
kill.c:62: warning: integer constant is too large for 'long' type
kill.c:63: warning: integer constant is too large for 'long' type
kill.c:68: warning: integer constant is too large for 'long' type
linkat.c: In function 'main':
linkat.c:14: warning: integer constant is too large for 'long' type
linkat.c:15: warning: integer constant is too large for 'long' type
mbind.c: In function 'main':
mbind.c:41: warning: integer constant is too large for 'long' type
mbind.c:43: warning: integer constant is too large for 'long' type
mbind.c:44: warning: integer constant is too large for 'long' type
migrate_pages.c: In function 'main':
migrate_pages.c:41: warning: integer constant is too large for 'long' type
In file included from mkdirat.c:10:
umode_t.c: In function 'test_syscall':
umode_t.c:47: warning: integer constant is too large for 'long' type
mknod.c: In function 'call_mknod':
mknod.c:16: warning: integer constant is too large for 'long' type
mknod.c: In function 'main':
mknod.c:23: warning: integer constant is too large for 'long' type
mknod.c:49: warning: integer constant is too large for 'long' type
mknod.c:56: warning: integer constant is too large for 'long' type
mknodat.c:12: warning: integer constant is too large for 'long' type
mknodat.c: In function 'call_mknodat':
mknodat.c:17: warning: integer constant is too large for 'long' type
mknodat.c: In function 'main':
mknodat.c:24: warning: integer constant is too large for 'long' type
mknodat.c:50: warning: integer constant is too large for 'long' type
mknodat.c:57: warning: integer constant is too large for 'long' type
mmap.c: In function 'main':
mmap.c:51: warning: integer constant is too large for 'long' type
move_pages.c: In function 'print_stat_pages':
move_pages.c:139: warning: integer constant is too large for 'long' type
move_pages.c: In function 'print_move_pages':
move_pages.c:166: warning: integer constant is too large for 'long' type
move_pages.c: In function 'main':
move_pages.c:188: warning: integer constant is too large for 'long' type
mq_sendrecv.c: In function 'main':
mq_sendrecv.c:238: warning: integer constant is too large for 'long' type
mq_sendrecv.c:401: warning: integer constant is too large for 'long' type
mq_sendrecv.c:403: warning: integer constant is too large for 'long' type
nsyscalls.c: In function 'test_syscall':
nsyscalls.c:64: warning: integer constant is too large for 'long' type
nsyscalls.c:65: warning: integer constant is too large for 'long' type
nsyscalls.c:66: warning: integer constant is too large for 'long' type
nsyscalls.c:67: warning: integer constant is too large for 'long' type
nsyscalls.c:68: warning: integer constant is too large for 'long' type
nsyscalls.c:69: warning: integer constant is too large for 'long' type
preadv-pwritev.c: In function 'main':
preadv-pwritev.c:162: warning: comparison between signed and unsigned
prlimit64.c: In function 'main':
prlimit64.c:65: warning: integer constant is too large for 'long' type
prlimit64.c:70: warning: integer constant is too large for 'long' type
remap_file_pages.c: In function 'main':
remap_file_pages.c:42: warning: integer constant is too large for 'long' type
remap_file_pages.c:43: warning: integer constant is too large for 'long' type
remap_file_pages.c:45: warning: integer constant is too large for 'long' type
renameat.c: In function 'main':
renameat.c:15: warning: integer constant is too large for 'long' type
renameat.c:16: warning: integer constant is too large for 'long' type
rt_sigqueueinfo.c: In function 'main':
rt_sigqueueinfo.c:41: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c: In function 'k_tgsigqueueinfo':
rt_tgsigqueueinfo.c:45: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c:46: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c:47: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c: In function 'main':
rt_tgsigqueueinfo.c:67: warning: integer constant is too large for 'long' type
sendfile.c: In function 'main':
sendfile.c:110: warning: integer constant is too large for 'long' type
sendfile64.c: In function 'main':
sendfile64.c:100: warning: integer constant is too large for 'long' type
set_mempolicy.c: In function 'main':
set_mempolicy.c:129: warning: integer constant is too large for 'long' type
set_mempolicy.c:130: warning: integer constant is too large for 'long' type
setrlimit.c: In function 'main':
setrlimit.c:44: warning: integer constant is too large for 'long' type
socketcall.c: In function 'test_socketcall':
socketcall.c:58: warning: integer constant is too large for 'long' type
splice.c: In function 'main':
splice.c:41: warning: integer constant is too large for 'long' type
splice.c:42: warning: integer constant is too large for 'long' type
splice.c:45: warning: integer constant is too large for 'long' type
splice.c:46: warning: integer constant is too large for 'long' type
symlinkat.c: In function 'main':
symlinkat.c:12: warning: integer constant is too large for 'long' type
sync_file_range.c: In function 'main':
sync_file_range.c:42: warning: integer constant is too large for 'long' type
sync_file_range.c:43: warning: integer constant is too large for 'long' type
syslog.c: In function 'main':
syslog.c:14: warning: integer constant is too large for 'long' type
tee.c: In function 'main':
tee.c:41: warning: integer constant is too large for 'long' type
tee.c:42: warning: integer constant is too large for 'long' type
timer_create.c: In function 'main':
timer_create.c:52: warning: integer constant is too large for 'long' type
timer_create.c:84: warning: integer constant is too large for 'long' type
timer_create.c:85: warning: integer constant is too large for 'long' type
truncate64.c: In function 'main':
truncate64.c:41: warning: integer constant is too large for 'long' type
xgetrlimit.c: In function 'main':
xgetrlimit.c:71: warning: integer constant is too large for 'long' type
umode_t.c: In function 'test_syscall':
umode_t.c:46: warning: integer constant is too large for 'long' type
unlinkat.c: In function 'main':
unlinkat.c:13: warning: integer constant is too large for 'long' type
waitpid.c: In function 'main':
waitpid.c:43: warning: integer constant is too large for 'long' type
waitid.c: In function 'poison':
waitid.c:141: warning: integer constant is too large for 'long' type
xetpriority.c: In function 'main':
xetpriority.c:15: warning: integer constant is too large for 'long' type
xetpriority.c:19: warning: integer constant is too large for 'long' type
xetpriority.c:20: warning: integer constant is too large for 'long' type
xetpgid.c: In function 'main':
xetpgid.c:43: warning: integer constant is too large for 'long' type
xetpgid.c:47: warning: integer constant is too large for 'long' type
xetpgid.c:48: warning: integer constant is too large for 'long' type

(SLES 11SP4, i386)

* tests/alarm.c (main): Add proper suffix to integer constant.
* tests/aio.c (main): Likewise.
* tests/btrfs.c (btrfs_test_sync_ioctls, btrfs_test_subvol_ioctls): Likewise.
* tests/dup2.c (main): Likewise.
* tests/dup3.c (main): Likewise.
* tests/epoll_create.c (main): Likewise.
* tests/epoll_ctl.c (invoke_syscall): Likewise.
* tests/faccessat.c (main): Likewise.
* tests/fchdir.c (main): Likewise.
* tests/fcntl.c (test_flock64_einval): Likewise.
* tests/fcntl64.c (test_flock64_einval): Likewise.
* tests/fdatasync.c (main): Likewise.
* tests/flock.c (main): Likewise.
* tests/fstat64.c (SAMPLE_SIZE): Likewise.
* tests/fstat.c (SAMPLE_SIZE): Likewise.
* tests/fsync.c (main): Likewise.
* tests/ftruncate64.c (main): Likewise.
* tests/futimesat.c (main): Likewise.
* tests/get_mempolicy.c (main): Likewise.
* tests/getdents.c (main): Likewise.
* tests/getdents64.c (main): Likewise.
* tests/ioctl_block.c (lmagic, main): Likewise.
* tests/ioctl_evdev.c (lmagic): Likewise.
* tests/ioctl_mtd.c (lmagic): Likewise.
* tests/ioctl_rtc.c (lmagic): Likewise.
* tests/ioctl_v4l2.c (main): Likewise.
* tests/ioperm.c (main): Likewise.
* tests/ipc.c (ipc_call): Likewise.
* tests/kill.c (main): Likewise.
* tests/linkat.c (main): Likewise.
* tests/lstat64.c (SAMPLE_SIZE): Likewise.
* tests/lstat.c (SAMPLE_SIZE): Likewise.
* tests/mbind.c (main): Likewise.
* tests/migrate_pages.c (main): Likewise.
* tests/mkdirat.c (TEST_SYSCALL_PREFIX_ARGS): Likewise.
* tests/mknod.c (call_mknod, main): Likewise.
* tests/mknodat.c (fd, call_mknodat, main): Likewise.
* tests/mmap.c (main): Likewise.
* tests/move_pages.c (print_stat_pages, print_move_pages): Likewise.
* tests/mq_sendrecv.c (main): Likewise.
* tests/nsyscalls.c (test_syscall): Likewise.
* tests/prlimit64.c (main): Likewise.
* tests/remap_file_pages.c (main): Likewise.
* tests/renameat.c (main): Likewise.
* tests/rt_sigqueueinfo.c (main): Likewise.
* tests/rt_tgsigqueueinfo.c (k_tgsigqueueinfo, main): Likewise.
* tests/sendfile.c (main): Likewise.
* tests/sendfile64.c (main): Likewise.
* tests/set_mempolicy.c (main): Likewise.
* tests/setrlimit.c (main): Likewise.
* tests/socketcall.c (test_socketcall): Likewise.
* tests/splice.c (main): Likewise.
* tests/stat64.c (SAMPLE_SIZE): Likewise.
* tests/stat.c (SAMPLE_SIZE): Likewise.
* tests/struct_flock.c (invoke_test_syscall, test_flock_einval): Likewise.
* tests/symlinkat.c (main): Likewise.
* tests/sync_file_range.c (main): Likewise.
* tests/syslog.c (main): Likewise.
* tests/tee.c (main): Likewise.
* tests/timer_create.c (main): Likewise.
* tests/truncate64.c (main): Likewise.
* tests/umode_t.c (test_syscall): Likewise.
* tests/unlinkat.c (main): Likewise.
* tests/waitid.c (main): Likewise.
* tests/waitpid.c (main): Likewise.
* tests/xetpgid.c (main): Likewise.
* tests/xetpriority.c (main): Likewise.
* tests/xgetrlimit.c (main): Likewise.
* tests/xstatfsx.c (main) [CHECK_ODD_SIZE]: Likewise.
* tests/xstatx.c (main): Likewise.

7 years agotests: fix "comparison between signed and unsigned" compilation warnings
Eugene Syromyatnikov [Sun, 13 Nov 2016 18:30:25 +0000 (21:30 +0300)]
tests: fix "comparison between signed and unsigned" compilation warnings

preadv-pwritev.c: In function 'main':
preadv-pwritev.c:162: warning: comparison between signed and unsigned
readv.c: In function 'main':
readv.c:148: warning: comparison between signed and unsigned
recvmsg.c: In function 'main':
recvmsg.c:148: warning: comparison between signed and unsigned

* tests/preadv-pwritev.c (main): Cast r_len to int.
* tests/readv.c (main): Likewise.
* tests/recvmsg.c (main): Likewise.