1. 20 12月, 2013 1 次提交
    • M
      CVE-2013-6436: fix crash in lxcDomainGetMemoryParameters · 218bd2e8
      Martin Kletzander 提交于
      The function doesn't check whether the request is made for active or
      inactive domain.  Thus when the domain is not running it still tries
      accessing non-existing cgroups (priv->cgroup, which is NULL).
      
      I re-made the function in order for it to work the same way it's qemu
      counterpart does.
      
      Reproducer:
       1) Define an LXC domain
       2) Do 'virsh memtune <domain>'
      
      Backtrace:
       Thread 6 (Thread 0x7fffec8c0700 (LWP 13387)):
       #0  0x00007ffff70edcc4 in virCgroupPathOfController (group=0x0, controller=3,
           key=0x7ffff75734bd "memory.limit_in_bytes", path=0x7fffec8bf750) at util/vircgroup.c:1764
       #1  0x00007ffff70e958c in virCgroupGetValueStr (group=0x0, controller=3,
           key=0x7ffff75734bd "memory.limit_in_bytes", value=0x7fffec8bf7c0) at util/vircgroup.c:705
       #2  0x00007ffff70e9d29 in virCgroupGetValueU64 (group=0x0, controller=3,
           key=0x7ffff75734bd "memory.limit_in_bytes", value=0x7fffec8bf810) at util/vircgroup.c:804
       #3  0x00007ffff70ee706 in virCgroupGetMemoryHardLimit (group=0x0, kb=0x7fffec8bf8a8)
           at util/vircgroup.c:1962
       #4  0x00005555557d590f in lxcDomainGetMemoryParameters (dom=0x7fffd40024a0,
           params=0x7fffd40027a0, nparams=0x7fffec8bfa24, flags=0) at lxc/lxc_driver.c:826
       #5  0x00007ffff72c28d3 in virDomainGetMemoryParameters (domain=0x7fffd40024a0,
           params=0x7fffd40027a0, nparams=0x7fffec8bfa24, flags=0) at libvirt.c:4137
       #6  0x000055555563714d in remoteDispatchDomainGetMemoryParameters (server=0x555555eb7e00,
           client=0x555555ebaef0, msg=0x555555ebb3e0, rerr=0x7fffec8bfb70, args=0x7fffd40024e0,
           ret=0x7fffd4002420) at remote.c:1895
       #7  0x00005555556052c4 in remoteDispatchDomainGetMemoryParametersHelper (server=0x555555eb7e00,
           client=0x555555ebaef0, msg=0x555555ebb3e0, rerr=0x7fffec8bfb70, args=0x7fffd40024e0,
           ret=0x7fffd4002420) at remote_dispatch.h:4050
       #8  0x00007ffff73b293f in virNetServerProgramDispatchCall (prog=0x555555ec3ae0,
           server=0x555555eb7e00, client=0x555555ebaef0, msg=0x555555ebb3e0)
           at rpc/virnetserverprogram.c:435
       #9  0x00007ffff73b207f in virNetServerProgramDispatch (prog=0x555555ec3ae0,
           server=0x555555eb7e00, client=0x555555ebaef0, msg=0x555555ebb3e0)
           at rpc/virnetserverprogram.c:305
       #10 0x00007ffff73a4d2c in virNetServerProcessMsg (srv=0x555555eb7e00, client=0x555555ebaef0,
           prog=0x555555ec3ae0, msg=0x555555ebb3e0) at rpc/virnetserver.c:165
       #11 0x00007ffff73a4e8d in virNetServerHandleJob (jobOpaque=0x555555ebc7e0, opaque=0x555555eb7e00)
           at rpc/virnetserver.c:186
       #12 0x00007ffff7187f3f in virThreadPoolWorker (opaque=0x555555eb7ac0) at util/virthreadpool.c:144
       #13 0x00007ffff718733a in virThreadHelper (data=0x555555eb7890) at util/virthreadpthread.c:161
       #14 0x00007ffff468ed89 in start_thread (arg=0x7fffec8c0700) at pthread_create.c:308
       #15 0x00007ffff3da26bd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      (cherry picked from commit f8c1cb90)
      
      Conflicts:
      	src/lxc/lxc_driver.c
      218bd2e8
  2. 15 12月, 2013 4 次提交
    • C
      Prep for release 1.0.5.8 · 2d0a9b97
      Cole Robinson 提交于
      2d0a9b97
    • C
      Tie SASL callbacks lifecycle to virNetSessionSASLContext · 46a6015b
      Christophe Fergeau 提交于
      The array of sasl_callback_t callbacks which is passed to sasl_client_new()
      must be kept alive as long as the created sasl_conn_t object is alive as
      cyrus-sasl uses this structure internally for things like logging, so
      the memory used for callbacks must only be freed after sasl_dispose() has
      been called.
      
      During testing of successful SASL logins with
      virsh -c qemu+tls:///system list --all
      I've been getting invalid read reports from valgrind
      
      ==9237== Invalid read of size 8
      ==9237==    at 0x6E93B6F: _sasl_getcallback (common.c:1745)
      ==9237==    by 0x6E95430: _sasl_log (common.c:1850)
      ==9237==    by 0x16593D87: digestmd5_client_mech_dispose (digestmd5.c:4580)
      ==9237==    by 0x6E91653: client_dispose (client.c:332)
      ==9237==    by 0x6E9476A: sasl_dispose (common.c:851)
      ==9237==    by 0x4E225A1: virNetSASLSessionDispose (virnetsaslcontext.c:678)
      ==9237==    by 0x4CBC551: virObjectUnref (virobject.c:262)
      ==9237==    by 0x4E254D1: virNetSocketDispose (virnetsocket.c:1042)
      ==9237==    by 0x4CBC551: virObjectUnref (virobject.c:262)
      ==9237==    by 0x4E2701C: virNetSocketEventFree (virnetsocket.c:1794)
      ==9237==    by 0x4C965D3: virEventPollCleanupHandles (vireventpoll.c:583)
      ==9237==    by 0x4C96987: virEventPollRunOnce (vireventpoll.c:652)
      ==9237==    by 0x4C94730: virEventRunDefaultImpl (virevent.c:274)
      ==9237==    by 0x12C7BA: vshEventLoop (virsh.c:2407)
      ==9237==    by 0x4CD3D04: virThreadHelper (virthreadpthread.c:161)
      ==9237==    by 0x7DAEF32: start_thread (pthread_create.c:309)
      ==9237==    by 0x8C86EAC: clone (clone.S:111)
      ==9237==  Address 0xe2d61b0 is 0 bytes inside a block of size 168 free'd
      ==9237==    at 0x4A07577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==9237==    by 0x4C73827: virFree (viralloc.c:580)
      ==9237==    by 0x4DE4BC7: remoteAuthSASL (remote_driver.c:4219)
      ==9237==    by 0x4DE33D0: remoteAuthenticate (remote_driver.c:3639)
      ==9237==    by 0x4DDBFAA: doRemoteOpen (remote_driver.c:832)
      ==9237==    by 0x4DDC8DC: remoteConnectOpen (remote_driver.c:1031)
      ==9237==    by 0x4D8595F: do_open (libvirt.c:1239)
      ==9237==    by 0x4D863F3: virConnectOpenAuth (libvirt.c:1481)
      ==9237==    by 0x12762B: vshReconnect (virsh.c:337)
      ==9237==    by 0x12C9B0: vshInit (virsh.c:2470)
      ==9237==    by 0x12E9A5: main (virsh.c:3338)
      
      This commit changes virNetSASLSessionNewClient() to take ownership of the SASL
      callbacks. Then we can free them in virNetSASLSessionDispose() after the corresponding
      sasl_conn_t has been freed.
      
      (cherry picked from commit 13fdc6d6)
      46a6015b
    • J
      spec: Don't save/restore running VMs on libvirt-client update · 140485ab
      Jiri Denemark 提交于
      The previous attempt (commit d65e0e14) removed just one of two
      libvirt-guests restarts that happened on libvirt-client update. Let's
      remove the last one too :-)
      
      https://bugzilla.redhat.com/show_bug.cgi?id=962225Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      (cherry picked from commit 604f79b3)
      140485ab
    • D
      Return right error code for baselineCPU · dba6ded8
      Don Dugger 提交于
      This Python interface code is returning a -1 on errors for the
      `baselineCPU' API.  Since this API is supposed to return a pointer
      the error return value should really be VIR_PY_NONE.
      
      NB:  I've checked all the other APIs in this file and this is the
      only pointer API that is returning -1.
      Signed-off-by: NDon Dugger <donald.d.dugger@intel.com>
      
      (crobinso: Upstream in libvirt-python.git)
      dba6ded8
  3. 22 11月, 2013 1 次提交
  4. 20 11月, 2013 3 次提交
  5. 18 11月, 2013 2 次提交
  6. 13 11月, 2013 1 次提交
    • J
      Disable nwfilter driver when running unprivileged · b2c87be9
      Ján Tomko 提交于
      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
      (cherry picked from commit b7829f95)
      b2c87be9
  7. 07 11月, 2013 4 次提交
    • J
      spec: Explicitly require libgcrypt-devel · c75683da
      Jiri Denemark 提交于
      Our configure.ac says:
      
          Not all versions of gnutls include -lgcrypt, and so we add
          it explicitly for the calls to gcry_control/check_version
      
      Thus we cannot rely on gnutls-devel to bring grcypt-devel as a
      dependency.
      
      (cherry picked from commit 3b50a711)
      c75683da
    • C
      Prep for release 1.0.5.7 · 7fd01c6a
      Cole Robinson 提交于
      7fd01c6a
    • M
      qemuSetupMemoryCgroup: Handle hard_limit properly · 11253a09
      Michal Privoznik 提交于
      Since 16bcb3 we have a regression. The hard_limit is set
      unconditionally. By default the limit is zero. Hence, if user hasn't
      configured any, we set the zero in cgroup subsystem making the kernel
      kill the corresponding qemu process immediately. The proper fix is to
      set hard_limit iff user has configured any.
      
      (cherry picked from commit 94a24dd3)
      
      Conflicts:
      	src/qemu/qemu_cgroup.c
      11253a09
    • M
      qemu: Drop qemuDomainMemoryLimit · 9421fd00
      Michal Privoznik 提交于
      This function is to guess the correct limit for maximal memory
      usage by qemu for given domain. This can never be guessed
      correctly, not to mention all the pains and sleepless nights this
      code has caused. Once somebody discovers algorithm to solve the
      Halting Problem, we can compute the limit algorithmically. But
      till then, this code should never see the light of the release
      again.
      
      (cherry picked from commit 16bcb3b6)
      
      Conflicts:
      	src/qemu/qemu_cgroup.c
      	src/qemu/qemu_command.c
      	src/qemu/qemu_domain.c
      	src/qemu/qemu_domain.h
      	src/qemu/qemu_hotplug.c
      9421fd00
  8. 18 10月, 2013 2 次提交
    • Z
      remote: fix regression in event deregistration · 03ba101a
      Zhou Yimin 提交于
      Introduced by 7b87a3
      When I quit the process which only register VIR_DOMAIN_EVENT_ID_REBOOT,
      I got error like:
      "libvirt: XML-RPC error : internal error: domain event 0 not registered".
      Then I add the following code, it fixed.
      Signed-off-by: NZhou Yimin <zhouyimin@huawei.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 9712c251)
      03ba101a
    • M
      virsh: Fix debugging · 99fa1ade
      Martin Kletzander 提交于
      Commit a0b6a36f "fixed" what abfff210 broke (URI precedence), but
      there was still one more thing missing to fix.  When using virsh
      parameters to setup debugging, those weren't honored, because at the
      time debugging was initializing, arguments weren't parsed yet.  To
      make ewerything work as expected, we need to initialize the debugging
      twice, once before debugging (so we can debug option parsing properly)
      and then again after these options are parsed.
      
      As a side effect, this patch also fixes a leak when virsh is ran with
      multiple '-l' parameters.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      (cherry picked from commit ac43da70)
      99fa1ade
  9. 15 10月, 2013 6 次提交
  10. 07 10月, 2013 7 次提交
  11. 03 10月, 2013 1 次提交
    • O
      virsh: Fix regression of vol-resize · 729bd0a3
      Osier Yang 提交于
      Introduced by commit 1daa4ba3. vshCommandOptStringReq returns
      0 on *success* or the option is not required && not present, both
      are right result. Error out when returning 0 is not correct.
      the caller, it doesn't have to check wether it
      (cherry picked from commit 2a3a725c)
      729bd0a3
  12. 21 9月, 2013 2 次提交
  13. 19 9月, 2013 3 次提交
    • D
      Fix crash in remoteDispatchDomainMemoryStats (CVE-2013-4296) · 118d26dc
      Daniel P. Berrange 提交于
      The 'stats' variable was not initialized to NULL, so if some
      early validation of the RPC call fails, it is possible to jump
      to the 'cleanup' label and VIR_FREE an uninitialized pointer.
      This is a security flaw, since the API can be called from a
      readonly connection which can trigger the validation checks.
      
      This was introduced in release v0.9.1 onwards by
      
        commit 158ba873
        Author: Daniel P. Berrange <berrange@redhat.com>
        Date:   Wed Apr 13 16:21:35 2011 +0100
      
          Merge all returns paths from dispatcher into single path
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit e7f400a1)
      
      Conflicts:
      	daemon/remote.c - context
      118d26dc
    • D
      Add support for using 3-arg pkcheck syntax for process (CVE-2013-4311) · 85ca4152
      Daniel P. Berrange 提交于
      With the existing pkcheck (pid, start time) tuple for identifying
      the process, there is a race condition, where a process can make
      a libvirt RPC call and in another thread exec a setuid application,
      causing it to change to effective UID 0. This in turn causes polkit
      to do its permission check based on the wrong UID.
      
      To address this, libvirt must get the UID the caller had at time
      of connect() (from SO_PEERCRED) and pass a (pid, start time, uid)
      triple to the pkcheck program.
      Signed-off-by: NColin Walters <walters@redhat.com>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 922b7fda)
      
      Conflicts:
      	src/access/viraccessdriverpolkit.c
      
      Resolution:
        Dropped file that does not exist in this branch.
      85ca4152
    • D
      Include process start time when doing polkit checks · 4407b19b
      Daniel P. Berrange 提交于
      Since PIDs can be reused, polkit prefers to be given
      a (PID,start time) pair. If given a PID on its own,
      it will attempt to lookup the start time in /proc/pid/stat,
      though this is subject to races.
      
      It is safer if the client app resolves the PID start
      time itself, because as long as the app has the client
      socket open, the client PID won't be reused.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 979e9c56)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      
      Conflicts:
      	src/rpc/virnetsocket.h - context
      	src/util/virprocess.c - needed #include "virstring.h"
      	src/util/virstring.c - context
      	src/util/virstring.h - context
      4407b19b
  14. 12 9月, 2013 1 次提交
    • M
      qemuDomainChangeGraphics: Check listen address change by listen type · 07381289
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1006697
      
      Currently, we have a bug when updating a graphics device. A graphics device can
      have a listen address set. This address is either defined by user (in which case
      it's type is VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) or it can be inherited
      from a network (in which case it's type is
      VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK). However, in both cases we have a
      listen address to process (e.g. during migration, as I've tried to fix in
      7f15ebc7).
      Later, when a user tries to update the graphics device (e.g. set a password),
      we check if listen addresses match the original as qemu doesn't know how to
      change listen address yet. Hence, users are required to not change the listen
      address. The implementation then just dumps listen addresses and compare them.
      Previously, while dumping the listen addresses, NULL was returned for NETWORK.
      After my patch, this is no longer true, and we get a listen address for olddev
      even if it is a type of NETWORK. So we have a real string on one side, the NULL
      from user's XML on the other side and hence we think user wants to change the
      listen address and we refuse it.
      
      Therefore, we must take the type of listen address into account as well.
      
      (cherry picked from commit 752596b5)
      07381289
  15. 29 8月, 2013 1 次提交
    • E
      security: provide supplemental groups even when parsing label (CVE-2013-4291) · 9a1145a9
      Eric Blake 提交于
      Commit 29fe5d74 (released in 1.1.1) introduced a latent problem
      for any caller of virSecurityManagerSetProcessLabel and where
      the domain already had a uid:gid label to be parsed.  Such a
      setup would collect the list of supplementary groups during
      virSecurityManagerPreFork, but then ignores that information,
      and thus fails to call setgroups() to adjust the supplementary
      groups of the process.
      
      Upstream does not use virSecurityManagerSetProcessLabel for
      qemu (it uses virSecurityManagerSetChildProcessLabel instead),
      so this problem remained latent until backporting the initial
      commit into v0.10.2-maint (commit c061ff5e, released in 0.10.2.7),
      where virSecurityManagerSetChildProcessLabel has not been
      backported.  As a result of using a different code path in the
      backport, attempts to start a qemu domain that runs as qemu:qemu
      will end up with supplementary groups unchanged from the libvirtd
      parent process, rather than the desired supplementary groups of
      the qemu user.  This can lead to failure to start a domain
      (typical Fedora setup assigns user 107 'qemu' to both group 107
      'qemu' and group 36 'kvm', so a disk image that is only readable
      under kvm group rights is locked out).  Worse, it is a security
      hole (the qemu process will inherit supplemental group rights
      from the parent libvirtd process, which means it has access
      rights to files owned by group 0 even when such files should
      not normally be visible to user qemu).
      
      LXC does not use the DAC security driver, so it is not vulnerable
      at this time.  Still, it is better to plug the latent hole on
      the master branch first, before cherry-picking it to the only
      vulnerable branch v0.10.2-maint.
      
      * src/security/security_dac.c (virSecurityDACGetIds): Always populate
      groups and ngroups, rather than only when no label is parsed.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 745aa55f)
      9a1145a9
  16. 21 8月, 2013 1 次提交
    • G
      python: return dictionary without value in case of no blockjob · c43e7e20
      Guannan Ren 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=999077
      
      Currently, when there is no blockjob, dom.blockJobInfo('vda')
      still reports error because it doesn't distinguish return value 0 from -1.
      libvirt.libvirtError: virDomainGetBlockJobInfo() failed
      
      virDomainGetBlockJobInfo() API return value:
       -1 in case of failure, 0 when nothing found, 1 found.
      
      And use PyDict_SetItemString instead of PyDict_SetItem when key is
      of string type. PyDict_SetItemString increments key/value reference
      count, so call Py_DECREF() for value. For key, we don't need to
      do this, because PyDict_SetItemString will handle it internally.
      
      (cherry picked from commit 0f9e67bf)
      c43e7e20