Bug 1029299 - session libvirtd crashes on nwfilter-define
session libvirtd crashes on nwfilter-define
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
All Linux
high Severity high
: rc
: ---
Assigned To: Ján Tomko
Virtualization Bugs
: Upstream
Depends On:
  Show dependency treegraph
Reported: 2013-11-12 01:11 EST by zhengqin
Modified: 2014-10-14 00:18 EDT (History)
11 users (show)

See Also:
Fixed In Version: libvirt-0.10.2-32.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2014-10-14 00:18:18 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
/var/log/messages (28.23 KB, text/plain)
2013-11-12 01:11 EST, zhengqin
no flags Details

  None (edit)
Description zhengqin 2013-11-12 01:11:14 EST
Created attachment 822767 [details]

On latest RHEL6.5, For non-root user, when executing command “virsh nwfilter-define <nwfilterXML>”, libvirtd will crash.



How reproducible:

Steps to Reproduce:
1. Issue the following command to create a user and set its password:
#useradd non-root ;  passwd non-root

2. Switch to user “non-root” by command “su - non-root”, and prepare a xml file named disallow-arp.xml like below:
<filter name='disallow-arp1' chain='arp'>
  <rule action='drop' direction='inout' priority='500'/>

3. Execute command “nwfilter-define” under “non-root” user.

Actual results:
[non-root@localhost ~]$ virsh nwfilter-define disallow.xml 
error: Failed to define network filter from disallow.xml
error: End of file while reading data: Input/output error
error: One or more references were leaked after disconnect from the hypervisor
error: Reconnected to the hypervisor

libvirtd crashed when executing nwfilter-define under non-root user.

Expected results:
libvirtd should be worked well, and non-root user should have not permission to define network filter.
Comment 7 zhengqin 2013-11-12 04:20:04 EST
Modified the title to: 
Memory leaks when executing nwfilter-define under non-root user.
Comment 10 Ján Tomko 2013-11-13 05:54:06 EST
The crash is caused by a NULL dereference due to the nwfilter driver being only partially initialized if it's not running as root:
#0  __strlen_sse2 () at ../sysdeps/x86_64/strlen.S:32
#1  0x0000003aed681036 in __strdup (s=0x0) at strdup.c:42
---Type <return> to continue, or q <return> to quit---
#2  0x0000003c95e677aa in virFileMakePathWithMode (path=<value optimized out>, mode=511) at util/util.c:1336
#3  0x0000003c95eb9ed9 in virNWFilterObjSaveDef (driver=0x7f42880523e0, nwfilter=0x7f427c0010f0, def=0x7f427c000b30)
    at conf/nwfilter_conf.c:3163
#4  0x00000000004fc3e0 in nwfilterDefine (conn=0x7f4284000bd0, xml=<value optimized out>) at nwfilter/nwfilter_driver.c:574
#5  0x0000003c95ee4ec6 in virNWFilterDefineXML (conn=0x7f4284000bd0, 
    xmlDesc=0x7f427c0009a0 "<filter name='bla' chain='arp'>\n  <rule action='drop' direction='inout' priority='500'/>\n</filter>\n")
    at libvirt.c:16828

On upstream this doesn't crash, it prints an obscure error instead (see bug 1029266). The fix in both cases is to properly disable the nwfilter driver and has been pushed upstream:
commit b7829f959b33c6e32422222a9ed745c0da7dc696
Author:     Ján Tomko <jtomko@redhat.com>
AuthorDate: 2013-11-12 13:18:54 +0100
Commit:     Ján Tomko <jtomko@redhat.com>
CommitDate: 2013-11-13 09:41:57 +0100

    Disable nwfilter driver when running unprivileged
    When opening a new connection to the driver, nwfilterOpen
    only succeeds if the driverState has been allocated.
    Move the privilege check in driver initialization before
    the state allocation to disable the driver.
    This changes the nwfilter-define error from:
    error: cannot create config directory (null): Bad address
    this function is not supported by the connection driver:

git describe: v1.1.4-79-gb7829f9
Comment 14 Ján Tomko 2014-04-09 04:46:42 EDT
Downstream patch posted:
Comment 16 yanbing du 2014-04-14 05:23:41 EDT
Verify bug with libvirt-0.10.2-32.el6.x86_64

# virsh nwfilter-define nw-filter.xml 
error: Failed to define network filter from nw-filter.xml
error: this function is not supported by the connection driver: virNWFilterDefineXML

This is an expect result, so move bug to VERIFIED.
Comment 18 errata-xmlrpc 2014-10-14 00:18:18 EDT
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.


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