]> granicus.if.org Git - strace/log
strace
7 years agoprintsiginfo: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Sun, 25 Dec 2016 02:49:58 +0000 (02:49 +0000)]
printsiginfo: cast pointers to kernel_ureg_t instead of unsigned long

* printsiginfo.c (printsigval): Cast siginfo.si_ptr pointer
to kernel_ureg_t instead of unsigned long.
(print_si_info): Cast siginfo.si_addr and siginfo.si_call_addr pointers
to kernel_ureg_t instead of unsigned long.

7 years agosigaltstack: cast pointers and sizes to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Sun, 25 Dec 2016 02:30:12 +0000 (02:30 +0000)]
sigaltstack: cast pointers and sizes to kernel_ureg_t instead of unsigned long

* sigaltstack.c (print_stack_t): Cast sigaltstack.ss_sp pointer
and sigaltstack.ss_size to kernel_ureg_t instead of unsigned long.

7 years agov4l2: cast pointers to kernel_ureg_t instead of long
Dmitry V. Levin [Sat, 24 Dec 2016 14:22:19 +0000 (14:22 +0000)]
v4l2: cast pointers to kernel_ureg_t instead of long

* v4l2.c (print_v4l2_ext_control): Cast v4l2_ext_control.string pointer
to kernel_ureg_t instead of long.

7 years agov4l2: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Sun, 25 Dec 2016 02:14:49 +0000 (02:14 +0000)]
v4l2: cast pointers to kernel_ureg_t instead of unsigned long

* v4l2.c (print_v4l2_buffer): Remove redundant cast.
(print_v4l2_framebuffer): Cast v4l2_framebuffer.base pointer
to kernel_ureg_t instead of unsigned long.
(print_v4l2_ext_controls): Cast v4l2_ext_controls.controls pointer
to kernel_ureg_t instead of unsigned long.

7 years agosysctl: cast pointers to kernel_ureg_t instead of size_t
Dmitry V. Levin [Fri, 23 Dec 2016 23:49:55 +0000 (23:49 +0000)]
sysctl: cast pointers to kernel_ureg_t instead of size_t

* sysctl.c (SYS_FUNC(sysctl)): Cast __sysctl_args.oldval and
__sysctl_args.newval pointers to kernel_ureg_t instead of size_t.

7 years agosysctl: cast pointers to kernel_ureg_t instead of long
Dmitry V. Levin [Fri, 23 Dec 2016 23:43:53 +0000 (23:43 +0000)]
sysctl: cast pointers to kernel_ureg_t instead of long

* sysctl.c (SYS_FUNC(sysctl)): Cast __sysctl_args.oldlenp pointer
to kernel_ureg_t instead of long.

7 years agoblock: cast pointers to kernel_ureg_t instead of long
Dmitry V. Levin [Wed, 21 Dec 2016 13:54:49 +0000 (13:54 +0000)]
block: cast pointers to kernel_ureg_t instead of long

* block.c (print_blkpg_req): Cast blkpg_ioctl_arg.data pointer
to kernel_ureg_t instead of long.

7 years agodumpiov_upto: cast pointers to kernel_ureg_t instead of long
Dmitry V. Levin [Wed, 21 Dec 2016 15:36:50 +0000 (15:36 +0000)]
dumpiov_upto: cast pointers to kernel_ureg_t instead of long

* util.c  (dumpiov_upto): Cast iovec.iov_base pointer to kernel_ureg_t
instead of long.

7 years agomsghdr: cast pointers to kernel_ureg_t instead of long
Dmitry V. Levin [Wed, 21 Dec 2016 15:36:50 +0000 (15:36 +0000)]
msghdr: cast pointers to kernel_ureg_t instead of long

* msghdr.c (print_struct_msghdr): Cast msghdr.msg_name pointer
to kernel_ureg_t instead of long.
(dumpiov_in_msghdr): Cast msghdr.msg_iov pointer to kernel_ureg_t
instead of long.

7 years agommsghdr: cast pointers to kernel_ureg_t instead of long
Dmitry V. Levin [Wed, 21 Dec 2016 15:36:50 +0000 (15:36 +0000)]
mmsghdr: cast pointers to kernel_ureg_t instead of long

* mmsghdr.c (dumpiov_in_mmsghdr): Cast msghdr.msg_iov pointer
to kernel_ureg_t instead of long.

7 years agoRemove redundant casts of ptrace arguments
Dmitry V. Levin [Fri, 23 Dec 2016 23:33:40 +0000 (23:33 +0000)]
Remove redundant casts of ptrace arguments

* strace.c (maybe_switch_tcbs, trace): Do not cast ptrace 4th argument
from pointer to long type.

7 years agoptrace_restart: cleanup
Dmitry V. Levin [Fri, 23 Dec 2016 23:39:35 +0000 (23:39 +0000)]
ptrace_restart: cleanup

* strace.c (ptrace_restart): Replace the sequence of "if" statements
with a "switch" statement.

7 years agoptrace_restart: change types of integer arguments to unsigned
Dmitry V. Levin [Fri, 23 Dec 2016 23:30:33 +0000 (23:30 +0000)]
ptrace_restart: change types of integer arguments to unsigned

* strace.c (ptrace_restart): Change types of "op" and "sig"
from int to unsigned int.

7 years agoprocess: remove redundant syserror checks
Dmitry V. Levin [Fri, 23 Dec 2016 23:05:46 +0000 (23:05 +0000)]
process: remove redundant syserror checks

* process.c (SYS_FUNC(ptrace)): Remove syserror checks as both
print_siginfo_array and print_seccomp_fprog do the right thing
by using umoven_or_printaddr.

