Commit Graph

5877 Commits

Author SHA1 Message Date
Eugene Syromyatnikov
3de6f8fe8a Return 0 instead of 1 on entering path of ioctl decoders
As returning 1 (without RVAL_DECODED) on entering makes no sense.

* block.c (block_ioctl) <case BLKTRACESETUP>: Replace return 1 with
return 0 on entering path.
* ptp.c (ptp_ioctl) <case PTP_SYS_OFFSET>: Likewise.
* sg_io_v3.c (decode_request): Likewise.
* sg_io_v4.c (decode_request): Likewise.
* sock.c (decode)ifconf, sock_ioctl) <case SIOCGIFMAP>: Likewise.
* ubi.c (ubi_ioctl) <case UBI_IOCMKVOL, case UBI_IOCATT>: Likewise.
* v4l2.c (print_v4l2_ext_controls): Likewise.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-08-28 02:33:20 +02:00
Eugene Syromyatnikov
6e4aead09e ioctl: simplify ioctl_decode handling, document its return value semantics
* ioctl.s (SYS_FUNC(ioctl.c)): Unconditionally unset 1, simply print arg
when (ret & RVAL_DECODED) && !(ret & 1).
2017-08-28 02:33:20 +02:00
Eugene Syromyatnikov
39f5a9cd2d syscall.c: define personality names for all multi-personality architectures
I see no reason for not having these definitions for SPARC64 and RISC-V.
Also, borrow the check template from supported_personalities.h.

* syscall.c (update_personality) [defined RISCV, defined SPARC64]
<PERSONALITY_NAMES>: Define it for these architectures.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-08-28 02:32:52 +02:00
Eugene Syromyatnikov
f07e8ada33 copyright-year-gen: workaround for old git versions
Apply the same treatment to this script as the one in
v4.18-278-g295cf32.

* copyright-year-gen <year>: Change format to format:%cD, remove --date,
supply output as a -d option argument to date +%Y.
2017-08-28 02:31:33 +02:00
Eugene Syromyatnikov
12087b7570 ubi: trim overly long lines 2017-08-27 11:06:14 +00:00
Eugene Syromyatnikov
baabc17725 term: use print_quoted_string
* term.c (decode_termios): Use print_quoted_string for printing c_cc field
instead of writing the printing code by hand.
2017-08-27 11:06:14 +00:00
Eugene Syromyatnikov
295cf322b1 update_copyright_years.sh: workaround for old git versions
Old git versions (like the one shipped in Debian 8) do not support setting
date format with --date, working this around by processing git log output
with date +%Y.

* main/update_copyright_years.sh (process_file) <first_commit_year,
last_commit_year>: Change format to format:%aD, remove --date, supply
output as a -d option argument to date +%Y.
2017-08-27 11:06:14 +00:00
Eugene Syromyatnikov
dbf939d19d syscall: use spaces in tile personality names, de-duplicate definition
As Chris Metcalf, the author of v4.7-40-g0b99a8a, told in private, there
is no strong reason for having tile's personality name different from
personality names on other architectures, so let's use spaces instead of
dashes here. And, while we are here, remove duplication of personality
name definitions for various architectures.

