Red Hat Bugzilla – Bug 1029299
session libvirtd crashes on nwfilter-define
Last modified: 2014-10-14 00:18:18 EDT
Created attachment 822767 [details]
On latest RHEL6.5, For non-root user, when executing command “virsh nwfilter-define <nwfilterXML>”, libvirtd will crash.
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.
[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.
libvirtd should be worked well, and non-root user should have not permission to define network filter.
Modified the title to:
Memory leaks when executing nwfilter-define under non-root user.
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)
#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")
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:
Author: Ján Tomko <firstname.lastname@example.org>
AuthorDate: 2013-11-12 13:18:54 +0100
Commit: Ján Tomko <email@example.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
Downstream patch posted:
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.
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.