7 years agosparc64: remove redundant casts
Dmitry V. Levin [Sat, 24 Dec 2016 14:19:14 +0000 (14:19 +0000)]
sparc64: remove redundant casts

* linux/sparc64/get_syscall_args.c (get_syscall_args): Remove
redundant casts from uint32_t to long.

7 years agonuma: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Fri, 23 Dec 2016 19:59:46 +0000 (19:59 +0000)]
numa: change address argument type from unsigned long to kernel_ureg_t

* numa.c (print_nodemask): Change address argument type from
unsigned long to kernel_ureg_t.

7 years agonet: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Fri, 23 Dec 2016 10:47:36 +0000 (10:47 +0000)]
net: change address argument type from unsigned long to kernel_ureg_t

* net.c (fetch_socklen): Change address argument type from
unsigned long to kernel_ureg_t.

7 years agomem: change tracee address type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Fri, 23 Dec 2016 12:45:03 +0000 (12:45 +0000)]
mem: change tracee address type from unsigned long to kernel_ureg_t

* mem.c (print_mmap, SYS_FUNC(remap_file_pages),
SYS_FUNC(subpage_prot)): Change the type of variables containing tracee
addresses from unsigned long to kernel_ureg_t.

7 years agokexec: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Fri, 23 Dec 2016 01:18:15 +0000 (01:18 +0000)]
kexec: change address argument type from unsigned long to kernel_ureg_t

* kexec.c (print_kexec_segments): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agopoll: change counter type from unsigned long to unsigned int
Dmitry V. Levin [Thu, 22 Dec 2016 17:59:19 +0000 (17:59 +0000)]
poll: change counter type from unsigned long to unsigned int

* poll.c (decode_poll_exiting): Change the type of printed and
max_printed counters from unsigned long to unsigned int.

7 years agoxattr: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:54:10 +0000 (20:54 +0000)]
xattr: change address argument type from unsigned long to kernel_ureg_t

* xattr.c (print_xattr_val, print_xattr_list): Change address
argument type from unsigned long to kernel_ureg_t.

7 years agouid: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:53:16 +0000 (20:53 +0000)]
uid: change address argument type from unsigned long to kernel_ureg_t

* uid.c (print_groups): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agostat64: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:50:45 +0000 (20:50 +0000)]
stat64: change address argument type from unsigned long to kernel_ureg_t

* stat64.c (decode_struct_stat64): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agostat: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:50:13 +0000 (20:50 +0000)]
stat: change address argument type from unsigned long to kernel_ureg_t

* stat.c (decode_struct_stat): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agosigaltstack: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:49:04 +0000 (20:49 +0000)]
sigaltstack: change address argument type from unsigned long to kernel_ureg_t

* sigaltstack.c (print_stack_t): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agoresource: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:46:16 +0000 (20:46 +0000)]
resource: change address argument type from unsigned long to kernel_ureg_t

* resource.c (print_rlimit64, print_rlimit32, decode_rlimit): Change
address argument type from unsigned long to kernel_ureg_t.

7 years agoprintsiginfo: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 20:44:44 +0000 (20:44 +0000)]
printsiginfo: change address argument type from unsigned long to kernel_ureg_t

* printsiginfo.c (print_siginfo_array): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agopoll: change tracee address type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 16:56:14 +0000 (16:56 +0000)]
poll: change tracee address type from unsigned long to kernel_ureg_t

* poll.c (decode_poll_entering, decode_poll_exiting): Change the type
all tracee address variables from unsigned long to kernel_ureg_t.

7 years agoperf: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 02:50:05 +0000 (02:50 +0000)]
perf: change address argument type from unsigned long to kernel_ureg_t

* perf.c (fetch_perf_event_attr, print_perf_event_attr): Change
address argument type from unsigned long to kernel_ureg_t.

7 years agopathtrace: change tracee address type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Thu, 22 Dec 2016 02:43:57 +0000 (02:43 +0000)]
pathtrace: change tracee address type from unsigned long to kernel_ureg_t

* pathtrace.c (upathmatch): Change address argument type
from unsigned long to kernel_ureg_t.
(pathtrace_match): Change the type of all tracee address variables
from unsigned long to kernel_ureg_t.

7 years agoscsi: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 03:03:09 +0000 (03:03 +0000)]
scsi: change address argument type from unsigned long to kernel_ureg_t

* scsi.c (print_sg_io_buffer): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agodm: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 03:03:09 +0000 (03:03 +0000)]
dm: change address argument type from unsigned long to kernel_ureg_t

* dm.c (dm_decode_dm_target_spec, dm_decode_dm_target_deps,
dm_decode_dm_name_list, dm_decode_dm_target_versions,
dm_decode_dm_target_msg, dm_decode_string): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agooldstat: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 21:39:15 +0000 (21:39 +0000)]
oldstat: change address argument type from unsigned long to kernel_ureg_t

* oldstat.c (print_old_kernel_stat): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agocapability: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 17:08:17 +0000 (17:08 +0000)]
capability: change address argument type from unsigned long to kernel_ureg_t

* capability.c (get_cap_header, print_cap_header, print_cap_data):
Change address argument type from unsigned long to kernel_ureg_t.

7 years agobtrfs: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 17:00:44 +0000 (17:00 +0000)]
btrfs: change address argument type from unsigned long to kernel_ureg_t

* btrfs.c (btrfs_print_qgroup_inherit): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agoaffinity: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 02:10:53 +0000 (02:10 +0000)]
affinity: change address argument type from unsigned long to kernel_ureg_t

* affinity.c (print_affinitylist): Change address argument type from
unsigned long to kernel_ureg_t.

7 years agoaio: change address type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 02:25:37 +0000 (02:25 +0000)]
aio: change address type from unsigned long to kernel_ureg_t