* syscall.c (update_personality) [defined TILE]: Change dashes to spaces
in personality names.
2017-08-27 11:06:14 +00:00
JingPiao Chen
bec0ab989d tests: check decoding of rtmsg netlink attributes
* tests/nlattr_rtmsg.c: Include <netinet/in.h> and <arpa/inet.h>.
(LWTUNNEL_ENCAP_NONE, RTA_ENCAP_TYPE): New macros.
(main): Check decoding of RTA_DST, RTA_OIF, RTA_METRICS, RTA_MULTIPATH,
RTA_CACHEINFO, RTA_MFC_STATS, RTA_VIA, and RTA_ENCAP_TYPE.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-08-26 23:09:09 +00:00
JingPiao Chen
e8a856f4bd rtnl_route: decode rtmsg netlink attributes
* configure.ac (AC_CHECK_TYPES): Check for
rta_mfc_stats and rtvia structures in <linux/rtnetlink.h>.
* nlattr.c (decode_nla_ifindex): New function.
* nlattr.h (decode_nla_ifindex): New prototype.
* rtnl_route.c (decode_route_addr, decode_rta_metrics,
decode_rta_multipath, decode_rta_cacheinfo,
decode_rta_mfc_stats, decode_rtvia,
decode_rta_encap_type): New functions.
(rta_metrics_nla_decoders, rtmsg_nla_decoders): New arrays.
(decode_rtmsg): Use rtmsg_nla_decoders.
* xlat/lwtunnel_encap_types.in: New file.
* xlat/route_nexthop_flags.in: Likewise.
* xlat/rtnl_rta_metrics_attrs.in: Likewise.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-08-26 16:45:18 +00:00
5634008d6e s390: wire up s390_guarded_storage syscall
* linux/s390/syscallent.h [378]: Add s390_guarded_storage entry.
* linux/s390x/syscallent.h: Likewise.
2017-08-25 15:57:14 +00:00
194a8bc7fa microblaze: wire up statx syscall
* linux/microblaze/syscallent.h [398]: Add statx entry.
2017-08-25 15:57:14 +00:00
1998f2666a alloc_number_set_array: add ATTRIBUTE_MALLOC
* number_set.h: Include "gcc_compat.h".
(alloc_number_set_array): Add ATTRIBUTE_MALLOC.
2017-08-24 18:24:16 +00:00
Nikolay Marchuk
ff8e066b3c Add macros for testing QUAL_* flags
* defs.h (traced, raw, inject): Add macros for testing QUAL_TRACE,
QUAL_RAW, and QUAL_INJECT flags.
* syscall.c (syscall_entering_trace, syscall_exiting_trace): Use them.
2017-08-24 18:24:16 +00:00
19cf122dd6 Remove QUAL_SIGNAL, QUAL_READ and QUAL_WRITE
Remove these flags that are unused since commit v4.15~26.
They might be introduced later with a different meaning.

* defs.h (QUAL_SIGNAL, QUAL_READ, QUAL_WRITE): Remove.
2017-08-24 18:24:16 +00:00
Eugene Syromiatnikov
7ba0d89c9f xstrdup, xtrndup: allow NULL argument
Accept NULL argument in xstrdup and xtrndup functions to allow use
of "xstrdup(str)" instead of "str ? xstrdup(str) : NULL".

