Bug 1513337

Summary: lldpad killed by SIGSEGV [rhel-7.9.z]
Product: Red Hat Enterprise Linux 7 Reporter: Denis Silakov <dsilakov>
Component: lldpadAssignee: Aaron Conole <aconole>
Status: CLOSED ERRATA QA Contact: Matt Lucius <malucius>
Severity: high Docs Contact:
Priority: high    
Version: 7.4CC: aconole, gerben, jbainbri, jpeska, jpittman, kpfleming, kzhang, loberman, malucius, mleitner, qe-baseos-daemons, todoleza, vcojot
Target Milestone: rcKeywords: OtherQA, Reopened, Triaged, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-09 11:54:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Possible patch
none
Improved patch
none
LLDPAD with proposed fix none

Description Denis Silakov 2017-11-15 08:51:01 UTC
Description of problem:
lldpad can crash on certain network configurations

Version-Release number of selected component (if applicable):
lldpad-1.0.1-3.git036e314

How reproducible:
On certain network configuration - always

After one of our autotests, abrt reports that lldpad killed by SIGSEGV.

Report contains the following backtrace:

Program terminated with signal 11, Segmentation fault.
#0  0x0000562b97f6dbcc in get_saddr6 (ifname=ifname@entry=0x562b993d97c0 "vethfd5c38f1", saddr=saddr@entry=0x7ffed42e4870) at lldp_util.c:1043
1043                            if ((ifa->ifa_addr->sa_family == AF_INET6) &&
(gdb) bt
#0  0x0000562b97f6dbcc in get_saddr6 (ifname=ifname@entry=0x562b993d97c0 "vethfd5c38f1", saddr=saddr@entry=0x7ffed42e4870) at lldp_util.c:1043
#1  0x0000562b97f6dc71 in get_ipaddr6 (ifname=ifname@entry=0x562b993d97c0 "vethfd5c38f1", in6=in6@entry=0x7ffed42e48e2) at lldp_util.c:1060
#2  0x0000562b97f6e863 in mand_bld_portid_tlv (md=md@entry=0x562b993d97c0, agent=0x562b993d8a60) at lldp_mand.c:382
#3  0x0000562b97f6ec85 in mand_bld_tlv (md=md@entry=0x562b993d97c0, agent=agent@entry=0x562b993d8a60) at lldp_mand.c:475
#4  0x0000562b97f6f17c in mand_ifup (ifname=0x7ffed42e4cf0 "vethfd5c38f1", agent=0x562b993d8a60) at lldp_mand.c:606
#5  0x0000562b97f555a5 in oper_add_device (device_name=device_name@entry=0x7ffed42e4cf0 "vethfd5c38f1") at event_iface.c:218
#6  0x0000562b97f55f0e in event_if_decode_nlmsg (len=<optimized out>, data=0x7ffed42e4d10, route_type=16) at event_iface.c:313
#7  event_if_process_recvmsg (nlmsg=0x7ffed42e4d00) at event_iface.c:334
#8  event_iface_receive (sock=<optimized out>, eloop_ctx=<optimized out>, sock_ctx=<optimized out>) at event_iface.c:412
#9  0x0000562b97f56504 in eloop_sock_table_dispatch (table=table@entry=0x562b981acbf0 <eloop+16>, fds=fds@entry=0x562b993d3140) at eloop.c:209
#10 0x0000562b97f56c73 in eloop_run () at eloop.c:526
#11 0x0000562b97f512ea in main (argc=<optimized out>, argv=<optimized out>) at lldpad.c:459
  

(gdb) p ifa
$1 = (struct ifaddrs *) 0x55a64c323f18
(gdb) p ifa->ifa_addr
$2 = (struct sockaddr *) 0x0


^^^
ifa_addr is zero. And this is legal, getaddrinfo can return NULL for ifa_addr. In our case this happened for interface which had only the following address configured:

  inet6 fe80::1/128 scope link

Comment 2 Denis Silakov 2017-11-15 08:52:43 UTC
Created attachment 1352445 [details]
Possible patch

Comment 3 Denis Silakov 2018-01-12 15:23:15 UTC
Created attachment 1380451 [details]
Improved patch

Improved version of the patch. Should handle all possible failures we met in our tests.

Comment 4 Gerben Meijer 2018-05-04 10:37:50 UTC
Works great on Debian package as well, thanks!

Comment 11 Aaron Conole 2019-09-09 17:48:20 UTC
Created attachment 1613291 [details]
LLDPAD with proposed fix

Comment 21 loberman 2021-12-21 12:31:20 UTC
We have a customer reporting this and I had given them a fix similar to this, but John Pittman then found this bug.

Customer is on 7.7.

Is the latest version of lldpad fixed now meaning this bug can be closed errata

Comment 22 loberman 2021-12-21 12:40:19 UTC
Hello

Customer experienced this in 7.7 and I checked the latest package available and the fix is not in.

I had come up with a similar fix to the BZ here and gave them a test package.


The latest revision of this package is not fixed
lldpad-1.0.1-5.git036e314.el7.src.rpm



{
        struct ecp22_user_data *eud;
        struct ecp22 *ecp;

        LLDPAD_DBG("%s:%s start ecp\n", __func__, ifname);
        eud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_ECP22);
        if (!eud) {
                LLDPAD_DBG("%s:%s no ECP module\n", __func__, ifname);
                return;
        }
        ecp = find_ecpdata(ifname, eud);
        if (!ecp)
                ecp = ecp22_create(ifname, eud);

The fix I gave them is this and its needed because they use docker and interfaces can leave the configuration.


void ecp22_start(char *ifname)
{
        struct ecp22_user_data *eud;
        struct ecp22 *ecp;

        LLDPAD_DBG("%s:%s start ecp\n", __func__, ifname);
        eud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_ECP22);
        if (!eud) {
                LLDPAD_DBG("%s:%s no ECP module\n", __func__, ifname);
                return;
        }
        ecp = find_ecpdata(ifname, eud);
        if (!ecp)
                ecp = ecp22_create(ifname, eud);     /*** This is never checked for NULL ***/
        if (!ecp)                                    /*** If null because interface is gone just return **/

Comment 23 loberman 2021-12-21 13:13:56 UTC
Opening again

Comment 25 John Pittman 2021-12-21 13:17:03 UTC
Hi Aaron, could you please look at this and apply the patch from upstream for the next zstream?  Thanks!

Comment 27 loberman 2022-06-02 16:36:27 UTC
Hello
Given this change is only specific to lldpad and that its not a kernel change so very narrow exposure
we are asking to get this into the latest possible change for 7.9 zstream please.

Comment 37 Matt Lucius 2022-07-11 16:02:11 UTC
No luck so far reproducing using the information provided, including Aaron's suggestion to repeatedly bounce the IPv6 address.

Comment 44 errata-xmlrpc 2022-08-09 11:54:25 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 (lldpad 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/RHBA-2022:5940