Bug 2028157 - [RHEL 7 DTS] assertion when using 'xx' arguments to strace
Summary: [RHEL 7 DTS] assertion when using 'xx' arguments to strace
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Developer Toolset
Classification: Red Hat
Component: strace
Version: DTS 11.0 RHEL 7
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: beta1
: 11.1
Assignee: Eugene Syromiatnikov
QA Contact: Lenka Špačková
URL:
Whiteboard:
Depends On:
Blocks: 2048964
TreeView+ depends on / blocked
 
Reported: 2021-12-01 15:48 UTC by Eugene Syromiatnikov
Modified: 2022-06-06 10:13 UTC (History)
7 users (show)

Fixed In Version: devtoolset-11-strace-5.13-3.1.el7
Doc Type: Bug Fix
Doc Text:
.Sufficient buffer sizes used for network interface name printing Previously, `strace` used insufficient buffer sizes for network interface name printing. This led to assertions on attempts of printing interface names that require quoting, for example, names longer than 4 characters in `-xx` mode. This bug has been fixed.
Clone Of: 2028146
: 2048964 (view as bug list)
Environment:
Last Closed: 2022-05-24 16:11:31 UTC
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker DTS-265 0 None None None 2021-12-01 15:52:29 UTC
Red Hat Product Errata RHEA-2022:4635 0 None None None 2022-05-24 16:11:42 UTC

Description Eugene Syromiatnikov 2021-12-01 15:48:29 UTC
+++ This bug was initially created as a clone of Bug #2028146 +++

Backtrace:

...
(gdb) bt
#0  die () at strace.c:313
#1  0x000000000040d883 in error_msg_and_die (fmt=fmt@entry=0x4640e8 "%s: got unexpected return value %d for snprintf(buf, %zu, %s)") at error_prints.c:74
#2  0x000000000042152a in xsnprintf_ (str=0x6f9a20 <res.6552> "if_nametoindex(\"\\x62\\x6c\\x69\\x6e\\x6", size=36, func=0x484ede <__func__.6555> "get_ifname", argstr=0x484eb0 "(\"if_nametoindex(\" \"%s\" \")\"), name_quoted_buf", 
    format=0x484e9b "if_nametoindex(%s)", format=0x484e9b "if_nametoindex(%s)", argstr=0x484eb0 "(\"if_nametoindex(\" \"%s\" \")\"), name_quoted_buf", func=0x484ede <__func__.6555> "get_ifname", size=36, 
    str=0x6f9a20 <res.6552> "if_nametoindex(\"\\x62\\x6c\\x69\\x6e\\x6") at xstring.h:36
#3  0x0000000000421596 in get_ifname (ifindex=6) at print_ifindex.c:31
#4  print_ifindex (ifindex=6) at print_ifindex.c:44
#5  0x0000000000427a7d in decode_ndmsg (tcp=0x712370, nlmsghdr=<optimized out>, family=<optimized out>, addr=140215372832688, len=60) at rtnl_neigh.c:86
#6  0x000000000041c5c8 in decode_netlink_route (tcp=tcp@entry=0x712370, nlmsghdr=nlmsghdr@entry=0x7fffffffe0b0, addr=addr@entry=140215372832688, len=len@entry=60) at netlink_route.c:120
...

  The problem in frame #3:

(gdb) f 3
#3  0x0000000000421596 in get_ifname (ifindex=6) at print_ifindex.c:31
31			xsprintf(res, INI_PFX "%s" INI_SFX, name_quoted_buf);
(gdb) info local
name_buf = "blink1\000\000\000\000\000\000\000\000\000"
name_quoted_buf = "\"\\x62\\x6c\\x69\\x6e\\x"
res = "if_nametoindex(\"\\x62\\x6c\\x69\\x6e\\x6"
res = "if_nametoindex(\"\\x62\\x6c\\x69\\x6e\\x6"
__func__ = "get_ifname"

  The fix could be to check the 'xflag' global variable and not print in hex
the name, but since all strings are printed in hex, the most likely fix should
be to rework the code in print_ifindex.c. This appears to be buggy:

# define IFNAME_QUOTED_SZ (sizeof(IFNAMSIZ) * 4 + 3)

as it most likely should mean:

# define IFNAME_QUOTED_SZ (IFNAMSIZ * 4 + 3)

because, otherwise it should result in:

sizeof(IFNAMSIZ) that is the same as sizeof(16) and return 4 (as literal
16 should default to type int). So, the code likely did already prepare for
printing in hex, but due to a mistake, used sizeof.

Comment 1 Eugene Syromiatnikov 2021-12-02 21:49:30 UTC
Fixed upstream in strace commit v5.15~1[1].

[1] https://gitlab.com/strace/strace/-/commit/e27b0677

Comment 9 errata-xmlrpc 2022-05-24 16:11:31 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (devtoolset-11-strace bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2022:4635


Note You need to log in before you can comment on or make changes to this bug.