* aio.c (print_iocb): Remove casts to unsigned long.
(print_iocbp,  SYS_FUNC(io_submit)): Change address type
from unsigned long to kernel_ureg_t.

7 years agommsghdr: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 15:36:50 +0000 (15:36 +0000)]
mmsghdr: change address argument type from unsigned long to kernel_ureg_t

* mmsghdr.c (save_mmsgvec_namelen, decode_mmsgvec): Change
address argument type from unsigned long to kernel_ureg_t.

7 years agomsghdr: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 15:36:50 +0000 (15:36 +0000)]
msghdr: change address argument type from unsigned long to kernel_ureg_t

* msghdr.c (decode_msg_control): Change address argument type
from unsigned long to kernel_ureg_t.

7 years agofetch_struct_stat64: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 21:22:25 +0000 (21:22 +0000)]
fetch_struct_stat64: change address argument type from unsigned long to kernel_ureg_t

* fetch_struct_stat64.c (fetch_struct_stat64): Change address argument
type from unsigned long to kernel_ureg_t.

7 years agofetch_struct_stat: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 21:21:20 +0000 (21:21 +0000)]
fetch_struct_stat: change address argument type from unsigned long to kernel_ureg_t

* fetch_struct_stat.c (fetch_struct_stat): Change address argument
type from unsigned long to kernel_ureg_t.

7 years agofetch_struct_msghdr: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 15:36:50 +0000 (15:36 +0000)]
fetch_struct_msghdr: change address argument type from unsigned long to kernel_ureg_t

* fetch_struct_msghdr.c (fetch_struct_msghdr): Change
address argument type from unsigned long to kernel_ureg_t.

7 years agofetch_struct_mmsghdr: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Wed, 21 Dec 2016 15:36:50 +0000 (15:36 +0000)]
fetch_struct_mmsghdr: change address argument type from unsigned long to kernel_ureg_t

* fetch_struct_mmsghdr.c (fetch_struct_mmsghdr): Change
address argument type from unsigned long to kernel_ureg_t.

7 years agodecode_netlink: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Tue, 20 Dec 2016 23:16:25 +0000 (23:16 +0000)]
decode_netlink: change address argument type from unsigned long to kernel_ureg_t

* defs.h (decode_netlink) Change address argument type
from unsigned long to kernel_ureg_t.
* netlink.c (fetch_nlmsghdr, decode_nlmsghdr_with_payload,
decode_netlink): Likewise.

7 years agoprint_seccomp_*: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Tue, 20 Dec 2016 22:54:53 +0000 (22:54 +0000)]
print_seccomp_*: change address argument type from unsigned long to kernel_ureg_t

* defs.h (print_seccomp_filter, print_seccomp_fprog): Change
address argument type from unsigned long to kernel_ureg_t.
* seccomp.c (print_seccomp_filter, print_seccomp_fprog,
decode_seccomp_set_mode_strict): Likewise.

7 years agotprint_iov*: change address argument type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Tue, 20 Dec 2016 22:47:02 +0000 (22:47 +0000)]
tprint_iov*: change address argument type from unsigned long to kernel_ureg_t

* defs.h (tprint_iov, tprint_iov_upto): Change address argument type
from unsigned long to kernel_ureg_t.
* io.c (tprint_iov, tprint_iov_upto): Likewise.

7 years agoprint_array: change tracee address type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Tue, 20 Dec 2016 21:46:10 +0000 (21:46 +0000)]
print_array: change tracee address type from unsigned long to kernel_ureg_t

* defs.h (print_array): Change start_addr type from unsigned long
to kernel_ureg_t.
* util.c (print_array): Likewise.  Change the type of all tracee
address variables from unsigned long to kernel_ureg_t.

7 years agoRename LONG_LONG to ULONG_LONG and change it to return unsigned long long
Dmitry V. Levin [Fri, 23 Dec 2016 19:12:38 +0000 (19:12 +0000)]
Rename LONG_LONG to ULONG_LONG and change it to return unsigned long long

In all places where LONG_LONG is used the destination already has type
unsigned long long, so it is quite natural to change LONG_LONG as well.

* defs.h (LONG_LONG): Rename to ULONG_LONG, change return type
from long long to unsigned long long.  All callers updated.

7 years agomem: remove redundant casts
Dmitry V. Levin [Fri, 23 Dec 2016 11:16:11 +0000 (11:16 +0000)]
mem: remove redundant casts

* mem.c (SYS_FUNC(old_mmap)): Remove redundant cast
from kernel_ureg_t to unsigned long.
[S390] (SYS_FUNC(old_mmap_pgoff)): Remove redundant cast
from unsigned int to unsigned long.

7 years agodesc: remove redundant casts
Dmitry V. Levin [Thu, 22 Dec 2016 23:36:32 +0000 (23:36 +0000)]
desc: remove redundant casts

* desc.c (umove_kulong_array_or_printaddr): Remove redundant cast
from uint32_t to kernel_ulong_t.
(SYS_FUNC(pselect6)): Remove redundant casts from kernel_ulong_t
to unsigned long.

7 years agoprint_sigevent: remove redundant cast
Dmitry V. Levin [Thu, 22 Dec 2016 17:07:24 +0000 (17:07 +0000)]
print_sigevent: remove redundant cast

* print_sigevent.c (print_sigevent): Remove redundant cast from
struct_sigevent.sigev_value.sival_ptr to unsigned long as the former
is not a pointer but an unsigned integer.

7 years agotests: fix xattr.test for the case when listxattr returns a long list
Dmitry V. Levin [Thu, 22 Dec 2016 22:34:23 +0000 (22:34 +0000)]
tests: fix xattr.test for the case when listxattr returns a long list