* xmalloc.c (xstrdup, xstrndup): Handle NULL argument.
* xmalloc.h: Add comment regarding this deviation from the behaviour
of the POSIX counterparts of these functions.
2017-08-24 20:06:54 +02:00
2b786e0113 tests: really skip mips o32 scno tampering tests on mips n64
* tests/is_linux_mips_n64.c: New file.
* tests/Makefile.am (check_PROGRAMS): Add it.
* tests/scno_tampering.sh <$STRACE_ARCH == mips>:
In case of mips o32 abi, skip the test if is_linux_mips_n64 says
that the kernel is mips n64, even if "uname -m" claims it's mips.
2017-08-23 18:38:26 +00:00
5d7623a502 Hide struct number_set implementation details from users
* number_set.h (number_slot_t, struct number_set): Move to number_set.c.
(struct number_set): Add forward declaration.
(read_set, write_set, signal_set): Change prototypes from objects
to pointers.
* filter_qualify.c (read_set, write_set, signal_set): Change definitions
from objects to pointers.
(abbrev_set, inject_set, raw_set, trace_set, verbose_set): Change
definitions from arrays to pointers.
(qualify_read): Initialize read_set before first use.
(qualify_write): Initialize write_set before first use.
(qualify_signals): Initialize signal_set before first use.
(qualify_trace): Initialize trace_set before first use.
(qualify_abbrev): Initialize abbrev_set before first use.
(qualify_verbose): Initialize verbose_set before first use.
(qualify_raw): Initialize raw_set before first use.
(qualify_inject_common): Initialize inject_set before first use.
* strace.c (print_signalled, print_stopped): Update signal_set usage.
* syscall.c (dumpio): Update usage of read_set and write_set.
2017-08-22 21:23:49 +00:00
ef7b7a70c1 Extend number_set interface
* number_set.h (number_set_array_is_empty, is_number_in_set_array,
add_number_to_set_array, clear_number_set_array,
invert_number_set_array, alloc_number_set_array, free_number_set_array):
New function prototypes.
* number_set.c (number_set_array_is_empty, is_number_in_set_array,
add_number_to_set_array, clear_number_set_array,
invert_number_set_array, alloc_number_set_array, free_number_set_array):
New functions.
* basic_filters.c (qualify_syscall_number, qualify_syscall_regex,
qualify_syscall_class, qualify_syscall_name): Use
add_number_to_set_array.
(qualify_syscall_tokens, qualify_tokens): Use
clear_number_set_array and invert_number_set_array.
* filter_qualify.c (qualify_inject_common): Use alloc_number_set_array,
number_set_array_is_empty, is_number_in_set_array,
add_number_to_set_array, and free_number_set_array.
(qual_flags): Use is_number_in_set_array.
2017-08-22 21:23:49 +00:00
67c97082ac Move number_set interface to separate files
* number_set.c: New file.
* number_set.h: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* basic_filters.c: Include "number_set.h".
(number_slot_t, struct number_set): Move to number_set.h.
(BITS_PER_SLOT, number_setbit, number_isset, reallocate_number_set,
add_number_to_set, is_number_in_set): Move to number_set.c.
* defs.h (struct number_set): Remove forward declaration.
(read_set, write_set, signal_set, is_number_in_set): Move to number_set.h.
* filter.h (add_number_to_set): Move to number_set.h.
* filter_qualify.c: Include "number_set.h".
(number_slot_t, struct number_set): Remove.
* strace.c: Include "number_set.h".
* syscall.c: Likewise.
2017-08-22 21:23:49 +00:00
Edgar Kaziakhmedov
e398011d2b Move SUPPORTED_PERSONALITIES to a separate file
Since the defs.h contains unrelated declarations which are
redundant (and sometimes conflicting) for other binaries included
in the strace package, move SUPPORTED_PERSONALITIES defintions
to a separate file.

* defs.h: Include "supported_personalities.h".
(SUPPORTED_PERSONALITIES): Move ...
* supported_personalities.h: ... to the new file.
* Makefile.am (strace_SOURCES): Add it.

Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2017-08-22 15:24:05 +00:00
Edgar Kaziakhmedov
b1fab45b47 Move string_to_uint* functions to a separate file
Make string_to_uint* functions available to other binaries
included in the strace package.

