Commit Graph

5046 Commits

Author SHA1 Message Date
7e5cd0e72b execve: prepare for handling big pointers
* execve.c (printargv): Change cp.p64 type from unsigned long
to kernel_ulong_t so it could handle wordsize > sizeof(long) properly.
2016-12-25 22:27:33 +00:00
276839aec6 clone: print clone flags without truncation
The flags argument is defined in kernel as unsigned long,
so change its decoding to avoid truncation.

* clone.c (SYS_FUNC(clone)): Change flags type from unsigned long
to kernel_ureg_t, print it using printflags64 instead of printflags.
2016-12-25 22:17:38 +00:00
d69c27760c Use printxval64 instead of printxval_long
After the change of tcb.u_arg type from long to kernel_ureg_t it is safe
to stop using printxval_long proxy and pass syscall arguments directly
to printxval64.

* defs.h (printxval_long): Remove.
* fcntl.c (print_fcntl): Replace printxval_long with printxval64.
* mtd.c (mtd_ioctl): Likewise.
* numa.c (SYS_FUNC(mbind)): Likewise.
* or1k_atomic.c [OR1K] (SYS_FUNC(or1k_atomic)): Likewise.
* sysmips.c [MIPS] (SYS_FUNC(sysmips)): Likewise.
* term.c (term_ioctl): Likewise.
2016-12-25 21:59:59 +00:00
9f8b29f1cd Use printflags64 instead of printflags_long
After the change of tcb.u_arg type from long to kernel_ureg_t it is safe
to stop using printflags_long proxy and pass syscall arguments directly
to printflags64.

