error_prints: fix potential program_invocation_name type conflict
uClibc-ng declares program_invocation_name as const.
This causes the build failure below:
error_prints.c:40:14: error: conflicting types for ‘program_invocation_name’
extern char *program_invocation_name;
^~~~~~~~~~~~~~~~~~~~~~~
In file included from error_prints.c:32:0:
.../output/host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/errno.h:54:20: note: previous declaration of ‘program_invocation_name’ was here
extern const char *program_invocation_name, *program_invocation_short_name;
^~~~~~~~~~~~~~~~~~~~~~~
* error_prints.c (program_invocation_name): Declare only in case
of [!HAVE_PROGRAM_INVOCATION_NAME].
* configure.ac (AC_CHECK_TYPES): Check for gnet_stats_basic,
gnet_stats_queue, gnet_stats_rate_est,
and gnet_stats_rate_est64 structures in <linux/gen_stats.h>.
And check for struct tc_sizespec in <linux/pkt_sched.h>.
* nlattr.h (tc_stats): New prototype.
* rtnl_tc.c: Include <linux/gen_stats.h>, <linux/pkt_sched.h>,
"xlat/rtnl_tca_stab_attrs.h" and "xlat/rtnl_tca_stats_attrs.h".
(decode_tc_stats, decode_tc_estimator, decode_gnet_stats_basic,
decode_gnet_stats_rate_est, decode_gnet_stats_queue,
decode_gnet_stats_rate_est64, decode_nla_tc_stats,
decode_tc_sizespec, print_stab_data, decode_tca_stab_data,
decode_tca_stab): New functions.
(tca_stats_nla_decoders, tca_stab_nla_decoders,
tcmsg_nla_decoders): New arrays.
(decode_tcmsg): Use tcmsg_nla_decoders.
* xlat/rtnl_tca_stab_attrs.in: New file.
* xlat/rtnl_tca_stats_attrs.in: Likewise.
update_copyright_years.sh: add ability to automatically commit results
* maint/update_copyright_years.sh (DEFAULT_GIT_COMMIT_MESSAGE,
GIT_COMMIT_MESSAGE): New variables.
<-c>: New option, implies -a, calls git commit with GIT_COMMIT_TEMPLATE string
as a template.
tests: check decoding of more ifinfomsg netlink attributes
* tests/nlattr_ifinfomsg.c (IFLA_LINKINFO, IFLA_VF_PORTS,
IFLA_INFO_KIND, IFLA_VF_PORT): New macros.
(main): Check decoding of IFLA_LINKINFO and IFLA_VF_PORTS.
* tests/keyctl.c: Since do_keyctl() has so convoluted calling convention
and keyctl test is so complex, let's try to improve readability a bit
with some conventions regarding do_keyctl() call formatting: arguments
representing single keyctl argument should be put on the separate line,
continuations of arguments related to the same keyctl argument should
have additional indentation and termination 0UL should always be
on a separate line. Also, while we are here, let's add spaces
to two type casts that are missing them.
rtnl_link: enhance decoding of struct rtnl_link_stats{,64}
Enhance runtime detection of struct rtnl_link_stats.rx_nohandler
and struct rtnl_link_stats64.rx_nohandler.
* rtnl_link.c (decode_rtnl_link_stats): Do not accept structure length
greater than min_size but less than sizeof(struct rtnl_link_stats).
(decode_rtnl_link_stats64): Likewise, so not accept structure length
greater than min_size but less than sizeof(struct rtnl_link_stats64).
JingPiao Chen [Sun, 27 Aug 2017 08:12:11 +0000 (16:12 +0800)]
rtnl_link: decode IFLA_PROTINFO netlink attribute of ifinfomsg
* configure.ac (AC_CHECK_TYPES): Check for ifla_bridge_id
and rtnl_link_stats64 structures in <linux/if_link.h>.
* rtnl_link.c: Include "xlat/rtnl_ifla_brport_attrs.h".
(decode_ifla_bridge_id, decode_ifla_protinfo): New functions.
(ifla_brport_nla_decoders): New array.
(ifinfomsg_nla_decoders) <IFLA_PROTINFO>: Use decode_ifla_protinfo.
* xlat/rtnl_ifla_brport_attrs.in: New file.
JingPiao Chen [Wed, 30 Aug 2017 13:51:30 +0000 (21:51 +0800)]
rtnl_neightbl: decode ndtmsg netlink attributes
* configure.ac (AC_CHECK_TYPES): Check for ndt_config
and ndt_stats structures in <linux/neighbour.h>.
(AC_CHECK_MEMBERS): Check for ndts_table_fulls field in struct ndt_stats.
* rtnl_neightbl.c: Include "xlat/rtnl_neightbl_parms_attrs.h".
(decode_ndt_config, decode_ndta_parms, decode_ndta_parms): New functions.
(ndt_parms_nla_decoders, ndtmsg_nla_decoders): New arrays.
(decode_ndtmsg): Use ndtmsg_nla_decoders.
* xlat/rtnl_neightbl_parms_attrs.in: New file.
Dmitry V. Levin [Thu, 31 Aug 2017 09:54:24 +0000 (09:54 +0000)]
mpers.awk: declare local variables consistently
* mpers.awk (compare_indices): Make c1 and c2 variables local.
(enter): Make item variable local.
(what_is): Make loc_diff, returned_size, and to_return local.
Dmitry V. Levin [Tue, 29 Aug 2017 10:09:04 +0000 (10:09 +0000)]
rtnl_route: enhance RTA_TABLE decoding
The attribute of RTA_TABLE is not just a 32-bit integer, some constants
have well-known symbolic names like RT_TABLE_DEFAULT.
* nlattr.h (decode_nla_rt_class): New prototype.
* rtnl_route.c (decode_nla_rt_class): New function.
(rtmsg_nla_decoders) <RTA_TABLE>: Use it.
* tests/nlattr_rtmsg.c (main): Check RTA_TABLE decoding.
JingPiao Chen [Sun, 27 Aug 2017 16:56:41 +0000 (00:56 +0800)]
tests: check decoding of ndmsg netlink attributes
* tests/nlattr_ndmsg.c: Include <netinet/in.h> and <arpa/inet.h>.
(NDA_PORT): New macro.
(main): Check decoding of NDA_DST, NDA_CACHEINFO and NDA_PORT.
JingPiao Chen [Sun, 27 Aug 2017 16:46:22 +0000 (00:46 +0800)]
rtnl_neigh: decode ndmsg netlink attributes
* nlattr.c: Include <netinet/in.h> and <arpa/inet.h>.
(decode_nla_be16): New function.
* nlattr.h (decode_nla_be16): New prototype.
* rtnl_neigh.c (decode_neigh_addr,
decode_nda_cacheinfo): New functions.
(ndmsg_nla_decoders): New array.
(decode_ndmsg): Use it.
JingPiao Chen [Sun, 27 Aug 2017 16:37:33 +0000 (00:37 +0800)]
tests: check decoding of fib_rule_hdr netlink attributes
* tests/nlattr_fib_rule_hdr.c: Include <inttypes.h>.
(FRA_TUN_ID, FRA_UID_RANGE): New macros.
(main): Check decoding of FRA_DST, FRA_UID_RANGE and FRA_TUN_ID.
JingPiao Chen [Sun, 27 Aug 2017 16:33:30 +0000 (00:33 +0800)]
rtnl_rule: decode fib_rule_hdr netlink attributes
* configure.ac (AC_CHECK_FUNCS): Add be64toh.
(AC_CHECK_TYPES): Check for struct fib_rule_uid_range
in <linux/fib_rules.h>.
* nlattr.c: Include <endian.h>.
(decode_nla_be64): New function.
* nlattr.h (decode_nla_be64): New prototype.
* rtnl_rule.c (decode_rule_addr,
decode_fib_rule_uid_range): New functions.
(fib_rule_hdr_nla_decoders): New array.
(decode_fib_rule_hdr): Use it.
Dmitry V. Levin [Mon, 28 Aug 2017 22:37:27 +0000 (22:37 +0000)]
Add "flags" field to struct inject_data
Introduce "flags" field to struct inject_data and use it instead
of magic rval and signo constants.
Due to layout of struct inject_data, this new field does not change
sizeof(struct inject_data).
* defs.h (INJECT_F_RETVAL, INJECT_F_SIGNAL): New macros.
(INJECT_OPTS_RVAL_DEFAULT): Remove macro.
(struct inject_data): Add "flags" field.
* filter_qualify.c (parse_inject_token, qualify_inject_common): Check
struct inject_data.flags instead of inject_data.rval
and inject_data.signo, do not initialize inject_opts.data.
* syscall.c (tamper_with_syscall_entering): Check struct
inject_data.flags instead of inject_data.rval and inject_data.signo.
Dmitry V. Levin [Mon, 28 Aug 2017 22:37:27 +0000 (22:37 +0000)]
Move inject data of struct inject_opts to inject_data substructure
* defs.h (inject_data): New structure.
(struct inject_opts): Replace "signo" and "rval" fields with "data"
field of type "struct inject_data".
* filter_qualify.c (parse_inject_token, qualify_inject_common): Update
for the new layout of struct inject_opts.
* syscall.c (tamper_with_syscall_entering, tamper_with_syscall_exiting):
Likewise.
Co-authored-by: Victor Krapivensky <krapivenskiy.va@phystech.edu>
JingPiao Chen [Sun, 27 Aug 2017 15:55:14 +0000 (23:55 +0800)]
tests: check decoding of ifinfomsg netlink attributes
* tests/nlattr_ifinfomsg.c: Include <stddef.h> and <linux/if_link.h>.
(IFLA_LINK_NETNSID): New macro.
(main): Check decoding of IFLA_LINK_NETNSID,
IFLA_STATS, IFLA_MAP and IFLA_STATS64.
JingPiao Chen [Sun, 27 Aug 2017 15:04:15 +0000 (23:04 +0800)]
rtnl_link: decode ifinfomsg netlink attributes
* configure.ac (AC_CHECK_HEADERS): Add linux/if_link.h.
(AC_CHECK_TYPES): Check for struct rtnl_link_stats64
in <linux/if_link.h>.
(AC_CHECK_MEMBERS): Check for rx_nohandler field
in struct rtnl_link_stats/rtnl_link_stats64.
* rtnl_link.c: Include <linux/if_link.h>.
(decode_rtnl_link_stats, decode_rtnl_link_ifmap,
decode_rtnl_link_stats64): New functions.
(ifinfomsg_nla_decoders): New array.
(decode_ifinfomsg): Use it.
Move exiting path out of if (entering(tcp)) { ... return 0; } else,
provide common exit point in v4l2_ioctl handler, use break instead of
return in specific command handlers.
* v4l2.c (print_v4l2_format, print_v4l2_buffer, print_v4l2_standard,
print_v4l2_input, print_v4l2_frmivalenum): Move exiting path out of else
par of the entering(tcp) condition.
(v4l2_ioctl): Add return RVAL_DECODED | 1 at the end of function.
(v4l2_ioctl) <case VIDIOC_S_STD, case VIDIOC_S_INPUT>: Replace return
with break.
v4l2: reorder field printing in order to avoid auxstr usage
Also rework flow a little in order to reduce amount of indentation.
* v4l2.c (print_v4l2_requestbuffers): Print count as the last field on
entering, append it with updated value on exiting.
* tests/ioctl_v4l2.c: Update expected output.
Make userfaultfd ioctl handling more in line with other ioctl decoders.
* userfaultfd.c (uffdio_ioctl): Return RVAL_DECODED | 1, break instead
of returning in specific command handlers, return 0 on entering paths,
move exiting paths out of else branch of entering(tcp) condition.
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.
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.
JingPiao Chen [Tue, 22 Aug 2017 15:24:55 +0000 (23:24 +0800)]
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>
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.
* 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.
Dmitry V. Levin [Tue, 22 Aug 2017 21:23:49 +0000 (21:23 +0000)]
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.
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>
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>
JingPiao Chen [Tue, 22 Aug 2017 06:45:49 +0000 (14:45 +0800)]
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.
JingPiao Chen [Tue, 22 Aug 2017 06:45:48 +0000 (14:45 +0800)]
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.
Dmitry V. Levin [Mon, 21 Aug 2017 11:30:47 +0000 (11:30 +0000)]
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.
Dmitry V. Levin [Fri, 18 Aug 2017 14:30:08 +0000 (14:30 +0000)]
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.
Dmitry V. Levin [Thu, 17 Aug 2017 12:43:18 +0000 (12:43 +0000)]
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.
Dmitry V. Levin [Wed, 16 Aug 2017 17:50:25 +0000 (17:50 +0000)]
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.