* string_to_uint.h: New file.
* defs.h: Include it.
(string_to_uint_ex, string_to_uint_upto, string_to_uint): Move
to string_to_uint.h.
* util.c (string_to_uint_ex, string_to_uint): Move ...
* string_to_uint.c: ... to the new file.
* Makefile.am (strace_SOURCES): Add string_to_uint.h and string_to_uint.c.

Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2017-08-22 15:24:05 +00:00
JingPiao Chen
bc9fd5ffb9 tests: check decoding of ifaddrmsg netlink attributes
* tests/nlattr_ifaddrmsg.c: Include <arpa/inet.h>.
(IFA_FLAGS, SET_IFA_FAMILY): New macros.
(init_ifaddrmsg): Set ifaddrmsg.ifa_family field from ifa_family.
(print_ifaddrmsg): Print ifaddrmsg.ifa_family field using ifa_family_str.
(main): Check decoding of IFA_ADDRESS, IFA_CACHEINFO, and IFA_FLAGS.
2017-08-22 11:39:03 +00:00
JingPiao Chen
f076c78667 rtnl_addr: decode ifaddrmsg netlink attributes
* rtnl_addr.c (decode_ifa_address,
decode_ifa_cacheinfo, decode_ifa_flags): New functions.
(ifaddrmsg_nla_decoders): New array.
(decode_ifaddrmsg): Use it.
2017-08-22 11:39:03 +00:00
89cab1f000 Export decode_inet_addr
* defs.h (decode_inet_addr): New prototype.
* netlink_inet_diag.c (decode_inet_addr): Remove static keyword, move ...
* sockaddr.c: ... here.
2017-08-22 11:39:03 +00:00
7c6f8ad313 netlink_inet_diag: prepare decode_inet_addr for export
* netlink_inet_diag.c (decode_inet_addr): Change return type to bool,
parametrize field name using new var_name argument.
(decode_inet_diag_hostcond): Specify "addr" field name
to decode_inet_addr.
2017-08-22 11:39:03 +00:00
b3cbf90920 print_inet_addr: add support of invocations without field name
Prepare print_inet_addr for use in structureless contexts where
no structure field name is available.

* sockaddr.c (print_inet_addr): Handle var_name == NULL.
2017-08-20 11:10:03 +00:00
6a54605010 print_inet_addr: print address of unsupported family in hex
* sockaddr.c (print_inet_addr): Specify QUOTE_FORCE_HEX
to print_quoted_string.
2017-08-19 11:04:00 +00:00
25f91fd854 mips o32: do not bail out in get_syscall_args if umoven fails
If the kernel contains commit 84d77d3f06e7e8dea057d10e8ec77ad71f721be3,
both PTRACE_PEEKDATA and process_vm_readv become unavailable when the
process dumpable flag is cleared.  As the first 4 syscall arguments are
still available via registers, do not treat this as get_syscall_args
error.

This condition is triggered and therefore tested by prctl-dumpable test.

* linux/mips/get_syscall_args.c (get_syscall_args) [LINUX_MIPSO32]:
Do not bail out if umoven fails.
2017-08-18 14:30:08 +00:00
dac32d406f configure: cleanup struct statfs/statfs64 member checks
* configure.ac <AC_CHECK_TYPES([struct statfs])>: Merge several
AC_CHECK_MEMBERS checks of struct statfs members into a single check.
<AC_CHECK_TYPES([struct statfs64])>: Likewise, for checks
of struct statfs64 members.
2017-08-17 12:43:18 +00:00
1cd860cc6c tests: fix a few harmless -Woverflow compilation warnings
Fix the following compilation warnings on platforms where
sizeof(struct timeval.tv_usec) < sizeof(long):

xettimeofday.c: In function ‘main’:
xettimeofday.c:76:16: warning: overflow in implicit constant conversion [-Woverflow]
  tv->tv_usec = (long) 0xbadc0dedfacefeedLL;
xetitimer.c: In function ‘main’:
xetitimer.c:170:28: warning: overflow in implicit constant conversion [-Woverflow]
  p_new->it_value.tv_usec = (long) 0xbadc0dedfacefeedLL;
In file included from utimes.c:38:0:
xutimes.c: In function ‘main’:
xutimes.c:110:18: warning: overflow in implicit constant conversion [-Woverflow]
  tv[1].tv_usec = (long) 0xbadc0dedfacefeedLL;
futimesat.c: In function ‘main’:
futimesat.c:121:18: warning: overflow in implicit constant conversion [-Woverflow]
  tv[1].tv_usec = (long) 0xbadc0dedfacefeedLL;
In file included from _newselect.c:35:0:
xselect.c: In function ‘main’:
xselect.c:94:16: warning: overflow in implicit constant conversion [-Woverflow]
  tv->tv_usec = (long) 0xbadc0dedfacefeedLL;
                ^