* defs.h (printflags_long): Remove.
* fcntl.c (print_fcntl): Replace printflags_long with printflags64.
* numa.c (SYS_FUNC(get_mempolicy)): Likewise.
* perf.c (SYS_FUNC(perf_event_open)): Likewise.
* sram_alloc.c [BFIN] (SYS_FUNC(sram_alloc)): Likewise.
2016-12-25 21:55:01 +00:00
0eda4a0a4b upeek, upoke: change argument types from long to unsigned long
* defs.h (upeek, upoke): Change offset argument type from long
to unsigned long.  Change res argument type from long to kernel_ureg_t.
* upeek.c (upeek): Likewise.
* upoke.c (upoke.c): Likewise.
* syscall.c (print_pc) [ARCH_PC_PEEK_ADDR]: Change pc type from long
to kernel_ureg_t.
* linux/aarch64/arch_regs.c (arm_sp_ptr): Remove redundant cast.
* linux/metag/get_syscall_args.c (get_syscall_args): Likewise.
* linux/sh/get_syscall_result.c (get_syscall_result_regs): Likewise.
* linux/sh64/get_syscall_result.c (get_syscall_result_regs): Likewise.
* linux/powerpc/getregs_old.c (getregs_old): Remove redundant casts.
* linux/alpha/arch_getrval2.c (getrval2): Change r20 type from long
to unsigned long.
* linux/alpha/arch_regs.c (alpha_r0, alpha_a3): Change type from long
to unsigned long.
* linux/bfin/arch_regs.c (bfin_r0): Likewise.
* linux/crisv10/arch_regs.c (cris_r10): Likewise.
* linux/hppa/arch_regs.c (hppa_r28): Likewise.
* linux/ia64/arch_regs.c (IA64_PSR_IS): Likewise.
* linux/microblaze/arch_regs.c (microblaze_r3): Likewise.
* linux/sh/arch_regs.c (sh_r0): Likewise.
* linux/sh64/arch_regs.c (sh64_r9): Likewise.
* linux/xtensa/arch_regs.c (xtensa_a2): Likewise.
* linux/alpha/arch_sigreturn.c (arch_sigreturn): Change addr type
from long to unsigned long.
* linux/microblaze/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/alpha/get_scno.c (arch_get_scno): Update for the change
of signedness.
* linux/arc/get_syscall_args.c (get_syscall_args): Change arc_args type
from pointer to long to pointer to unsigned long.
* linux/arm/arch_regs.c (arm_sp_ptr): Change type from pointer to long
to pointer to unsigned long.
* linux/arm/arch_regs.h (arm_sp_ptr): Likewise.
* linux/i386/arch_regs.c (i386_esp_ptr): Likewise.
* linux/i386/arch_regs.h (i386_esp_ptr): Likewise.
* linux/m68k/arch_regs.c (m68k_usp_ptr): Likewise.
* linux/m68k/arch_regs.h (m68k_usp_ptr): Likewise.
* linux/ia64/get_syscall_args.c (get_syscall_args): Use umove
instead of umoven.
* linux/sh/arch_getrval2.c (getrval2): Change val type from long
to unsigned long.
2016-12-25 20:14:12 +00:00
44cb9c8356 arch_sigreturn: change tracee address type from long to unsigned long
* linux/arm/arch_sigreturn.c (arch_sigreturn): Change addr variable
type from long to unsigned long.
* linux/ia64/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/m68k/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/powerpc/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/s390/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/sparc/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/tile/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/crisv10/arch_sigreturn.c (arch_sigreturn): Change the type
of addr and regs variables from long to unsigned long.
* linux/mips/arch_sigreturn.c (arch_sigreturn): Change addr variable
type from long to kernel_ureg_t.
* linux/x86_64/arch_sigreturn.c (arch_sigreturn): Change the type
of offset and addr variables from long to kernel_ureg_t.
2016-12-25 11:32:46 +00:00
7372d4a900 kexec: change flags type from unsigned long to kernel_ureg_t
* kexec.c (SYS_FUNC(kexec_load)): Change n variable type
from unsigned long to kernel_ureg_t.  Use printxval64 instead
of printxval_long.  Use printflags64 instead of printflags_long.
2016-12-25 11:32:46 +00:00
bbb1fa0c5f kexec: change types of pointers and sizes to kernel_ureg_t
* kexec.c (print_seg): Change the type of *seg and seg_buf variables
from unsigned long to kernel_ureg_t.
(print_kexec_segments): Change len argument type from unsigned long
to kernel_ureg_t.  Change seg variable type from unsigned long
to kernel_ureg_t.
2016-12-25 11:32:46 +00:00
94f801f14d printsiginfo: change len argument type from unsigned long to kernel_ureg_t
* printsiginfo.c (print_siginfo_array): Change len argument type
from unsigned long to kernel_ureg_t.
2016-12-25 11:32:46 +00:00
6666c28424 signal: change address argument type from unsigned long to kernel_ureg_t
* signal.c (print_sigqueueinfo): Change address argument type
from unsigned long to kernel_ureg_t.
2016-12-25 11:32:46 +00:00
53ec9ab555 statfs64: change size argument type from unsigned long to kernel_ureg_t
* defs.h (print_struct_statfs64): Change size argument type
from unsigned long to kernel_ureg_t.
* print_statfs.c (print_struct_statfs64): Likewise.
* fetch_struct_statfs.c (fetch_struct_statfs64): Likewise.
* fstatfs64.c (SYS_FUNC(fstatfs64)): Pass size argument directly
to print_struct_statfs64.
* statfs64.c (SYS_FUNC(statfs64)): Likewise.
2016-12-25 11:32:46 +00:00
db28c91159 Cast tcp->u_rval to kernel_ureg_t instead of unsigned long
* fcntl.c (print_fcntl): Cast tcp->u_rval to kernel_ureg_t instead
of unsigned long.
* membarrier.c (SYS_FUNC(membarrier)): Likewise.
* prctl.c (SYS_FUNC(prctl)): Likewise.
* sched.c (SYS_FUNC(sched_getscheduler)): Likewise.
* time.c (do_adjtimex): Likewise.
2016-12-25 11:32:46 +00:00
26102a5a87 decode_sockbuf: change addrlen argument type from long to kernel_ureg_t
* net.c (decode_sockbuf): Change addrlen argument type from long
to kernel_ureg_t.
2016-12-25 11:32:46 +00:00
b19829eaf4 netlink: change size types from unsigned long to kernel_ureg_t
* defs.h (decode_netlink): Change len argument type from unsigned long
to kernel_ureg_t.
* netlink.c (fetch_nlmsghdr): Likewise.
(decode_nlmsghdr_with_payload): Likewise.  Change nlmsg_len variable
type from unsigned long to unsigned int.
(decode_netlink): Change the type of len argument and next_len variable
from unsigned long to kernel_ureg_t.  Change nlmsg_len variable type
from unsigned long to unsigned int.
2016-12-25 11:32:46 +00:00
4ee3e80cb1 ipc_msg: change size types from unsigned long to kernel_ureg_t
* ipc_msg.c (tprint_msgsnd): Change count argument type
from unsigned long to kernel_ureg_t.  Change flags argument type
from unsigned long to unsigned int.
(tprint_msgrcv): Change the type of count and msgtyp arguments
from unsigned long to kernel_ureg_t.
(fetch_msgrcv_args): Change *pair type from unsigned long
to kernel_ureg_t.
(SYS_FUNC(msgrcv)): Change pair type from unsigned long
to kernel_ureg_t.
* print_msgbuf.c (tprint_msgbuf): Change count argument type
from unsigned long to kernel_ureg_t.
2016-12-25 11:32:46 +00:00
0601cf5939 dumpiov_upto: change size types from unsigned long to kernel_ureg_t
* defs.h (dumpiov_upto): Change data_size argument type
from unsigned long to kernel_ureg_t.
* util.c (dumpiov_upto): Change the type of data_size argument
and iov_len variable from unsigned long to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
27cc81d61f msghdr: change cmsghdr size types from size_t to unsigned int
As the kernel does not accept control messages longer than the value
of int sysctl_optmem_max kernel variable exported as
/proc/sys/net/core/optmem_max, we do not print them either.

