1. 03 9月, 2015 1 次提交
    • M
      remoteClientCloseFunc: Don't mangle connection object refcount · 211566f7
      Michal Privoznik 提交于
      Well, in 8ad126e6 we tried to fix a memory corruption problem.
      However, the fix was not as good as it could be. I mean, the
      commit has one line more than it should. I've noticed this output
      just recently:
      
        # ./run valgrind --leak-check=full --show-reachable=yes ./tools/virsh domblklist gentoo
        ==17019== Memcheck, a memory error detector
        ==17019== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
        ==17019== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
        ==17019== Command: /home/zippy/work/libvirt/libvirt.git/tools/.libs/virsh domblklist gentoo
        ==17019==
        Target     Source
        ------------------------------------------------
        fda        /var/lib/libvirt/images/fd.img
        vda        /var/lib/libvirt/images/gentoo.qcow2
        hdc        /home/zippy/tmp/install-amd64-minimal-20150402.iso
      
        ==17019== Thread 2:
        ==17019== Invalid read of size 4
        ==17019==    at 0x4EFF5B4: virObjectUnref (virobject.c:258)
        ==17019==    by 0x5038CFF: remoteClientCloseFunc (remote_driver.c:552)
        ==17019==    by 0x5069D57: virNetClientCloseLocked (virnetclient.c:685)
        ==17019==    by 0x506C848: virNetClientIncomingEvent (virnetclient.c:1852)
        ==17019==    by 0x5082136: virNetSocketEventHandle (virnetsocket.c:1913)
        ==17019==    by 0x4ECD64E: virEventPollDispatchHandles (vireventpoll.c:509)
        ==17019==    by 0x4ECDE02: virEventPollRunOnce (vireventpoll.c:658)
        ==17019==    by 0x4ECBF00: virEventRunDefaultImpl (virevent.c:308)
        ==17019==    by 0x130386: vshEventLoop (vsh.c:1864)
        ==17019==    by 0x4F1EB07: virThreadHelper (virthread.c:206)
        ==17019==    by 0xA8462D3: start_thread (in /lib64/libpthread-2.20.so)
        ==17019==    by 0xAB441FC: clone (in /lib64/libc-2.20.so)
        ==17019==  Address 0x139023f4 is 4 bytes inside a block of size 240 free'd
        ==17019==    at 0x4C2B1F0: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
        ==17019==    by 0x4EA8949: virFree (viralloc.c:582)
        ==17019==    by 0x4EFF6D0: virObjectUnref (virobject.c:273)
        ==17019==    by 0x4FE74D6: virConnectClose (libvirt.c:1390)
        ==17019==    by 0x13342A: virshDeinit (virsh.c:406)
        ==17019==    by 0x134A37: main (virsh.c:950)
      
      The problem is, when registering remoteClientCloseFunc(), it's
      conn->closeCallback which is ref'd. But in the function itself
      it's conn->closeCallback->conn what is unref'd. This is causing
      imbalance in reference counting. Moreover, there's no need for
      the remote driver to increase/decrease conn refcount since it's
      not used anywhere. It's just merely passed to client registered
      callback. And for that purpose it's correctly ref'd in
      virConnectRegisterCloseCallback() and then unref'd in
      virConnectUnregisterCloseCallback().
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      (cherry picked from commit e6893007)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      211566f7
  2. 30 1月, 2015 1 次提交
    • M
      xend: Don't crash in virDomainXMLDevID · 2c7639f1
      Michal Privoznik 提交于
      The function is called from all {Attach,Update,Detach}Device APIs to
      create config strings that are later passed to the xend to perform the
      desired action. The function is intended to handle all supported
      devices. However, as of 5b05358a we
      are trying to get disk driver of the device without checking if the
      device really is a disk. This leads to an segmentation fault:
      
        #0 0x00007ffff7571815 in virDomainDiskGetDriver () from /usr/lib/libvirt.so.0
        #1 0x00007fffeb9ad471 in ?? () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
        #2 0x00007fffeb9b1062 in xenDaemonAttachDeviceFlags () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
        #3 0x00007fffeb9a8a86 in ?? () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
        #4 0x00007ffff7609266 in virDomainAttachDevice () from /usr/lib/libvirt.so.0
        #5 0x0000555555593c9d in ?? ()
        #6 0x00007ffff76743c9 in virNetServerProgramDispatch () from /usr/lib/libvirt.so.0
        #7 0x00005555555a678d in ?? ()
        #8 0x00007ffff755460e in ?? () from /usr/lib/libvirt.so.0
        #9 0x00007ffff7553b06 in ?? () from /usr/lib/libvirt.so.0
        #10 0x00007ffff4998b50 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
        #11 0x00007ffff46e30ed in clone () from /lib/x86_64-linux-gnu/libc.so.6
        #12 0x0000000000000000 in ?? ()
      Reported-by: NXiaolin Su <linxxnil@126.com>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      (cherry picked from commit cd7702d4)
      2c7639f1
  3. 23 1月, 2015 2 次提交
  4. 23 12月, 2014 6 次提交
  5. 13 11月, 2014 1 次提交
    • L
      util: eliminate "use after free" in callers of virNetDevLinkDump · 38dce339
      Laine Stump 提交于
      virNetDevLinkDump() gets a message from netlink into "resp", then
      calls nlmsg_parse() to fill the table "tb" with pointers into resp. It
      then returns tb to its caller, but not before freeing the buffer at
      resp. That means that all the callers of virNetDevLinkDump() are
      examining memory that has already been freed. This can be verified by
      filling the buffer at resp with garbage prior to freeing it (or, I
      suppose, just running libvirtd under valgrind) then performing some
      operation that calls virNetDevLinkDump().
      
      The upstream commit log incorrectly states that the code has been like
      this ever since virNetDevLinkDump() was written. In reality, the
      problem was introduced with commit e95de74d, first in libvirt-1.0.5,
      which was attempting to eliminate a typecast that caused compiler
      warnings. It has only been pure luck (or maybe a lack of heavy load,
      and/or maybe an allocation algorithm in malloc() that delays re-use of
      just-freed memory) that has kept this from causing errors, for example
      when configuring a PCI passthrough or macvtap passthrough network
      interface.
      
      The solution taken in this patch is the simplest - just return resp to
      the caller along with tb, then have the caller free it after they are
      finished using the data (pointers) in tb. I alternately could have
      made a cleaner interface by creating a new struct that put tb and resp
      together along with a vir*Free() function for it, but this function is
      only used in a couple places, and I'm not sure there will be
      additional new uses of virNetDevLinkDump(), so the value of adding a
      new type, extra APIs, etc. is dubious.
      
      (cherry picked from commit f9f9699f)
      38dce339
  6. 07 11月, 2014 1 次提交
    • E
      CVE-2014-7823: dumpxml: security hole with migratable flag · 2a924d87
      Eric Blake 提交于
      Commit 28f8dfdc (v1.0.0) introduced a security hole: in at least
      the qemu implementation of virDomainGetXMLDesc, the use of the
      flag VIR_DOMAIN_XML_MIGRATABLE (which is usable from a read-only
      connection) triggers the implicit use of VIR_DOMAIN_XML_SECURE
      prior to calling qemuDomainFormatXML.  However, the use of
      VIR_DOMAIN_XML_SECURE is supposed to be restricted to read-write
      clients only.  This patch treats the migratable flag as requiring
      the same permissions, rather than analyzing what might break if
      migratable xml no longer includes secret information.
      
      Fortunately, the information leak is low-risk: all that is gated
      by the VIR_DOMAIN_XML_SECURE flag is the VNC connection password;
      but VNC passwords are already weak (FIPS forbids their use, and
      on a non-FIPS machine, anyone stupid enough to trust a max-8-byte
      password sent in plaintext over the network deserves what they
      get).  SPICE offers better security than VNC, and all other
      secrets are properly protected by use of virSecret associations
      rather than direct output in domain XML.
      
      * src/remote/remote_protocol.x (REMOTE_PROC_DOMAIN_GET_XML_DESC):
      Tighten rules on use of migratable flag.
      * src/libvirt-domain.c (virDomainGetXMLDesc): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit b1674ad5)
      
      Conflicts:
      	src/libvirt-domain.c - file split from older src/libvirt.c
      Signed-off-by: NEric Blake <eblake@redhat.com>
      2a924d87
  7. 02 10月, 2014 1 次提交
  8. 18 9月, 2014 1 次提交
  9. 02 7月, 2014 1 次提交
    • P
      qemu: copy: Accept 'format' parameter when copying to a non-existing img · b850e1a9
      Peter Krempa 提交于
      We have the following matrix of possible arguments handled by the logic
      statement touched by this patch:
             | flags & _REUSE_EXT | !(flags & _REUSE_EXT)
      -------+--------------------+----------------------
       format| (1)                | (2)
      -------+--------------------+----------------------
      !format| (3)                | (4)
      -------+--------------------+----------------------
      
      In cases 1 and 2 the user provided a format, in cases 3 and 4 not. The
      user requests to use a pre-existing image in 1 and 3 and libvirt will
      create a new image in 2 and 4.
      
      The difference between cases 3 and 4 is that for 3 the format is probed
      from the user-provided image, whereas in 4 we just use the existing disk
      format.
      
      The current code would treat cases 1,3 and 4 correctly but in case 2 the
      format provided by the user would be ignored.
      
      The particular piece of code was broken in commit 35c7701c
      but since it was introduced a few commits before that it was never
      released as working.
      
      (cherry picked from commit 42619ed0)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      
      Conflicts:
      	src/qemu/qemu_driver.c - no refactoring of commit 7b7bf001
      b850e1a9
  10. 27 6月, 2014 2 次提交
    • E
      docs: publish correct enum values · 99497739
      Eric Blake 提交于
      We publish libvirt-api.xml for others to use, and in fact, the
      libvirt-python bindings use it to generate python constants that
      correspond to our enum values.  However, we had an off-by-one bug
      that any enum that relied on C's rules for implicit initialization
      of the first enum member to 0 got listed in the xml as having a
      value of 1 (and all later members of the enum were equally
      botched).
      
      The fix is simple - since we add one to the previous value when
      encountering an enum without an initializer, the previous value
      must start at -1 so that the first enum member is assigned 0.
      
      The python generator code has had the off-by-one ever since DV
      first wrote it years ago, but most of our public enums were immune
      because they had an explicit = 0 initializer.  The only affected
      enums are:
      - virDomainEventGraphicsAddressType (such as
      VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4), since commit 987e31ed
      (libvirt v0.8.0)
      - virDomainCoreDumpFormat (such as VIR_DOMAIN_CORE_DUMP_FORMAT_RAW),
      since commit 9fbaff00 (libvirt v1.2.3)
      - virIPAddrType (such as VIR_IP_ADDR_TYPE_IPV4), since commit
      03e0e79e (not yet released)
      
      Thanks to Nehal J Wani for reporting the problem on IRC, and
      for helping me zero in on the culprit function.
      
      * docs/apibuild.py (CParser.parseEnumBlock): Fix implicit enum
      values.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 9b291bbe)
      99497739
    • P
      qemu: blockcopy: Don't remove existing disk mirror info · 2f7ea630
      Peter Krempa 提交于
      When creating a new disk mirror the new struct is stored in a separate
      variable until everything went well. The removed hunk would actually
      remove existing mirror information for example when the api would be run
      if a mirror still exists.
      
      (cherry picked from commit 02b364e1)
      
      This fixes a regression introduced in commit ff5f30b6.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      
      Conflicts:
      	src/qemu/qemu_driver.c - no refactoring of commit 7b7bf001
      2f7ea630
  11. 06 5月, 2014 1 次提交
  12. 01 5月, 2014 1 次提交
  13. 10 4月, 2014 3 次提交
  14. 08 4月, 2014 1 次提交
  15. 01 4月, 2014 7 次提交
    • D
      Release of libvirt-1.2.3 · c53663cc
      Daniel Veillard 提交于
      * docs/news.html.in libvirt.spec.in: update for the release
      * po/*.po*: pull updated translations and regenerate
      c53663cc
    • M
      79752160
    • P
      gluster: Fix "key" attribute for gluster volumes · 0f6c50b9
      Peter Krempa 提交于
      According to our documentation the "key" value has the following
      meaning: "Providing an identifier for the volume which identifies a
      single volume." The currently used keys for gluster volumes consist of
      the gluster volume name and file path. This can't be considered unique
      as a different storage server can serve a volume with the same name.
      
      Unfortunately I wasn't able to figure out a way to retrieve the gluster
      volume UUID which would avoid the possibility of having two distinct
      keys identifying a single volume.
      
      Use the full URI as the key for the volume to avoid the more critical
      ambiguity problem and document the possible change to UUID.
      0f6c50b9
    • C
      storage: Rename VolOpenCheckMode to VolOpen · fa5b5549
      Cole Robinson 提交于
      Remove the original VolOpen implementation, which is now only used in
      one spot.
      fa5b5549
    • C
      847a9eb1
    • C
      storage: Rename UpdateVolInfoFlags to UpdateVolInfo · 16d75d19
      Cole Robinson 提交于
      And drop the original UpdateVolInfo. Makes it a bit easier to follow
      the function usage.
      
      And change the int parameter to an explicit bool.
      16d75d19
    • N
      Fix Memory Leak in testMessageArrayRef() · 968aae48
      Nehal J Wani 提交于
      While running virdbustest, it was found that valgrind pointed out
      the following memory leaks:
      
      ==9996== 17 (8 direct, 9 indirect) bytes in 1 blocks are definitely lost in loss record 9 of 36
      ==9996==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
      ==9996==    by 0x4A06B62: realloc (vg_replace_malloc.c:662)
      ==9996==    by 0x4C6B587: virReallocN (viralloc.c:245)
      ==9996==    by 0x4C6B6AE: virExpandN (viralloc.c:294)
      ==9996==    by 0x4C82B54: virDBusMessageDecodeArgs (virdbus.c:907)
      ==9996==    by 0x4C83463: virDBusMessageDecode (virdbus.c:1141)
      ==9996==    by 0x402C45: testMessageArrayRef (virdbustest.c:273)
      ==9996==    by 0x404E71: virtTestRun (testutils.c:201)
      ==9996==    by 0x401C2D: mymain (virdbustest.c:479)
      ==9996==    by 0x4055ED: virtTestMain (testutils.c:789)
      ==9996==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
      ==9996==
      ==9996== 28 (16 direct, 12 indirect) bytes in 1 blocks are definitely lost in loss record 12 of 36
      ==9996==    at 0x4A06BE0: realloc (vg_replace_malloc.c:662)
      ==9996==    by 0x4C6B587: virReallocN (viralloc.c:245)
      ==9996==    by 0x4C6B6AE: virExpandN (viralloc.c:294)
      ==9996==    by 0x4C82B54: virDBusMessageDecodeArgs (virdbus.c:907)
      ==9996==    by 0x4C83463: virDBusMessageDecode (virdbus.c:1141)
      ==9996==    by 0x402C45: testMessageArrayRef (virdbustest.c:273)
      ==9996==    by 0x404E71: virtTestRun (testutils.c:201)
      ==9996==    by 0x401C2D: mymain (virdbustest.c:479)
      ==9996==    by 0x4055ED: virtTestMain (testutils.c:789)
      ==9996==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
      ==9996==
      Signed-off-by: NEric Blake <eblake@redhat.com>
      968aae48
  16. 31 3月, 2014 7 次提交
  17. 30 3月, 2014 3 次提交
    • D
      ESX: Add support for virtualHW version 10 · 5cc3cce5
      Dawid Zamirski 提交于
      This follows the same pattern when v8 and v9 were added. I've tested
      this with my ESX 5.5 and seems to work fine.
      5cc3cce5
    • M
      Prohibit Windows special chars in filenames · 8f21ae70
      Matthias Bolte 提交于
      Using any of these chars [:*?"<>|] in a filename is forbidden on
      Windows and breaks git operations on Windows as git is not able
      to create those files/directories on clone or pull.
      
      Because some of them can be used in UNIX filenames they tend to
      creep into filenames; especially : in PCI/SCSI device names that
      are used as filenames in test cases.
      8f21ae70
    • M
      tests: Fix SCSI test data filenames for Windows · d20539a4
      Matthias Bolte 提交于
      Windows doesn't allow : in filenames.
      
      Commit 6fdece9a added files with a : in
      their names. This broke git operations on Windows as git is not able to
      create those files on clone or pull.
      
      Replace : with - in the offending filenames and adapt the test case.
      As the tested Linux specific code expects the files to exist with : in
      their path use symlinks to provide the name that way.
      d20539a4