* tests/xattr.c (DEFAULT_STRLEN): New macro.
(main): Use it to limit the length passed to print_quoted_memory.
Print ellipsis when the list returned by listxattr is too long.

7 years agotests: test for correct ellipsis with -s in xattr
Gabriel Laskar [Thu, 22 Dec 2016 15:10:52 +0000 (16:10 +0100)]
tests: test for correct ellipsis with -s in xattr

* tests/xattr-strings.c: New file.
* tests/xattr-strings.test: New test.
* tests/.gitignore: Add xattr-string.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add xattr-string.test.

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
7 years agoxattr: use printstr_ex instead of print_quoted_string
Gabriel Laskar [Thu, 22 Dec 2016 15:10:51 +0000 (16:10 +0100)]
xattr: use printstr_ex instead of print_quoted_string

This fixes the display when using `-s` to limit the string size
of the values displayed by {get,set}xattr.

* xattr.c (print_xattr_val): Remove static buffer.  Use printstr_ex
instead of print_quoted_string.

Reported-by: Марк Коренберг <socketpair@gmail.com>
Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
7 years agotests: use scno.h in finit_module, kcmp, renameat2 tests
Eugene Syromyatnikov [Tue, 20 Dec 2016 23:49:04 +0000 (02:49 +0300)]
tests: use scno.h in finit_module, kcmp, renameat2 tests

* tests/finit_module.c: Include "scno.h".
* tests/kcmp.c: Likewise.
* tests/renameat2.c: Likewise.

7 years agosock: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 14:12:17 +0000 (14:12 +0000)]
sock: cast pointers to kernel_ureg_t instead of unsigned long

* sock.c (decode_ifconf): Cast ifconf.ifc_buf pointer to kernel_ureg_t
instead of unsigned long.

7 years agoscsi: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 13:59:02 +0000 (13:59 +0000)]
scsi: cast pointers to kernel_ureg_t instead of unsigned long

* scsi.c (print_sg_io_v3_req, print_sg_io_v3_res): Cast sg_io_hdr.cmdp,
sg_io_hdr.dxferp, and sg_io_hdr.sbp pointers to kernel_ureg_t instead
of unsigned long.

7 years agomtd: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 16:38:02 +0000 (16:38 +0000)]
mtd: cast pointers to kernel_ureg_t instead of unsigned long

* mtd.c (decode_mtd_oob_buf): Cast mtd_oob_buf.ptr pointer
to kernel_ureg_t instead of unsigned long.

7 years agomsghdr: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 00:04:06 +0000 (00:04 +0000)]
msghdr: cast pointers to kernel_ureg_t instead of unsigned long

* msghdr.c (print_struct_msghdr): Cast msghdr.msg_iov and
msghdr.msg_control pointers to kernel_ureg_t instead of unsigned long.

7 years agoevdev: cast tcp->u_rval to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 14:12:17 +0000 (14:12 +0000)]
evdev: cast tcp->u_rval to kernel_ureg_t instead of unsigned long

* evdev.c (decode_bitset): Cast tcp->u_rval to kernel_ureg_t
instead of unsigned long.

7 years agoevdev: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 13:13:08 +0000 (13:13 +0000)]
evdev: cast pointers to kernel_ureg_t instead of unsigned long

* evdev.c (ff_effect_ioctl): Cast ff_periodic_effect.custom_data
pointer to kernel_ureg_t instead of unsigned long.

7 years agobtrfs: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 13:11:11 +0000 (13:11 +0000)]
btrfs: cast pointers to kernel_ureg_t instead of unsigned long

* btrfs.c (btrfs_ioctl): Cast btrfs_ioctl_send_args.clone_sources
and btrfs_ioctl_vol_args_v2.qgroup_inherit pointers to kernel_ureg_t
instead of unsigned long.

7 years agoRework ifdefery around print_user_desc
Dmitry V. Levin [Wed, 21 Dec 2016 18:01:21 +0000 (18:01 +0000)]
Rework ifdefery around print_user_desc

* configure.ac (AC_CHECK_TYPES): Check for struct user_desc
in <asm/ldt.h>.
* clone.c (print_tls_arg): New function.
(SYS_FUNC(clone)): Use it.
(print_user_desc): Move prototype ...
* defs.h [HAVE_STRUCT_USER_DESC]: ... here.
* ldt.c: Check for HAVE_STRUCT_USER_DESC instead of architectures.
* linux/dummy.h: Likewise.

7 years agoIntroduce DECL_IOCTL macro to declare *_ioctl functions
Dmitry V. Levin [Wed, 21 Dec 2016 00:21:10 +0000 (00:21 +0000)]
Introduce DECL_IOCTL macro to declare *_ioctl functions

* defs.h (DECL_IOCTL): New macro.
(dm_ioctl, file_ioctl, fs_x_ioctl, loop_ioctl, ptp_ioctl, scsi_ioctl,
sock_ioctl, term_ioctl, ubi_ioctl, uffdio_ioctl): Rewrite prototypes
using DECL_IOCTL.

7 years agoIntroduce DECL_PRINT* macros to declare printnum_* and printpair_*
Dmitry V. Levin [Tue, 20 Dec 2016 22:28:20 +0000 (22:28 +0000)]
Introduce DECL_PRINT* macros to declare printnum_* and printpair_*

* defs.h (DECL_PRINTNUM, DECL_PRINTPAIR): New macros.
(printnum_short, printnum_int, printnum_int64): Rewrite prototypes
using DECL_PRINTNUM.
(printpair_int, printpair_int64): Rewrite prototypes
using DECL_PRINTPAIR.