Since unsigned int has enough room to contain any valid control message
size, change all internal cmsghdr size types from size_t
to unsigned int.

* msghdr.c (print_scm_rights, print_scm_creds, print_scm_security,
print_cmsg_ip_pktinfo, print_cmsg_uint, print_cmsg_uint8_t,
print_cmsg_ip_opts, print_cmsg_ip_recverr, print_cmsg_ip_origdstaddr,
cmsg_printer, print_cmsg_type_data): Change data_len argument type
from size_t to unsigned int.
(cmsg_socket_printers): Change min_len type from size_t to unsigned int.
(decode_msg_control): Change the type of in_control_len argument,
cmsg_len, and len variables from size_t to kernel_ureg_t.
Change the type of cmsg_size, control_len, and buf_len variables
from size_t to unsigned int.
2016-12-25 11:32:45 +00:00
121e148978 msghdr: change register based size types from unsigned long to kernel_ureg_t
* defs.h (dumpiov_in_msghdr): Change data_size argument type
from unsigned long to kernel_ureg_t.
* msghdr.h (print_struct_msghdr): Likewise.
* msghdr.c (print_struct_msghdr): Likewise.  Cast msghdr.msg_iovlen
and msghdr.msg_controllen to kernel_ureg_t instead of unsigned long.
(decode_msghdr, dumpiov_in_msghdr): Change data_size argument type
from unsigned long to kernel_ureg_t.
(SYS_FUNC(sendmsg)): Pass -1 instead of -1UL as data_size argument
to decode_msghdr.
* mmsghdr.c (print_struct_mmsghdr): Pass (kernel_ureg_t) -1 instead
of -1UL as data_size argument to print_struct_msghdr.
(dumpiov_in_mmsghdr): Cast msghdr.msg_iovlen to kernel_ureg_t instead
of unsigned long.
* syscall.c (dumpio): Pass -1 instead of -1UL as data_size argument
to dumpiov_in_msghdr
2016-12-25 11:32:45 +00:00
1049a1dae9 mq: remove redundant u_rval check
* mq.c (SYS_FUNC(mq_timedreceive)): Do not check for tcp->u_rval < 0,
syserror(tcp) is enough, and printstrn can handle len < 0 anyway.
2016-12-25 11:32:45 +00:00
3ccde53d7f io: change size types from unsigned long to kernel_ureg_t
* defs.h (tprint_iov_upto): Change the type of len and data_size
arguments from unsigned long to kernel_ureg_t.
(tprint_iov): Change the type of len argument from unsigned long
to kernel_ureg_t.
* io.c (print_iovec_config): Change data_size type from unsigned long
to kernel_ureg_t.
(print_iovec): Change the type of *iov, iov_buf, and len variables
from unsigned long to kernel_ureg_t.
(tprint_iov_upto): Change the type of len and data_size arguments, and
the type of iov variable from unsigned long to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
570314dd90 mount: change flags type from unsigned long to kernel_ureg_t
* mount.c (SYS_FUNC(mount)): Change the type of flags from unsigned long
to kernel_ureg_t, use printflags64 instead of printflags_long
to print it.
2016-12-25 11:32:45 +00:00
697ca3e41f mem: change mmap arguments type from unsigned long to kernel_ureg_t
* mem.c (print_mmap): Change the type of len, prot, and flags
from unsigned long to kernel_ureg_t.  Use printflags64 instead
of printflags_long.  Use printxval64 instead of printxval_long.
(SYS_FUNC(old_mmap)): Check for current_klongsize instead
of [AARCH64 || X86_64] to take X32 into account.
(SYS_FUNC(mremap)): Use printflags64 instead of printflags_long.
(SYS_FUNC(remap_file_pages)): Change the type of size, prot, pgoff, and
flags from unsigned long to kernel_ureg_t.  Use printflags64 instead
of printflags_long.  Use printxval64 instead of printxval_long.
[POWERPC] (SYS_FUNC(subpage_prot)): Change the type of len and nmemb
from unsigned long to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
f8b6389263 numa: change size arguments type from unsigned long to kernel_ureg_t
* numa.c (print_node, print_addr): Add kernel_ureg_t support.
(print_nodemask): Change type of maxnodes argument from unsigned long
to kernel_ureg_t.
(SYS_FUNC(move_pages)): Change npages type from unsigned long
to kernel_ureg_t.  Change buf type from long to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
a8bf674039 print_sigset_addr_len: change len argument type from long to kernel_ureg_t
* defs.h (print_sigset_addr_len): Change len argument type from long
to kernel_ureg_t.
* signal.c (print_sigset_addr_len_limit, print_sigset_addr_len): Likewise.
2016-12-25 11:32:45 +00:00
569dc792d5 process_vm: change size arguments type from unsigned long to kernel_ureg_t
* process_vm.c (SYS_FUNC(process_vm_readv),
SYS_FUNC(process_vm_writev)): Change the type of local_iovcnt,
remote_iovcnt, and flags from unsigned long to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
00785bf73a printstr*: change len argument type from long to kernel_ureg_t
* defs.h (printstr_ex, printstrn): Change len argument type from long
to kernel_ureg_t.
* util.c (printstr_ex): Likewise.
2016-12-25 11:32:45 +00:00
9ec1fb02ef xattr: change size arguments type from unsigned long to kernel_ureg_t
* xattr.c (print_xattr_val): Change type of insize and size arguments
from unsigned long to kernel_ureg_t.
(print_xattr_list): Change type of size argument from unsigned long
to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
a3c2e4e20b printstr_ex: fix decoding of non-NUL-terminated strings when len == -1
Do not treat len == -1 in any special way.  All users who need the
string to be handled as a NUL-terminated string set QUOTE_0_TERMINATED
bit in user_style flags already.

