Hide Forgot
Created attachment 822767 [details] /var/log/messages Description On latest RHEL6.5, For non-root user, when executing command “virsh nwfilter-define <nwfilterXML>”, libvirtd will crash. Version: libvirt-0.10.2-29.el6.x86_64 How reproducible: 100% 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'/> </filter> ----------------------------------------------------------------- 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.
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) 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> AuthorDate: 2013-11-12 13:18:54 +0100 Commit: Ján Tomko <jtomko> 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 To: this function is not supported by the connection driver: virNWFilterDefineXML https://bugzilla.redhat.com/show_bug.cgi?id=1029266 git describe: v1.1.4-79-gb7829f9
Downstream patch posted: http://post-office.corp.redhat.com/archives/rhvirt-patches/2014-April/msg00201.html
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. http://rhn.redhat.com/errata/RHBA-2014-1374.html