7 years agoioctl: use uintptr_t for casts between 32-bit integers and pointers
Dmitry V. Levin [Wed, 21 Dec 2016 00:26:06 +0000 (00:26 +0000)]
ioctl: use uintptr_t for casts between 32-bit integers and pointers

* ioctl.c (compare): Cast pointer to uintptr_t before assigning
it to an integer.
(ioctl_lookup): Cast integer to uintptr_t before passing it
as a pointer.

7 years agoscsi: use umove_or_printaddr
Dmitry V. Levin [Wed, 21 Dec 2016 00:37:57 +0000 (00:37 +0000)]
scsi: use umove_or_printaddr

* scsi.c (scsi_ioctl): Use umove_or_printaddr.

7 years agoRemove dumpiov wrapper
Dmitry V. Levin [Wed, 21 Dec 2016 02:16:35 +0000 (02:16 +0000)]
Remove dumpiov wrapper

* defs.h (dumpiov): Remove.
* syscall.c (dumpio): Use dumpiov_upto instead of dumpiov.

7 years agotravis: fix enabling of gcc -Werror builds
Dmitry V. Levin [Wed, 21 Dec 2016 22:20:29 +0000 (22:20 +0000)]
travis: fix enabling of gcc -Werror builds

* travis-build.sh: Use DISTCHECK_CONFIGURE_FLAGS instead
of CHECK_CONFIGURE_FLAGS and ENABLE_GCC_WERROR.
[$CC == gcc]: Add --enable-gcc-Werror to DISTCHECK_CONFIGURE_FLAGS
instead of ENABLE_GCC_WERROR.
[$CHECK == coverage]: Add --enable-code-coverage
to DISTCHECK_CONFIGURE_FLAGS instead of CHECK_CONFIGURE_FLAGS.

7 years agoprintaddr: change argument type to kernel_ureg_t
Dmitry V. Levin [Tue, 20 Dec 2016 15:10:48 +0000 (15:10 +0000)]
printaddr: change argument type to kernel_ureg_t

* defs.h (printaddr): Change argument type from unsigned long
to kernel_ureg_t.

7 years agotests: check decoding of unreadable ip_mreq and ipv6_mreq structures
Dmitry V. Levin [Tue, 20 Dec 2016 20:19:35 +0000 (20:19 +0000)]
tests: check decoding of unreadable ip_mreq and ipv6_mreq structures

* tests/ip_mreq.c (main): Check short read.

7 years agotests: rewrite ip_mreq.c using arrays and iterators
Dmitry V. Levin [Tue, 20 Dec 2016 20:17:18 +0000 (20:17 +0000)]
tests: rewrite ip_mreq.c using arrays and iterators

* tests/ip_mreq.c (main): Create arrays of setsockopt arguments to test.
Iterate over these arrays invoking setsockopt and printing expected
output.

7 years agotests: rewrite ip_mreq.c using tail_alloc
Dmitry V. Levin [Tue, 20 Dec 2016 20:13:18 +0000 (20:13 +0000)]
tests: rewrite ip_mreq.c using tail_alloc

* tests/ip_mreq.c (main): Allocate objects of struct ip_mreq
and struct ipv6_mreq using tail_alloc instead of using stack.

7 years agotests: rewrite ip_mreq.c without asserts
Dmitry V. Levin [Tue, 20 Dec 2016 17:55:04 +0000 (17:55 +0000)]
tests: rewrite ip_mreq.c without asserts

* tests/ip_mreq.c: Do not include <assert.h>.
(main): Do not use assert.  Use sprintrc instead of errno2name.

7 years agoRemove NEED_PTRACE_PROTOTYPE_WORKAROUND
Dmitry V. Levin [Tue, 20 Dec 2016 14:58:57 +0000 (14:58 +0000)]
Remove NEED_PTRACE_PROTOTYPE_WORKAROUND

Remove the workaround for broken ptrace prototypes
that seems to be unneeded for quite a long time.

* defs.h [NEED_PTRACE_PROTOTYPE_WORKAROUND]: Remove.

7 years agotests: use scno.h in tests of relatively new syscalls
Dmitry V. Levin [Tue, 20 Dec 2016 00:06:15 +0000 (00:06 +0000)]
tests: use scno.h in tests of relatively new syscalls

* tests/add_key.c: Include "scno.h" after <asm/unistd.h>.
* tests/copy_file_range.c: Likewise.
* tests/execveat.c: Likewise.
* tests/kexec_file_load.c: Likewise.
* tests/membarrier.c: Likewise.
* tests/memfd_create.c: Likewise.
* tests/mlock2.c: Likewise.
* tests/pkey_alloc.c: Likewise.
* tests/pkey_free.c: Likewise.
* tests/pkey_mprotect.c: Likewise.
* tests/preadv2-pwritev2.c: Likewise.
* tests/userfaultfd.c: Likewise.

7 years agotests: generate scno.h from syscallent.h for use by other tests
Dmitry V. Levin [Mon, 19 Dec 2016 23:37:57 +0000 (23:37 +0000)]
tests: generate scno.h from syscallent.h for use by other tests

Provide scno.h with fallback definitions of all __NR_* constants known
to strace for the personbality being tested.

Some tests need just __NR_* constants without any kernel support.
Such tests can include "scno.h" after <asm/unistd.h> to get definitions
of these constants when system headers are too old.

* tests/generate_scno.c: New file.
* tests/.gitignore: Add generate_scno.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(scno.h): New rule.
(BUILT_SOURCES, CLEANFILES): Add scno.h.

7 years agotests: fix potential errno clobbering in membarrier test
Dmitry V. Levin [Tue, 20 Dec 2016 02:27:22 +0000 (02:27 +0000)]
tests: fix potential errno clobbering in membarrier test

* tests/membarrier.c (main): Save errno.

