Commit Graph

19 Commits

Author SHA1 Message Date
c5f6863a18 Fix printing of invalid arguments of prctl syscall
* prctl.c (SYS_FUNC(prctl)): Print 2nd syscall argument
of PR_CAPBSET_DROP, PR_CAPBSET_READ, PR_CAP_AMBIENT, PR_MCE_KILL,
and PR_SET_SECCOMP using printxval_long.
Print 2nd syscall argument of PR_SET_SECUREBITS using printflags_long.
Print 3rd syscall argument of PR_CAP_AMBIENT and PR_MCE_KILL using
printxval_long.
* tests/prctl-seccomp-strict.c (main): Update.
2016-05-16 23:50:59 +00:00
b8eec608fa Fix decoding of prctl/arch_prctl operation argument
Consistently treat operation argument of prctl/arch_prctl syscalls
as int to match the kernel behaviour.

* prctl.c (SYS_FUNC(prctl), SYS_FUNC(arch_prctl)): Assign 1st argument
of syscalls to a variable of type unsigned int and use it in all
subsequent checks and lookups.
2016-05-16 22:41:20 +00:00
6274ecc752 Prepare for transition from sprintflags64 to sprintflags
* fcntl.c (print_fcntl): Cast 3rd argument of sprintflags
to unsigned long.
* membarrier.c (SYS_FUNC(membarrier)): Likewise.
* prctl.c (SYS_FUNC(prctl)): Likewise.
* poll.c (decode_poll_exiting): Cast 3rd argument of sprintflags
to unsigned short.
2016-05-15 14:23:06 +00:00
9134aab407 Prepare for transition from xlookup64 to xlookup
* fcntl.c (print_fcntl, SYS_FUNC(fcntl), SYS_FUNC(fcntl64)):
Cast 2nd argument of xlookup to unsigned long.
* prctl.c (SYS_FUNC(prctl)): Likewise.
* sched.c (SYS_FUNC(sched_getscheduler)): Likewise.
* time.c (do_adjtimex): Likewise.
* ioprio.c (sprint_ioprio): Change type of the argument
and local variables from int to unsigned int.
* keyctl.c (print_keyring_serial_number): Cast 2nd argument
of xlookup to unsigned int.
* net.c (tprint_sock_type): Change type of the argument to unsigned int.
* printmode.c (sprintmode): Likewise.
* printsiginfo.c (printsigval):  Change type of si_code argument
to unsigned int.
2016-05-14 22:05:06 +00:00
Elliott Hughes
612368b59e Improve decoding of Android's PR_SET_VMA prctl
Before:

  prctl(0x53564d41 /* PR_??? */, 0, 0x7f8ab53000, 4096,
        "atexit handlers") = 0

After:

  prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x7fa8cbd000, 4096,
        "atexit handlers") = 0

* prctl.c (SYS_FUNC(prctl)) [__ANDROID__]: Do not define PR_SET_VMA.
* Hard-code PR_SET_VMA_ANON_NAME, the only current sub-option.
* xlat/prctl_options.in: Add PR_SET_VMA.
2016-04-06 21:41:36 +00:00
38a34c9349 Add copyright headers to some files which lack them
Before this change, all files that exist since 20th century had
copyright headers, while most files that appeared later didn't.  This
change fixes the inconsistency by adding missing copyright headers.

It doesn't mean that copyright headers became maintained.  In my view,
git history provides much better information on this subject and is much
more accurate than copyright headers.
2015-12-17 17:56:48 +00:00
eb76c4be15 prctl: add PR_CAP_AMBIENT parser
* xlat/pr_cap_ambient.in: New file.
* prctl.c: Include "xlat/pr_cap_ambient.h".
(SYS_FUNC(prctl)): Handle PR_CAP_AMBIENT.
2015-12-06 15:33:53 +00:00
1b283307d1 prctl: finish decoding of several commands on entering syscall
* prctl.c (SYS_FUNC(prctl)): Return RVAL_DECODED after decoding of
PR_GET_DUMPABLE, PR_GET_KEEPCAPS, PR_GET_SECCOMP, PR_GET_TIMERSLACK,
PR_GET_TIMING, and PR_CAPBSET_READ commands.
2015-12-06 15:29:04 +00:00
2479ef0bce Fix printing tracee's long integers
Replace ambiguous printnum_long that used to fetch native long integers
from tracee's memory with printnum_ptr, printnum_slong, and printnum_ulong
that fetch tracee's pointer, signed long, and unsigned long integers.

