1. 30 6月, 2016 1 次提交
  2. 16 12月, 2015 1 次提交
    • E
      CVE-2015-5313: storage: don't allow '/' in filesystem volume names · b0f88836
      Eric Blake 提交于
      The libvirt file system storage driver determines what file to
      act on by concatenating the pool location with the volume name.
      If a user is able to pick names like "../../../etc/passwd", then
      they can escape the bounds of the pool.  For that matter,
      virStoragePoolListVolumes() doesn't descend into subdirectories,
      so a user really shouldn't use a name with a slash.
      
      Normally, only privileged users can coerce libvirt into creating
      or opening existing files using the virStorageVol APIs; and such
      users already have full privilege to create any domain XML (so it
      is not an escalation of privilege).  But in the case of
      fine-grained ACLs, it is feasible that a user can be granted
      storage_vol:create but not domain:write, and it violates
      assumptions if such a user can abuse libvirt to access files
      outside of the storage pool.
      
      Therefore, prevent all use of volume names that contain "/",
      whether or not such a name is actually attempting to escape the
      pool.
      
      This changes things from:
      
      $ virsh vol-create-as default ../../../../../../etc/haha --capacity 128
      Vol ../../../../../../etc/haha created
      $ rm /etc/haha
      
      to:
      
      $ virsh vol-create-as default ../../../../../../etc/haha --capacity 128
      error: Failed to create vol ../../../../../../etc/haha
      error: Requested operation is not valid: volume name '../../../../../../etc/haha' cannot contain '/'
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 034e47c3)
      b0f88836
  3. 03 9月, 2015 1 次提交
    • M
      remoteClientCloseFunc: Don't mangle connection object refcount · 3b7eeec1
      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>
      3b7eeec1
  4. 29 8月, 2015 1 次提交
  5. 19 6月, 2015 1 次提交
  6. 17 6月, 2015 1 次提交
    • E
      lxc: set nosuid+nodev+noexec flags on /proc/sys mount · bda5f2bd
      Eric W. Biederman 提交于
      Future kernels will mandate the use of nosuid+nodev+noexec
      flags when mounting the /proc/sys filesystem. Unconditionally
      add them now since they don't harm things regardless and could
      mitigate future security attacks.
      
      (cherry picked from commit 24710414)
      
      Conflicts:
          src/lxc/lxc_container.c
      bda5f2bd
  7. 22 5月, 2015 1 次提交
    • T
      conf: fix issue on virCPUDefCopy · 62d46ead
      Thibaut Collet 提交于
      The cpu xml copy is incorrect: the memAccess field is not copied.
      The lack of copy of this memAccess field can cause unexpected behaviour for live
      migration when vhost user is used.
      
      For example if guest has the following configuration:
      ....
      <cpu>
      <model>Westmere</model>
      <topology sockets="1" cores="4" threads="1"/>
      <numa>
      <cell id='0' cpus='0-3' memory='2097152' memAccess='shared'/>
      </numa>
      </cpu>
      ....
      
      The used configuration on the remote host in case of live migration is:
      ....
        <cpu mode='custom' match='exact'>
          <model fallback='allow'>Westmere</model>
          <topology sockets='1' cores='4' threads='1'/>
          <numa>
            <cell id='0' cpus='0-3' memory='2097152' unit='KiB'/>
          </numa>
        </cpu>
      ....
      
      On the remote host the lack of memAccess info can cause unexpected error on the
      qemu backend vhost user driver.
      
      Fixes: def6b359 ("docs, conf, schema: add support for shared memory mapping")
      
      This issue is present only for libvirt1.2.9 to libvirt1.2.12
      With patch 181742d4 ("conf: Move all NUMA configuration to virDomainNuma")
      present since libvirt1.2.13 the problem does not exist anymore as NUMA
      information are no more in the CPU configuration.
      Signed-off-by: NThibaut Collet <thibaut.collet@6wind.com>
      62d46ead
  8. 28 4月, 2015 18 次提交
    • C
      Prep for release 1.2.9.3 · 09661a8e
      Cole Robinson 提交于
      09661a8e
    • C
      storage: fs: Ignore volumes that fail to open with EACCESS/EPERM · 96b8510f
      Cole Robinson 提交于
      Trying to use qemu:///session to create a storage pool pointing at
      /tmp will usually fail with something like:
      
      $ virsh pool-start tmp
      error: Failed to start pool tmp
      error: cannot open volume '/tmp/systemd-private-c38cf0418d7a4734a66a8175996c384f-colord.service-kEyiTA': Permission denied
      
      If any volume in an FS pool can't be opened by the daemon, the refresh
      fails, and the pool can't be used.
      
      This causes pain for virt-install/virt-manager though. Imaging a user
      downloads a disk image to /tmp. virt-manager wants to import /tmp as
      a storage pool, so we can detect what disk format it is, and set the
      XML correctly. However this case will likely fail as explained above.
      
      Change the logic here to skip volumes that fail to open. This could
      conceivably cause user complaints along the lines of 'why doesn't
      libvirt show $ROOT-OWNED-VOLUME-FOO', but figuring that currently
      the pool won't even startup, I don't think there are any current
      users that care about that case.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1103308
      (cherry picked from commit 56476f6a)
      96b8510f
    • C
      domain: conf: Don't validate VM ostype/arch at daemon startup · 55540339
      Cole Robinson 提交于
      When parsing XML, we validate the passed ostype + arch combo against
      the detected hypervisor capabilities. This has led to the following
      problem:
      
      - Define x86 qemu guest
      - qemu is inadvertently removed from the host
      - libvirtd is restarted. fails to parse VM config since arch is removed
      - 'virsh list --all' is now empty, user is wondering where their VMs went
      
      Add a new internal flag VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS. Use
      it when loading VM and snapshot configs from disk.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1043572
      (cherry picked from commit f1a89a8b)
      55540339
    • C
      domain: conf: Better errors on bad os <type> values · 7d9739f2
      Cole Robinson 提交于
      If no <os><type> was specified:
        before: unknown OS type no OS type
        after : xml error: an os <type> must be specified
      
      If an <os><type> is specified that's not in our capabiliities data:
        before: unknown OS type: $type
        after : unsupported configuration: no support found for os <type> '$type'
      
      VIR_ERR_OS_TYPE is now unused (as it should be frankly) so drop its strings
      as well to save our translators some effort.
      
      (cherry picked from commit 3700c065)
      7d9739f2
    • D
      Report original error when QMP probing fails with new QEMU · a514d325
      Daniel P. Berrange 提交于
      If probing capabilities via QMP fails, we now have a check
      that prevents us falling back to -help parsing. Unfortunately
      the error message
      
        "Failed to probe capabilities for /usr/bin/qemu-kvm:
         unsupported configuration: QEMU 2.1.2 is too new for help parsing"
      
      is proving rather unhelpful to the user. We need to be telling
      them why QMP failed (the root cause), rather than they can't
      use -help (the side effect).
      
      To do this we should capture stderr during QMP probing, and
      if -help parsing then sees a new QEMU version, we know that
      QMP should have worked, and so we can show the messages from
      stderr. The message thus becomes
      
        "Failed to probe capabilities for /usr/bin/qemu-kvm:
         internal error: QEMU / QMP failed: Could not access
         KVM kernel module: No such file or directory
         failed to initialize KVM: No such file or directory"
      
      (cherry picked from commit 25bf888a)
      a514d325
    • J
      cpu: Add {Haswell,Broadwell}-noTSX CPU models · b2436daf
      Jiri Denemark 提交于
      QEMU 2.3 adds these new models to cover Haswell and Broadwell CPUs with
      updated microcode. Luckily, they also reverted former the machine type
      specific changes to existing models. And since these changes were never
      released, we don't need to hack around them in libvirt.
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      (cherry picked from commit c563b506)
      b2436daf
    • P
      storage: qemu: Fix security labelling of new image chain elements · 5d6cf6d4
      Peter Krempa 提交于
      When creating a disk image snapshot the libvirt code would blindly copy
      the parents label to the newly created image. This runs into problems
      when you start a VM from an image hosted on NFS (or other storage system
      that doesn't support selinux labels) and the snapshot destination is on
      a storage system that does support selinux labels. Libvirt's code in
      that case generates a different security label for the image hosted on
      NFS. This label is valid only for NFS images and doesn't allow access in
      case of a locally stored image.
      
      To fix this issue libvirt needs to refrain from copying security
      information in cases where the default domain seclabel is a better
      choice.
      
      This patch repurposes the now unused @force argument of
      virStorageSourceInitChainElement to denote whether a copy of the
      security labelling stuff should be attempted or not. This allows to
      fine-control the copy operation for cases where we need to keep the
      label of the old disk vs. the cases where we need to keep the label
      unset to use the default domain imagelabel.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1151718
      (cherry picked from commit 7e130e8b)
      5d6cf6d4
    • J
      Ignore CPU features without a model for host-passthrough · 66a7f51a
      Ján Tomko 提交于
      This fixes reverting to snapshots created by older libvirt
      and allows libvirt not to lose track of a domain that
      has this in its live status XML (such as a domain
      restored from managedsave)
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1030793
      https://bugzilla.redhat.com/show_bug.cgi?id=1151885
      (cherry picked from commit 15abebde)
      66a7f51a
    • J
      Do not format CPU features without a model · c9da7af6
      Ján Tomko 提交于
      For host-passthrough CPU we don't honor the CPU
      features specified in the XML, but we allow
      outputting them via the UPDATE_CPU flag for dumpxml,
      this gives user a rough idea of what features the CPU
      might have.
      
      After restoring a managedsave'd domain, the features
      might end up in the live status XML (in /var/run) without
      the model. This XML cannot be parsed by the daemon after
      restart and the domain might disappear.
      
      This fix skips formatting the features for HOST_PASSTHROUGH
      when UPDATE_CPU is not specified, so the newly restored domains
      and newly created snapshots won't be affected.
      
      Note: this doesn't fix existing snapshots or already restored
      running domains.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1030793
      https://bugzilla.redhat.com/show_bug.cgi?id=1151885
      (cherry picked from commit dd324bb2)
      c9da7af6
    • M
      domcaps: Check for architecture more wisely · 8feb6bad
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1209948
      
      So we have this bug. The virConnectGetDomainCapabilities() API
      performs a couple of checks before it produces any result. One of
      the checks is if the architecture requested by user can be run by
      the binary (again user provided). However, the check is pretty
      dumb. It merely compares if the default binary architecture
      matches the one provided by user. However, a qemu binary can run
      multiple architectures. For instance: qemu-system-ppc64 can run:
      ppc, ppcle, ppc64, ppc64le and ppcemb. The default is ppc64, so
      if user requested something else, like ppc64le, the check would
      have failed without obvious reason.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      (cherry picked from commit 0af9325e)
      8feb6bad
    • P
      daemon: Clear fake domain def object that is used to check ACL prior to use · 4650e48a
      Peter Krempa 提交于
      The fake object is used to pass the domain name and UUID to the ACL code
      for events where we don't have the full domain def when dispatching
      events. The rest of the entries would be left uninitialized. While this
      is not a problem code-wise as the used fields are initialized it looks
      ugly in the debugger.
      
      (cherry picked from commit 6ca857c7)
      4650e48a
    • P
      util: identity: Harden virIdentitySetCurrent() · 363bc010
      Peter Krempa 提交于
      Don't unref the old identity unless we set the new one correctly and
      unref the new one on failure to set it so that we don't leak any
      references or use invalid pointers.
      
      (cherry picked from commit ad886fa6)
      363bc010
    • C
      qemu: Build nvram directory at driver startup · b843bea3
      Cole Robinson 提交于
      Similar to what was done for the channel socket in the previous commit.
      
      (cherry picked from commit 19425d11)
      b843bea3
    • C
      qemu: Build channel autosocket directory at driver startup · a86252af
      Cole Robinson 提交于
      Rather than depend on the RPM to put it in place, since this doesn't
      cover the qemu:///session case. Currently auto allocated socket path is
      completely busted with qemu:///session
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1105274
      
      And because we chown the directory at driver startup now, this also fixes
      autosocket startup failures when using user/group=root
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1044561
      https://bugzilla.redhat.com/show_bug.cgi?id=1146886
      (cherry picked from commit e31ab02f)
      a86252af
    • C
      qemu: chown autoDumpPath on driver startup · 116742ee
      Cole Robinson 提交于
      Not sure if this is required, but it makes things consistent with the
      rest of the directories.
      
      (cherry picked from commit db3ccd58)
      116742ee
    • C
      qemu: conf: Clarify paths that are relative to libDir · 808a6382
      Cole Robinson 提交于
      Rather than duplicate libDir for each new path
      
      (cherry picked from commit c19f43ae)
      808a6382
    • D
      avoid using deprecated udev logging functions · 96789b1e
      Daniel P. Berrange 提交于
      In systemd >= 218, the udev_set_log_fn method has been marked
      deprecated and turned into a no-op. Nothing in the udev client
      library will print to stderr by default anymore, so we can
      just stop installing a logging hook for new enough udev.
      
      (cherry picked from commit a93a3b97)
      96789b1e
    • C
      qemu: Always refresh capabilities if no <guests> found · 9ebc1631
      Cole Robinson 提交于
      - Remove all qemu emulators
      - Restart libvirtd
      - Install qemu emulators
      - Call 'virsh version' -> errors
      
      The only thing that will force the qemu driver to refresh it's cached
      capablities info is an explict API call to GetCapabilities.
      
      However in the case when the initial caps lookup at driver connect didn't
      find a single qemu emulator to poll, the driver is effectively useless
      and really can't do anything until it's populated some qemu capabilities
      info.
      
      With the above steps, the user would have to either know about the
      magic refresh capabilities call, or restart libvirtd to pick up the
      changes.
      
      Instead, this patch changes things so that every time a part of th
      driver requests access to capabilities info, check to see if
      we've previously seen any emulators. If not, force a refresh.
      
      In the case of 'still no emulators found', this is still very quick, so
      I can't think of a downside.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1000116
      (cherry picked from commit 95546c43)
      9ebc1631
  9. 23 4月, 2015 1 次提交
    • Z
      qemu: move setting emulatorpin ahead of monitor showing up · 91ced385
      Zhou yimin 提交于
      If VM is configured with many devices(including passthrough devices)
      and large memory, libvirtd will take seconds(in the worst case) to
      wait for monitor. In this period the qemu process may run on any
      PCPU though I intend to pin emulator to the specified PCPU in xml
      configuration.
      
      Actually qemu process takes high cpu usage during vm startup.
      So this is not the strict CPU isolation in this case.
      Signed-off-by: NZhou yimin <zhouyimin@huawei.com>
      (cherry picked from commit 411cea63)
      91ced385
  10. 16 4月, 2015 9 次提交
  11. 10 4月, 2015 1 次提交
    • M
      virNetworkDefUpdateIPDHCPHost: Don't crash when updating network · cf2289f2
      Michal Privoznik 提交于
      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: NMichal Privoznik <mprivozn@redhat.com>
      (cherry picked from commit 7d3ae359)
      cf2289f2
  12. 17 3月, 2015 1 次提交
    • E
      daemon: avoid memleak when ListAll returns nothing · b9dacdd4
      Eric Blake 提交于
      Commit 4f25146b (v1.2.8) managed to silence Coverity, but at the
      cost of a memory leak detected by valgrind:
      ==24129== 40 bytes in 5 blocks are definitely lost in loss record 355 of 637
      ==24129==    at 0x4A08B1C: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==24129==    by 0x5084B8E: virReallocN (viralloc.c:245)
      ==24129==    by 0x514D5AA: virDomainObjListExport (domain_conf.c:22200)
      ==24129==    by 0x201227DB: qemuConnectListAllDomains (qemu_driver.c:18042)
      ==24129==    by 0x51CC1B6: virConnectListAllDomains (libvirt-domain.c:6797)
      ==24129==    by 0x14173D: remoteDispatchConnectListAllDomains (remote.c:1580)
      ==24129==    by 0x121BE1: remoteDispatchConnectListAllDomainsHelper (remote_dispatch.h:1072)
      
      In short, every time a client calls a ListAll variant and asks
      for the resulting list, but there are 0 elements to return, we
      end up leaking the 1-entry array that holds the NULL terminator.
      
      What's worse, a read-only client can access these functions in a
      tight loop to cause libvirtd to eventually run out of memory; and
      this can be considered a denial of service attack against more
      privileged clients.  Thankfully, the leak is so small (8 bytes per
      call) that you would already have some other denial of service with
      any guest calling the API that frequently, so an out-of-memory
      crash is unlikely enough that this did not warrant a CVE.
      
      * daemon/remote.c (remoteDispatchConnectListAllDomains)
      (remoteDispatchDomainListAllSnapshots)
      (remoteDispatchDomainSnapshotListAllChildren)
      (remoteDispatchConnectListAllStoragePools)
      (remoteDispatchStoragePoolListAllVolumes)
      (remoteDispatchConnectListAllNetworks)
      (remoteDispatchConnectListAllInterfaces)
      (remoteDispatchConnectListAllNodeDevices)
      (remoteDispatchConnectListAllNWFilters)
      (remoteDispatchConnectListAllSecrets)
      (remoteDispatchNetworkGetDHCPLeases): Plug leak.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 3c2ff502)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      
      Conflicts:
      	daemon/remote.c - context with older cleanup styles
      b9dacdd4
  13. 26 2月, 2015 2 次提交
  14. 14 2月, 2015 1 次提交