RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1182486 - libvirtd crashed when updating a IPv6 <host> and a IPv4 <host> into a IPv4 <ip> element
Summary: libvirtd crashed when updating a IPv6 <host> and a IPv4 <host> into a IPv4 <i...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: x86_64
OS: All
high
high
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-01-15 09:22 UTC by Hu Jianwei
Modified: 2015-03-05 07:49 UTC (History)
5 users (show)

Fixed In Version: libvirt-1.2.8-14.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-05 07:49:12 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
All back trace for the bug (9.21 KB, text/plain)
2015-01-15 09:22 UTC, Hu Jianwei
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 12:10:54 UTC

Description Hu Jianwei 2015-01-15 09:22:00 UTC
Description of problem:
libvirtd crashed when updating a IPv6 <host> and a IPv4 <host> into a IPv4 <ip> element

Version-Release number of selected component (if applicable):
libvirt-1.2.8-12.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
[root@localhost ~]# virsh net-list 
 Name                 State      Autostart     Persistent
----------------------------------------------------------
 default              active     yes           yes

[root@localhost ~]# cat libvirt-test-API/repos/network/xmls/ip-dhcp-host.xml
<host mac="00:16:3e:77:e2:ed" name="foo.example.com" ip="192.168.122.10" />

[root@localhost ~]# cat libvirt-test-API/repos/network/xmls/ipv6-dhcp-host.xml
<host id='00:04:58:fd:e4:15:1b:09:4c:0e:09:af:e4:d3:8c:b8:ca:1e' name="redhatipv6.redhat.com" ip='2001:db8:ca2:2::119'/>

[root@localhost ~]# virsh net-dumpxml default
<network>
  <name>default</name>
  <uuid>ac3350be-5fa1-405c-b19f-cf0ef7c81263</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:15:e9:3a'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>
  </ip>
  <ip family='ipv6' address='2001:db8:ca2:2::1' prefix='64'>
    <dhcp>
      <range start='2001:db8:ca2:2::100' end='2001:db8:ca2:2::1ff'/>
    </dhcp>
  </ip>
</network>

[root@localhost ~]# virsh net-update default add-first ip-dhcp-host libvirt-test-API/repos/network/xmls/ipv6-dhcp-host.xml --parent-index 0
Updated network default live state

[root@localhost ~]# virsh net-update default add-first ip-dhcp-host libvirt-test-API/repos/network/xmls/ip-dhcp-host.xml --parent-index 0
error: Failed to update network default
error: internal error: received hangup / error event on socket
error: Failed to reconnect to the hypervisor

Actual results:
As shown above steps.

Expected results:
Should prevent such behavior.

Additional info:
1. [root@jiahu libvirt-test-API]# virsh net-update default add-first ip-dhcp-host modify-ip-dhcp-host.xml --parent-index 1
error: Failed to update network default
error: XML error: Invalid to specify MAC address '00:16:3e:77:e2:ed' in network 'default' IPv6 static host definition

Comment 1 Hu Jianwei 2015-01-15 09:22:58 UTC
Created attachment 980379 [details]
All back trace for the bug

Comment 5 Michal Privoznik 2015-01-15 14:48:48 UTC
Patch proposed upstream:

https://www.redhat.com/archives/libvir-list/2015-January/msg00546.html

Comment 6 Michal Privoznik 2015-01-16 09:01:42 UTC
I've just pushed the patch upstream:

commit 7d3ae359db604f6052247ad49d7fbce1db7ef99c
Author:     Michal Privoznik <mprivozn>
AuthorDate: Thu Jan 15 15:42:04 2015 +0100
Commit:     Michal Privoznik <mprivozn>
CommitDate: Fri Jan 16 09:57:05 2015 +0100

    virNetworkDefUpdateIPDHCPHost: Don't crash when updating network
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1182486
    
    When updating a network and adding new ip-dhcp-host entry, the deamon
    may crash. The problem is, we iterate over existing <host/> entries
    trying to compare MAC addresses to see if there's already an existing
    rule. However, not all entries are required to have MAC address. For
    instance, the following is perfectly valid entry:
    
    <host id='00:04:58:fd:e4:15:1b:09:4c:0e:09:af:e4:d3:8c:b8:ca:1e'
    name='redhatipv6.redhat.com' ip='2001:db8:ca2:2::119'/>
    
    When the checking loop iterates over this, the entry's MAC address is
    accessed directly. Well, the fix is obvious - check if the address is
    defined before trying to compare it.
    
    Signed-off-by: Michal Privoznik <mprivozn>


v1.2.11-177-g7d3ae35

Comment 7 Michal Privoznik 2015-01-16 09:04:06 UTC
And moving to POST:

http://post-office.corp.redhat.com/archives/rhvirt-patches/2015-January/msg00360.html

Comment 9 Hu Jianwei 2015-01-22 07:43:13 UTC
I can not reproduce it on below version.

[root@ibm-x3850x5-06 ~]# rpm -q libvirt 
libvirt-1.2.8-15.el7.x86_64

[root@ibm-x3850x5-06 ~]# cat ip-dhcp-host.xml 
<host mac='52:54:00:cb:17:00' name='jiahu.example.com' ip='192.168.122.10'/>
[root@ibm-x3850x5-06 ~]# cat ipv6-dhcp-host.xml
<host id='00:04:58:fd:e4:15:1b:09:4c:0e:09:af:e4:d3:8c:b8:ca:1e' name="redhatipv6.redhat.com" ip='2001:db8:ca2:2::119'/>