7 years agoDo not use widen_to_ulong in kexec.c and process_vm.c
Dmitry V. Levin [Tue, 20 Dec 2016 02:04:09 +0000 (02:04 +0000)]
Do not use widen_to_ulong in kexec.c and process_vm.c

Automatic argument truncation makes use of this function redundant.

* kexec.c (SYS_FUNC(kexec_load)): Do not invoke widen_to_ulong.
* process_vm.c (SYS_FUNC(process_vm_readv),
SYS_FUNC(process_vm_writev)): Likewise.

7 years agox32: implement automatic argument truncation for compat syscalls
Dmitry V. Levin [Tue, 20 Dec 2016 01:52:20 +0000 (01:52 +0000)]
x32: implement automatic argument truncation for compat syscalls

x32 syscalls starting with number 512 are compat syscalls that operate
on compat types.  Set COMPAT_SYSCALL_TYPES flag to these syscall entries
and make get_syscall_args truncate arguments of syscalls that have this
flag set, to avoid unpleasant alternative of adding multiple
widen_to_ulong invocations to individual syscall parsers.

preadv, pwritev, preadv2, and pwritev2 are exceptions: while these
syscalls operate on compat types, the offset argument has a regular
64-bit type, so the automatic argument truncation cannot be applied.

* defs.h (COMPAT_SYSCALL_TYPES): New macro.
* syscall.c (CST): New macro, defined to COMPAT_SYSCALL_TYPES.
* linux/ia64/syscallent.h: Do not include "../i386/syscallent.h"
unless [CST > 0].
* linux/x32/syscallent.h [512..533, 536..545]: Add CST flag.
* linux/x86_64/get_syscall_args.c (get_syscall_args): Truncate arguments
of compat syscalls to 32-bit values.
* tests/ksysent.c (CST): New macro, defined to 0.
* tests/nsyscalls.c (CST): Likewise.

7 years agox32: fix decoding of mprotect and pkey_mprotect syscall arguments
Dmitry V. Levin [Tue, 20 Dec 2016 01:11:53 +0000 (01:11 +0000)]
x32: fix decoding of mprotect and pkey_mprotect syscall arguments

As there are no compat versions of mprotect or pkey_mprotect syscalls
in x32 personality, "addr", "len", and "prot" syscall arguments have
kernel_ulong_t type and should be printed accordingly.

* mem.c (do_mprotect): Retrieve 1st, 2nd and 3rd arguments using
getarg_klu, print them using printaddr_klu, PRI_klu format,
and printflags64, correspondingly.

7 years agoMake tprint_iov function a static inline wrapper
Dmitry V. Levin [Mon, 19 Dec 2016 21:17:13 +0000 (21:17 +0000)]
Make tprint_iov function a static inline wrapper

* io.c (tprint_iov): Move ...
* defs.h: ... here, add static inline keywords.

7 years agox32: fix decoding of 3rd argument of preadv* and pwritev* syscalls
Eugene Syromyatnikov [Mon, 19 Dec 2016 22:13:21 +0000 (01:13 +0300)]
x32: fix decoding of 3rd argument of preadv* and pwritev* syscalls

In x32 personality these syscalls use compat type for the 3rd argument,
therefore it has to be truncated there.

* io.c (do_preadv, do_pwritev): Truncate tcp->u_arg[2] using
widen_to_ulong.

7 years agotests: fix preadv2-pwritev2 test on x32
Eugene Syromyatnikov [Mon, 19 Dec 2016 21:32:40 +0000 (00:32 +0300)]
tests: fix preadv2-pwritev2 test on x32

On x32 p(read|write)v(|2) syscalls are implemented via compat, which
truncates len argument to unsigned int.

* tests/preadv2-pwritev2.c (main): Print vlen argument as unsigned long.

7 years agokexec: fix for the x32 ABI
Eugene Syromyatnikov [Mon, 19 Dec 2016 21:13:27 +0000 (00:13 +0300)]
kexec: fix for the x32 ABI

There is no compat (and no 32-bit version, ever) for x32 ABI, so
kernel's long type should be used for arguments' values.

The only remaining thing is a pointer to cmdline string, but it is
currently broken on x32 anyway.

* kexec.c (SYS_FUNC(kexec_file_load)): Print the cmdline_len argument
as kernel long, retrieve it via getarg_klu; use printflags64 for
printing the flags argument, retrieve it via getarg_klu.

7 years agoCheck for current_klongsize instead of current_personality where appropriate
Dmitry V. Levin [Mon, 19 Dec 2016 18:30:22 +0000 (18:30 +0000)]
Check for current_klongsize instead of current_personality where appropriate

current_klongsize checks are more universal, therefore they are usually
shorter and easier to comprehend.

* desc.c (umove_kulong_array_or_printaddr): Check for current_klongsize
instead of current_personality and current_wordsize.
* io.c (print_lld_from_low_high_val): Likewise.
* lseek.c (SYS_FUNC(lseek)): Likewise.
* resource.c (decode_rlimit): Likewise.
* syscall.c (is_negated_errno): Likewise.
* util.c (getllval, getarg_klu): Likewise.

7 years agoUse kernel_ulong_t instead of unsigned long long where appropriate
Dmitry V. Levin [Mon, 19 Dec 2016 16:56:45 +0000 (16:56 +0000)]
Use kernel_ulong_t instead of unsigned long long where appropriate