* util.c (printstr_ex): Remove (len == -1) check.
* tests/printstr.c: New file.
* tests/printstr.test: New test.
* tests/.gitignore: Add printstr.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add printstr.test.
2016-12-25 11:32:45 +00:00
9af28a4d13 Fix decoding of sethostname syscall
The second argument of sethostname syscall is not an unsigned long but
unsigned int.  The kernel does not look at the string argument when
the length argument is too long.

* hostname.c [HAVE_LINUX_UTSNAME_H]: Include <linux/utsname.h>.
[!__NEW_UTS_LEN] (__NEW_UTS_LEN): Define.
(SYS_FUNC(sethostname)): Treat the second argument as unsigned int.
Print the first argument as a pointer when the second argument exceeds
__NEW_UTS_LEN.
* tests/sethostname.c [HAVE_LINUX_UTSNAME_H]: Include <linux/utsname.h>.
[!__NEW_UTS_LEN] (__NEW_UTS_LEN): Define.
(main): Use it.  Check that the second argument of sethostname
is handled as unsigned int.  Check that the first argument is printed
as a pointer when the second argument exceeds __NEW_UTS_LEN.
2016-12-25 11:32:45 +00:00
bd43e0954b tests: add F8ILL_KULONG_* and f8ill_ptr_to_kulong to tests.h
* tests/tests.h (F8ILL_KULONG_SUPPORTED, F8ILL_KULONG_MASK): New macros.
(f8ill_ptr_to_kulong): New static inline function.
2016-12-25 11:32:45 +00:00
a940d1a60f printstr: rename to printstrn, add printstr as a thin wrapper
As about half of all printstr uses cases are invocations with the last
argument set to -1, create a dedicated function for this use case.