* defs.h (printnum_long, printpair_long): Remove prototypes.
(printnum_int64, printpair_int64): Remove macros, declare functions
unconditionally.
[SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4] (printnum_long_int):
New prototype.
(printnum_ptr, printnum_slong, printnum_ulong): New macros.
* aio.c (sys_io_setup): Use printnum_ulong.
* block.c (block_ioctl): Use printnum_slong and printnum_ulong.
* get_robust_list.c (sys_get_robust_list): Use printnum_ptr
and printnum_ulong.
* io.c (print_off_t): Remove.
(sys_sendfile): Use printnum_ulong.
* ipc.c (sys_semctl): Use printnum_ptr.
* prctl.c (sys_prctl): Likewise.
* process.c (sys_ptrace): Likewise.
* rtc.c (rtc_ioctl): Use printnum_ulong.
* util.c (printnum_long, printpair_long): Remove.
(printnum_int64, printpair_int64): Define unconditionally.
[SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4] (printnum_long_int):
New function.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Elvira Khabirova <lineprinter0@gmail.com>
2015-08-18 16:15:33 +00:00
Elliott Hughes
1d246ce3d4 prctl: decode Android-specific PR_SET_VMA
Android kernels have a prctl to name VMAs.

* prctl.c (sys_prctl) [__ANDROID__]: Decode PR_SET_VMA.
2015-07-29 22:54:11 +00:00
3691562e7d prctl: fix decoding of unrecognized commands
The use of printargs introduced by commit v4.10-179-g210a6b6 is wrong:
when the first argument is already printed, printargs cannot be called.

* prctl.c (print_prctl_args): New function.
(sys_prctl): Use it.
2015-07-25 09:55:02 +00:00
210a6b6884 prctl.c: make use of RVAL_DECODED
* prctl.c (prctl_enter, prctl_exit): Merge into sys_prctl.
(sys_prctl, sys_arch_prctl): Update for RVAL_DECODED.
2015-07-18 00:01:40 +00:00
7c53e984ac prctl.c: use printaddr and umove_or_printaddr
* prctl.c (prctl_exit): Use printaddr and umove_or_printaddr.
2015-07-18 00:01:40 +00:00
850ba4b1e9 Change printnum_* printers to honor syserror
With this change, printnum_* printers will not attempt to fetch data
in case of exiting(tcp) && syserror(tcp).
All "at exiting" decoders that call these printers have been made
ready for this change in previous commits.

* util.c (DEF_PRINTNUM, DEF_PRINTPAIR): Use umove_or_printaddr.
* prctl.c (prctl_exit): Use printnum_int and printnum_long.
(sys_arch_prctl): Do not check for syserror.
2015-07-14 21:59:26 +00:00
a0bd3749fc Declare syscall parsers using SYS_FUNC macro
Introduce SYS_FUNC macro to declare and define all syscall parsers.

* Makefile.am (BUILT_SOURCES, CLEANFILES): Add sys_func.h.
(sys_func.h): New rule.
* defs.h (SYS_FUNC_NAME, SYS_FUNC): New macros.
* linux/syscall.h: Include "sys_func.h".
[NEED_UID16_PARSERS]: Use SYS_FUNC to declare uid16 syscall parsers.
Remove other declarations.
* linux/alpha/syscallent.h (160, 161): Add sys_ prefix to osf_statfs
and osf_fstatfs syscall parsers.
* *.c: Use SYS_FUNC to define syscall parsers.
2015-04-07 11:22:49 +00:00
1e88073053 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.
2015-02-19 01:54:38 +00:00
2af6903f45 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.
2015-02-06 01:23:05 +00:00
8224758b33 Always compile sys_prctl parser
Since sys_prctl is referenced by syscallent files unconditionally,
conditional compilation of sys_prctl depending on prctl availability is
pointless.

* prctl.c (unalignctl_string, sys_prctl): Compile unconditionally.
2014-12-11 23:32:59 +00:00
53c993d9c1 process.c: move prctl and arch_prctl parsers to a separate file
* prctl.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* process.c: Move sys_prctl, sys_arch_prctl, and related code to prctl.c.
2014-12-11 21:40:44 +00:00