* defs.h (printaddr_ull): Rename to printaddr_klu, change argument
type from unsigned long long to kernel_ulong_t.  All callers updated.
(getarg_ull): Rename to getarg_klu, change return value type
from unsigned long long to kernel_ulong_t.  All callers updated.
(PRI_kl, PRI_kld, PRI_klu, PRI_klx): New macros.
* bjm.c (SYS_FUNC(init_module)): Print kernel_ulong_t type using
PRI_klu format.
* desc.c (SYS_FUNC(pselect6)): Likewise.
* fadvise.c (SYS_FUNC(fadvise64)): Likewise.
* lookup_dcookie.c (SYS_FUNC(lookup_dcookie)): Likewise.
* mq.c (SYS_FUNC(mq_timedsend), SYS_FUNC(mq_timedreceive)): Likewise.
* kcmp.c (SYS_FUNC(kcmp)): Print kernel_ulong_t type using
PRI_klx format.
* keyctl.c (SYS_FUNC(keyctl)): Likewise.
* pkeys.c (SYS_FUNC(pkey_alloc)): Likewise.
* prctl.c (print_prctl_args, SYS_FUNC(prctl), SYS_FUNC(arch_prctl)):
Print kernel_ulong_t type using PRI_kld, PRI_klu, or PRI_klx format.
* util.c (printaddr_ull): Rename to printaddr_klu, change argument
type from unsigned long long to kernel_ulong_t, print it using
PRI_klx format.
(getarg_ull): Rename to getarg_klu, change return value type
from unsigned long long to kernel_ulong_t, print it using
PRI_klx format.

7 years agofcntl.c: print 64-bit fields of struct_kernel_flock64 using PRId64 format
Dmitry V. Levin [Mon, 19 Dec 2016 16:46:51 +0000 (16:46 +0000)]
fcntl.c: print 64-bit fields of struct_kernel_flock64 using PRId64 format

* fcntl.c (print_struct_flock64): Print l_start and l_len fields
of struct_kernel_flock64 using PRId64 format.

7 years agov4l2.c: print v4l2_ext_control.value64 using PRId64 format
Dmitry V. Levin [Mon, 19 Dec 2016 16:19:40 +0000 (16:19 +0000)]
v4l2.c: print v4l2_ext_control.value64 using PRId64 format

* v4l2.c (print_v4l2_ext_control): Print value64 field
of struct_v4l2_ext_control using PRId64 format.

7 years agoperf.c: print perf_event_attr.__reserved_1 using PRIx64 format
Dmitry V. Levin [Mon, 19 Dec 2016 16:11:55 +0000 (16:11 +0000)]
perf.c: print perf_event_attr.__reserved_1 using PRIx64 format

* perf.c (print_perf_event_attr): Print __reserved_1 field
of perf_event_attr using PRIx64 format.

7 years agobtrfs.c: print 64-bit fields of btrfs_ioctl_vol_args_v2 using PRIu64 format
Dmitry V. Levin [Mon, 19 Dec 2016 16:05:16 +0000 (16:05 +0000)]
btrfs.c: print 64-bit fields of btrfs_ioctl_vol_args_v2 using PRIu64 format

* block.c (btrfs_ioctl): Print size and transid fields
of struct_btrfs_ioctl_vol_args_v2 using PRIu64 format.

7 years agoblock.c: change type of long long fileds to int64_t
Dmitry V. Levin [Mon, 19 Dec 2016 15:59:47 +0000 (15:59 +0000)]
block.c: change type of long long fileds to int64_t

* block.c (struct_blkpg_partition): Change type of start and length
fields from long long to int64_t.
(print_blkpg_req): Print them using PRId64 format.

7 years agoIntroduce current_klongsize in addition to current_wordsize
Eugene Syromyatnikov [Sun, 11 Dec 2016 13:30:30 +0000 (16:30 +0300)]
Introduce current_klongsize in addition to current_wordsize

Subsequent commits are going to use current_klongsize
as the tracee's size of kernel_ulong_t type.

* defs.h (PERSONALITY0_KLONGSIZE): New macro.
[X86_64] (PERSONALITY2_KLONGSIZE): Likewise.
[SUPPORTED_PERSONALITIES > 1] (PERSONALITY1_KLONGSIZE): Likewise.
[SUPPORTED_PERSONALITIES == 1] (current_klongsize): Likewise.
[SUPPORTED_PERSONALITIES == 2 && PERSONALITY0_KLONGSIZE ==
PERSONALITY1_KLONGSIZE] (current_klongsize): Likewise.
[SUPPORTED_PERSONALITIES != 1 && (SUPPORTED_PERSONALITIES != 2 ||
PERSONALITY0_KLONGSIZE != PERSONALITY1_KLONGSIZE)] (current_klongsize):
New variable prototype.
* syscall.c [!current_klongsize] (current_klongsize): New variable.
[!current_klongsize] (personality_klongsize): New array.
(set_personality) [!current_klongsize]: Update current_klongsize
with the appropriate value from personality_klongsize.

7 years agoconfigure: define SIZEOF_KERNEL_LONG_T macro
Dmitry V. Levin [Fri, 16 Dec 2016 20:28:09 +0000 (20:28 +0000)]
configure: define SIZEOF_KERNEL_LONG_T macro

Provide SIZEOF_KERNEL_LONG_T macro in addition to SIZEOF_LONG and
SIZEOF_LONG_LONG for checking of kernel_long_t and kernel_ulong_t
types at the time of preprocessing.

* configure.ac (AC_CHECK_SIZEOF): Add kernel_long_t.

7 years agoRemove getarg_ll
Dmitry V. Levin [Mon, 19 Dec 2016 14:21:40 +0000 (14:21 +0000)]
Remove getarg_ll

This function has never been used in the code, and in perspective
the whole ext_arg thing will go away.

* defs.h (getarg_ll): Remove prototype.
* util.c (getarg_ll): Remove.

7 years agostruct tcb: make types of syscall arguments unsigned
Dmitry V. Levin [Mon, 19 Dec 2016 12:05:31 +0000 (12:05 +0000)]
struct tcb: make types of syscall arguments unsigned