* tests/futimesat.c (main): In initialization of struct timeval.tv_usec,
change explicit cast from (long) to (suseconds_t).
* tests/xetitimer.c: Likewise.
* tests/xettimeofday.c: Likewise.
* tests/xselect.c: Likewise.
* tests/xutimes.c: Likewise.

Reported-by: Anatoly Pugachev <matorola@gmail.com>
2017-08-16 17:50:25 +00:00
06c4151a49 tests: fix sigaction.test on sparc
On sparc, the first argument of old sigaction syscall has negated
semantics, compared to other architectures.  While sigaction.test
was aware about this arch-specific detail from the beginning, in one
of many sigaction syscall invocations a non-negative signal number
was erroneously passed on sparc.

* tests/sigaction.c (ADDR_INT, SIGNO_INT): New arch-specific macros.
(signo, addr): Use them.
2017-08-16 16:25:03 +00:00
239418b7f8 nlattr: fix printing of unrecognized attribute data
Do not print more than "nlattr.nla_len - NLA_HDRLEN" bytes
of unrecognized attribute data.

* nlattr.c (decode_nlattr_with_data): Specify "nla_len - NLA_HDRLEN"
instead of "len - NLA_HDRLEN" as the size of unrecognized attribute
data.
* tests/nlattr.c (test_nlattr): Check it.
2017-08-16 02:24:29 +00:00
JingPiao Chen
c7946d380f tests: check decoding of NETLINK_ROUTE rtgenmsg attributes
* tests/nlattr_rtgenmsg.c: New file.
* tests/gen_tests.in (nlattr_rtgenmsg): New entry.
* tests/pure_executables.list: Add nlattr_rtgenmsg.
* tests/.gitignore: Likewise.
2017-08-15 22:34:46 +00:00
JingPiao Chen
b9afb63fd7 netlink: add basic decoding of NETLINK_ROUTE rtgenmsg attributes
* rtnl_nsid.c: Include "nlattr.h" and "xlat/rtnl_nsid_attrs.h".
(decode_rtgenmsg): Call decode_nlattr.
* xlat/rtnl_nsid_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-08-15 22:34:46 +00:00
JingPiao Chen
4c1e85025f tests: check decoding of NETLINK_ROUTE br_port_msg attributes
* tests/nlattr_br_port_msg.c: New file.
* tests/gen_tests.in (nlattr_br_port_msg): New entry.
* tests/pure_executables.list: Add nlattr_br_port_msg.
* tests/.gitignore: Likewise.
2017-08-15 22:34:46 +00:00
JingPiao Chen
a4ae112a42 netlink: add basic decoding of NETLINK_ROUTE br_port_msg attributes
* rtnl_mdb.c: Include "netlink.h", "nlattr.h".
and "xlat/rtnl_mdb_attrs.h".
(decode_br_port_msg): Call decode_nlattr.
* xlat/rtnl_mdb_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-08-15 22:34:46 +00:00
JingPiao Chen
ef4feccbad tests: check decoding of NETLINK_ROUTE netconfmsg attributes
* tests/nlattr_netconfmsg.c: New file.
* tests/gen_tests.in (nlattr_netconfmsg): New entry.
* tests/pure_executables.list: Add nlattr_netconfmsg.
* tests/.gitignore: Likewise.
2017-08-15 22:34:46 +00:00
JingPiao Chen
1569f4cfe5 netlink: add basic decoding of NETLINK_ROUTE netconfmsg attributes
* rtnl_netconf.c: Include "netlink.h", "nlattr.h",
and "xlat/rtnl_netconf_attrs.h".
(decode_netconfmsg): Call decode_nlattr.
* xlat/rtnl_netconf_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-08-15 22:34:46 +00:00
JingPiao Chen
3d27e43d82 tests: check decoding of NETLINK_ROUTE dcbmsg attributes
* tests/nlattr_dcbmsg.c: New file.
* tests/gen_tests.in (nlattr_dcbmsg): New entry.
* tests/pure_executables.list: Add nlattr_dcbmsg.
* tests/.gitignore: Likewise.
2017-08-15 22:34:46 +00:00
JingPiao Chen
1c3e1828dc netlink: add basic decoding of NETLINK_ROUTE dcbmsg attributes
* rtnl_dcb.c: Include "netlink.h", "nlattr.h",
and "xlat/rtnl_dcb_attrs.h".
(decode_dcbmsg): Call decode_nlattr.
* xlat/rtnl_dcb_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-08-15 22:34:46 +00:00
JingPiao Chen
a93b5fa242 tests: check decoding of NETLINK_ROUTE ifaddrlblmsg attributes
* tests/nlattr_ifaddrlblmsg.c: New file.
* tests/gen_tests.in (nlattr_ifaddrlblmsg): New entry.
* tests/pure_executables.list: Add nlattr_ifaddrlblmsg.
* tests/.gitignore: Likewise.
2017-08-15 22:34:46 +00:00
JingPiao Chen
52a55f2081 netlink: add basic decoding of NETLINK_ROUTE ifaddrlblmsg attributes
* rtnl_addrlabel.c: Include "netlink.h", "nlattr.h",
and "xlat/rtnl_addrlabel_attrs.h".
(decode_ifaddrlblmsg): Call decode_nlattr.
* xlat/rtnl_addrlabel_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-08-15 22:34:46 +00:00
JingPiao Chen
2795dde450 tests: check decoding of NETLINK_ROUTE tcamsg attributes
* tests/nlattr_tcamsg.c: New file.
* tests/gen_tests.in (nlattr_tcamsg): New entry.
* tests/pure_executables.list: Add nlattr_tcamsg.
* tests/.gitignore: Likewise.
2017-08-15 22:34:46 +00:00
JingPiao Chen
41d9c32e95 netlink: add basic decoding of NETLINK_ROUTE tcamsg attributes
* rtnl_tc_action.c: Include "nlattr.h" and "xlat/rtnl_tc_action_attrs.h".
(decode_tcamsg): Call decode_nlattr.
* xlat/rtnl_tc_action_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-08-15 22:34:46 +00:00
JingPiao Chen
7506c69c3a tests: check decoding of NETLINK_ROUTE tcmsg attributes
* tests/nlattr_tcmsg.c: New file.
* tests/gen_tests.in (nlattr_tcmsg): New entry.
* tests/pure_executables.list: Add nlattr_tcmsg.
* tests/.gitignore: Likewise.
2017-08-15 22:34:46 +00:00
JingPiao Chen
52eccecda5 netlink: add basic decoding of NETLINK_ROUTE tcmsg attributes
* rtnl_tc.c: Include "nlattr.h" and "xlat/rtnl_tc_attrs.h".
(decode_tcmsg): Call decode_nlattr.
* xlat/rtnl_tc_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-08-15 22:34:46 +00:00
JingPiao Chen
72f13278be tests: check decoding of NETLINK_ROUTE ndtmsg attributes
* tests/nlattr_ndtmsg.c: New file.
* tests/gen_tests.in (nlattr_ndtmsg): New entry.
* tests/pure_executables.list: Add nlattr_ndtmsg.
* tests/.gitignore: Likewise.
2017-08-15 22:34:46 +00:00
JingPiao Chen
46e2c5226a netlink: add basic decoding of NETLINK_ROUTE ndtmsg attributes
* rtnl_neightbl.c: Include "nlattr.h" and "xlat/rtnl_neightbl_attrs.h".
(decode_ndtmsg): Call decode_nlattr.
* xlat/rtnl_neightbl_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
2017-08-15 22:34:46 +00:00
JingPiao Chen
daf21282d1 tests: check decoding of NETLINK_ROUTE ndmsg attributes
* tests/nlattr_ndmsg.c: New file.
* tests/gen_tests.in (nlattr_ndmsg): New entry.
* tests/pure_executables.list: Add nlattr_ndmsg.
* tests/.gitignore: Likewise.
2017-08-15 22:34:46 +00:00