[root@ibm-x3850x5-06 ~]# cat 123.sh 
service libvirtd status
virsh net-update default add-first ip-dhcp-host ipv6-dhcp-host.xml --parent-index 0
virsh net-update default add-first ip-dhcp-host ip-dhcp-host.xml --parent-index 0
virsh net-dumpxml default
virsh net-update default delete ip-dhcp-host ip-dhcp-host.xml --parent-index 0
virsh net-update default delete ip-dhcp-host ipv6-dhcp-host.xml --parent-index 0
virsh net-dumpxml default
service libvirtd status

[root@ibm-x3850x5-06 ~]# sh 123.sh 
Redirecting to /bin/systemctl status  libvirtd.service
libvirtd.service - Virtualization daemon
   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; disabled)
   Active: active (running) since Thu 2015-01-22 14:29:32 CST; 54min ago
     Docs: man:libvirtd(8)
           http://libvirt.org
 Main PID: 12683 (libvirtd)
   CGroup: /system.slice/libvirtd.service
           ├─12224 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --dhcp-script=/usr/libexec/libvirt_leaseshelper
           ├─12225 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --dhcp-script=/usr/libexec/libvirt_leaseshelper
           ├─12329 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/test1.conf --dhcp-script=/usr/libexec/libvirt_leaseshelper
           ├─12330 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/test1.conf --dhcp-script=/usr/libexec/libvirt_leaseshelper
           └─12683 /usr/sbin/libvirtd

Jan 22 15:22:43 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq-dhcp[12224]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jan 22 15:22:43 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /etc/hosts - 2 addresses
Jan 22 15:22:43 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jan 22 15:22:43 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq-dhcp[12224]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jan 22 15:22:43 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /etc/hosts - 2 addresses
Jan 22 15:22:43 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jan 22 15:22:43 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq-dhcp[12224]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jan 22 15:22:43 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /etc/hosts - 2 addresses
Jan 22 15:22:43 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jan 22 15:22:43 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq-dhcp[12224]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Updated network default live state
Updated network default live state
<network>
  <name>default</name>
  <uuid>6d4f9a7b-d8bc-4150-a891-46019e4c99a5</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:42:e5:99'/>
  <domain name='example.com'/>
  <dns>
    <forwarder addr='8.8.8.8'/>
    <forwarder addr='8.8.4.4'/>
    <txt name='hjw' value='redhat jiahu'/>
  </dns>
  <ip address='192.168.122.1' netmask='255.255.0.0'>
    <dhcp>
      <range start='192.168.1.2' end='192.168.5.254'/>
      <host mac='52:54:00:cb:17:00' name='jiahu.example.com' ip='192.168.122.10'/>
      <host id='00:04:58:fd:e4:15:1b:09:4c:0e:09:af:e4:d3:8c:b8:ca:1e' name='redhatipv6.redhat.com' ip='2001:db8:ca2:2::119'/>
    </dhcp>
  </ip>
  <ip family='ipv6' address='2001:db8:ca2:2::1' prefix='64'>
    <dhcp>
      <range start='2001:db8:ca2:2::100' end='2001:db8:ca2:2::1ff'/>
    </dhcp>
  </ip>
</network>

Updated network default live state
Updated network default live state
<network>
  <name>default</name>
  <uuid>6d4f9a7b-d8bc-4150-a891-46019e4c99a5</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:42:e5:99'/>
  <domain name='example.com'/>
  <dns>
    <forwarder addr='8.8.8.8'/>
    <forwarder addr='8.8.4.4'/>
    <txt name='hjw' value='redhat jiahu'/>
  </dns>
  <ip address='192.168.122.1' netmask='255.255.0.0'>
    <dhcp>
      <range start='192.168.1.2' end='192.168.5.254'/>
    </dhcp>
  </ip>
  <ip family='ipv6' address='2001:db8:ca2:2::1' prefix='64'>
    <dhcp>
      <range start='2001:db8:ca2:2::100' end='2001:db8:ca2:2::1ff'/>
    </dhcp>
  </ip>
</network>

Redirecting to /bin/systemctl status  libvirtd.service
libvirtd.service - Virtualization daemon
   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; disabled)
   Active: active (running) since Thu 2015-01-22 14:29:32 CST; 54min ago
     Docs: man:libvirtd(8)
           http://libvirt.org
 Main PID: 12683 (libvirtd)
   CGroup: /system.slice/libvirtd.service
           ├─12224 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --dhcp-script=/usr/libexec/libvirt_leaseshelper
           ├─12225 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --dhcp-script=/usr/libexec/libvirt_leaseshelper
           ├─12329 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/test1.conf --dhcp-script=/usr/libexec/libvirt_leaseshelper
           ├─12330 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/test1.conf --dhcp-script=/usr/libexec/libvirt_leaseshelper
           └─12683 /usr/sbin/libvirtd

Jan 22 15:24:26 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq-dhcp[12224]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jan 22 15:24:26 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /etc/hosts - 2 addresses
Jan 22 15:24:26 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jan 22 15:24:26 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq-dhcp[12224]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jan 22 15:24:26 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /etc/hosts - 2 addresses
Jan 22 15:24:26 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jan 22 15:24:26 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq-dhcp[12224]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jan 22 15:24:26 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /etc/hosts - 2 addresses
Jan 22 15:24:26 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq[12224]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jan 22 15:24:26 ibm-x3850x5-06.qe.lab.eng.nay.redhat.com dnsmasq-dhcp[12224]: read /var/lib/libvirt/dnsmasq/default.hostsfile
[root@ibm-x3850x5-06 ~]# 

Can not hit the libvirtd crash, regarding the ipv6 <host> in wrong <ip> section, I filed a new bug to track it.
Bug 1184736 - libvirt should verify proper address family of <host> when updating network

Comment 11 errata-xmlrpc 2015-03-05 07:49:12 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, 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://rhn.redhat.com/errata/RHSA-2015-0323.html


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