This is the first step in the direction of revisiting current practice
of indiscriminate use of signed types for syscall arguments and memory
addresses.

* kernel_types.h (kernel_ureg_t): New type, typedef to unsigned long.
* defs.h (struct tcb): Change type of u_arg from long to kernel_ureg_t.
[HAVE_STRUCT_TCB_EXT_ARG]: Change type of ext_arg from long long
to unsigned long long.
* desc.c (decode_select): Change type of syscall arguments from long
to kernel_ureg_t.
(SYS_FUNC(oldselect)): Change type of select_args from long
to kernel_ureg_t.
* io.c (print_lld_from_low_high_val): Remove no longer needed cast
of syscall arguments to unsigned long.
* lseek.c (SYS_FUNC(lseek)): Cast syscall argument from unsigned long
to long.
* mem.c (print_mmap): Change type of syscall arguments from long
to kernel_ureg_t.
(SYS_FUNC(old_mmap), SYS_FUNC(old_mmap_pgoff)): Change type of u_arg
from long to kernel_ureg_t.
(SYS_FUNC(mmap), SYS_FUNC(mmap_pgoff), SYS_FUNC(mmap_pgoff)): Remove
no longer needed cast of syscall arguments to unsigned long.
* pathtrace.c (pathtrace_match): Change type of args and select_args
from long to kernel_ureg_t.
* util.c (getarg_ull): Remove no longer needed casts of syscall
arguments to unsigned types.

7 years agos390: fix decoding of mmap2 syscall when arguments are not available
Dmitry V. Levin [Mon, 19 Dec 2016 12:34:51 +0000 (12:34 +0000)]
s390: fix decoding of mmap2 syscall when arguments are not available

* mem.c [S390] (SYS_FUNC(old_mmap_pgoff)): Use umove_or_printaddr
instead of umoven to fetch mmap arguments, fix return value when this
fetch fails.

7 years agoFix pathmatch of oldselect syscall on 64-bit architectures
Dmitry V. Levin [Mon, 19 Dec 2016 11:49:58 +0000 (11:49 +0000)]
Fix pathmatch of oldselect syscall on 64-bit architectures

* pathtrace.c (pathtrace_match): Fix fetching of 32-bit oldselect
arguments on 64-bit architectures.

7 years agoCleanup oldselect
Dmitry V. Levin [Mon, 19 Dec 2016 11:40:43 +0000 (11:40 +0000)]
Cleanup oldselect

* desc.c (SYS_FUNC(oldselect)): Rewrite without use of macros.

7 years agoChange scno type from long to unsigned long
Dmitry V. Levin [Sun, 18 Dec 2016 17:20:44 +0000 (17:20 +0000)]
Change scno type from long to unsigned long

Use an unsigned type for syscall numbers as they are not intended
for signed arithmetics.  Introduce kernel_scno_t as a typedef
to unsigned long, that could be changed later to kernel_ulong_t.

* kernel_types.h (kernel_scno_t): New type, typedef to unsigned long.
* defs.h (struct tcb): Change type of scno field from long
to kernel_scno_t.
(syscall_name): Change argument type from long to kernel_scno_t.
(scno_in_range, scno_is_valid): Change argument type from unsigned long
to kernel_scno_t.
* linux/aarch64/set_scno.c (arch_set_scno): Change scno argument type
from long to kernel_scno_t.
* linux/alpha/set_scno.c (arch_set_scno): Likewise.
* linux/arc/set_scno.c (arch_set_scno): Likewise.
* linux/arm/set_scno.c (arch_set_scno): Likewise.
* linux/avr32/set_scno.c (arch_set_scno): Likewise.
* linux/bfin/set_scno.c (arch_set_scno): Likewise.
* linux/crisv10/set_scno.c (arch_set_scno): Likewise.
* linux/hppa/set_scno.c (arch_set_scno): Likewise.
* linux/i386/set_scno.c (arch_set_scno): Likewise.
* linux/ia64/set_scno.c (arch_set_scno): Likewise.
* linux/m68k/set_scno.c (arch_set_scno): Likewise.
* linux/metag/set_scno.c (arch_set_scno): Likewise.
* linux/microblaze/set_scno.c (arch_set_scno): Likewise.
* linux/mips/set_scno.c (arch_set_scno): Likewise.
* linux/nios2/set_scno.c (arch_set_scno): Likewise.
* linux/or1k/set_scno.c (arch_set_scno): Likewise.
* linux/powerpc/set_scno.c (arch_set_scno): Likewise.
* linux/riscv/set_scno.c (arch_set_scno): Likewise.
* linux/s390/set_scno.c (arch_set_scno): Likewise.
* linux/sh/set_scno.c (arch_set_scno): Likewise.
* linux/sh64/set_scno.c (arch_set_scno): Likewise.
* linux/sparc/set_scno.c (arch_set_scno): Likewise.
* linux/tile/set_scno.c (arch_set_scno): Likewise.
* linux/x86_64/set_scno.c (arch_set_scno): Likewise.
* linux/xtensa/set_scno.c (arch_set_scno): Likewise.
* linux/aarch64/get_scno.c (arch_get_scno): Change scno variable type
from long to kernel_scno_t.
* linux/alpha/get_scno.c (arch_get_scno): Likewise.
* linux/arm/get_scno.c (arch_get_scno): Likewise.
* linux/sh/get_scno.c (arch_get_scno): Likewise.
* linux/x86_64/get_scno.c (arch_get_scno): Likewise.
* syscall.c (arch_set_scno): Likewise.
(shuffle_scno): Change return type from long to kernel_scno_t.
(syscall_name): Change argument type from long to kernel_scno_t.