* defs.h (printstr): Rename to printstrn.  All callers updated.
(printstr): New static inline function.  All callers updated.
2016-12-25 11:32:45 +00:00
1cb75579e1 process: change ptrace arguments type from unsigned long to kernel_ureg_t
(SYS_FUNC(ptrace)): Change type of request and data arguments
from unsigned long to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
50cba466e5 process: change tracee address type from unsigned long to kernel_ureg_t
* process.c (print_user_offset_addr): Change address argument type
from unsigned long to kernel_ureg_t.
(SYS_FUNC(ptrace)): Change addr variable type from unsigned long
to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
405279fa77 net: change address argument type from long to kernel_ureg_t
* net.c (decode_sockbuf, decode_pair_fd, print_linger, print_ucred,
print_tpacket_stats, print_icmp_filter, print_getsockopt, print_mreq,
print_mreq6, print_group_req, print_tpacket_req, print_packet_mreq,
print_setsockopt): Change address argument type from long
to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
aff8528b22 print_mq_attr: change address argument type from long to kernel_ureg_t
* print_mq_attr.c (printmqattr): Change address argument type from long
to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
91b63a91ae ipc_*: change address argument type from long to kernel_ureg_t
* ipc_msg.c (tprint_msgsnd, tprint_msgrcv, fetch_msgrcv_args): Change
address argument type from long to kernel_ureg_t.
* ipc_msgctl.c (print_msqid_ds): Likewise.
* ipc_sem.c (tprint_sembuf_array): Likewise.
* ipc_shmctl.c (print_shmid_ds): Likewise.
2016-12-25 11:32:45 +00:00
fdcaa2fa42 print_msgbuf: change address argument type from long to kernel_ureg_t
* print_msgbuf.c (tprint_msgbuf): Change address argument type
from long to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
d4e4e873ee desc: change tracee address type from long to kernel_ureg_t
* desc.c (decode_select): Rename arg to addr, change its type
from long to kernel_ureg_t.
2016-12-25 11:32:45 +00:00
fae76db73b uid: change address argument type from long to kernel_ureg_t
* uid.c (get_print_uid): Change address argument type
from long to kernel_ureg_t.
2016-12-25 11:32:44 +00:00
93e2dfe0e5 time: change address argument type from long to kernel_ureg_t
* time.c (print_timezone, do_adjtimex): Change address argument type
from long to kernel_ureg_t.
2016-12-25 11:32:44 +00:00
4f486f8207 sched: change address argument type from long to kernel_ureg_t
* sched.c (print_sched_attr): Change address argument type
from long to kernel_ureg_t.
2016-12-25 11:32:44 +00:00
1575c3115a printsiginfo: change address argument type from long to kernel_ureg_t
* printsiginfo.c (printsiginfo_at): Change address argument type
from long to kernel_ureg_t.
2016-12-25 11:32:44 +00:00
38392acb35 print_timex: change address argument type from long to kernel_ureg_t
* print_timex.c (print_timex): Change address argument type
from long to kernel_ureg_t.
2016-12-25 11:32:44 +00:00
7f83dba279 print_sigevent: change address argument type from long to kernel_ureg_t
* print_sigevent.c (print_sigevent): Change address argument type
from long to kernel_ureg_t.
2016-12-25 11:32:44 +00:00
1c3c1ae44e poll: change address argument type from long to kernel_ureg_t
* poll.c (decode_poll_exiting): Change tracee address argument type
from long to kernel_ureg_t.
2016-12-25 11:32:44 +00:00
3f8d42d94f printrusage*: change tracee address argument type from long to kernel_ureg_t
* defs.h [ALPHA] (printrusage32): Change address argument type
from long to kernel_ureg_t.
* printrusage.c (printrusage): Likewise.
[ALPHA] (printrusage32): Likewise.
* wait.c (printwaitn): Change the type of tracee address argument
of print_rusage from long to kernel_ureg_t.
2016-12-25 11:32:44 +00:00
61b2e2199f print_time*: change tracee address argument type from long to kernel_ureg_t
* defs.h [ALPHA] (sprint_timeval32, print_timeval32,
print_timeval32_pair, print_itimerval32): Change address argument type
from long to kernel_ureg_t.
* desc.c (decode_select): Change the type of tracee address argument
of print_tv_ts and sprint_tv_ts from long to kernel_ureg_t.
* print_timespec.c (print_timespec, sprint_timespec,
print_timespec_utime_pair, print_itimerspec): Change address argument
type from long to kernel_ureg_t.
* print_timeval.c (print_timeval, print_timeval_pair, sprint_timeval,
print_itimerval, print_timeval32, print_timeval32_pair,
print_itimerval32, sprint_timeval32): Likewise.
2016-12-25 11:32:44 +00:00
033c9cfc13 rtc: change type of ioctl 3rd argument from long to kernel_ureg_t
* rtc.c (decode_rtc_time, decode_rtc_wkalrm, decode_rtc_pll_info):
Change addr type from long to kernel_ureg_t.
(rtc_ioctl): Change arg type from long to kernel_ureg_t.
2016-12-25 11:32:44 +00:00
16300524f2 mtd: change type of ioctl 3rd argument from long to kernel_ureg_t
* mtd.c (decode_erase_info_user, decode_erase_info_user64,
decode_mtd_oob_buf, decode_mtd_oob_buf64, decode_otp_info,
decode_otp_select, decode_mtd_write_req, decode_mtd_info_user,
decode_nand_oobinfo, decode_nand_ecclayout_user, decode_mtd_ecc_stats):
Change addr type from long to kernel_ureg_t.
(mtd_ioctl): Change arg type from long to kernel_ureg_t.
2016-12-25 11:32:44 +00:00
e86ff37e3f hdio: change type of ioctl 3rd argument from long to kernel_ureg_t
* hdio.c (hdio_ioctl): Change arg type from long to kernel_ureg_t.
2016-12-25 11:32:44 +00:00