1. 18 10月, 2013 1 次提交
  2. 03 10月, 2013 1 次提交
    • O
      virsh: Fix regression of vol-resize · 692474e6
      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)
      692474e6
  3. 19 9月, 2013 3 次提交
    • D
      Fix crash in remoteDispatchDomainMemoryStats (CVE-2013-4296) · 95983486
      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
      95983486
    • D
      Add support for using 3-arg pkcheck syntax for process (CVE-2013-4311) · a01514b2
      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.
      a01514b2
    • D
      Include process start time when doing polkit checks · 65f7c07c
      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)
      
      Conflicts:
      	src/util/virprocess.c
      	src/util/virstring.c
      	src/util/virstring.h
      65f7c07c
  4. 20 8月, 2013 1 次提交
    • P
      virbitmap: Refactor virBitmapParse to avoid access beyond bounds of array · b68a721d
      Peter Krempa 提交于
      The virBitmapParse function was calling virBitmapIsSet() function that
      requires the caller to check the bounds of the bitmap without checking
      them. This resulted into crashes when parsing a bitmap string that was
      exceeding the bounds used as argument.
      
      This patch refactors the function to use virBitmapSetBit without
      checking if the bit is set (this function does the checks internally)
      and then counts the bits in the bitmap afterwards (instead of keeping
      track while parsing the string).
      
      This patch also changes the "parse_error" label to a more common
      "error".
      
      The refactor should also get rid of the need to call sa_assert on the
      returned variable as the callpath should allow coverity to infer the
      possible return values.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=997367
      
      Thanks to Alex Jia for tracking down the issue. This issue is introduced
      by commit 0fc89098.
      
      (cherry picked from commit 47b9127e)
      b68a721d
  5. 11 7月, 2013 2 次提交
  6. 01 7月, 2013 4 次提交
  7. 20 6月, 2013 2 次提交
    • J
      lxc: Resolve issue with GetScheduler APIs for non running domain · ca62fde8
      John Ferlan 提交于
      Cherry-picked from 38ada092
      
      As a consequence of the cgroup layout changes from commit 'cfed9ad4', the
      lxcDomainGetSchedulerParameters[Flags]()' and lxcGetSchedulerType() APIs
      failed to return data for a non running domain.  This can be seen through
      a 'virsh schedinfo <domain>' command which returns:
      
      Scheduler      : Unknown
      error: Requested operation is not valid: cgroup CPU controller is not mounted
      
      Prior to that change a non running domain would return:
      
      Scheduler      : posix
      cpu_shares     : 0
      vcpu_period    : 0
      vcpu_quota     : 0
      emulator_period: 0
      emulator_quota : 0
      
      This patch will restore the capability to return configuration only data
      for a non running domain regardless of whether cgroups are available.
      
      Conflicts:
      	src/lxc/lxc_driver.c
      
        * Resolved conflict by using former lxcCgroupHasController() rather than
          virCgroupHasController()
        * Needed to add the code to fetch the 'vm'
           vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
           if (vm == NULL) {
               virReportError(VIR_ERR_INTERNAL_ERROR,
                              _("No such domain %s"), domain->uuid);
               goto cleanup;
           }
        * Used 'ret = strdup("posix");' rather than VIR_STRDUP(ret, "posix");
          and added the virReportOOMError(); on failure.
      ca62fde8
    • J
      qemu: Resolve issue with GetScheduler APIs for non running domain · 94c88b48
      John Ferlan 提交于
      Cherry-picked from b2375453
      
      As a consequence of the cgroup layout changes from commit '632f78ca', the
      qemuDomainGetSchedulerParameters[Flags]()' and qemuGetSchedulerType() APIs
      failed to return data for a non running domain.  This can be seen through
      a 'virsh schedinfo <domain>' command which returns:
      
      Scheduler      : Unknown
      error: Requested operation is not valid: cgroup CPU controller is not mounted
      
      Prior to that change a non running domain would return:
      
      Scheduler      : posix
      cpu_shares     : 0
      vcpu_period    : 0
      vcpu_quota     : 0
      emulator_period: 0
      emulator_quota : 0
      
      This patch will restore the capability to return configuration only data
      for a non running domain regardless of whether cgroups are available.
      
      Conflicts:
      	src/qemu/qemu_driver.c
      
       * Resolved conflict by using former qemuCgroupHasController() rather than
         virCgroupHasController()
       * Needed to add the code to fetch the 'vm'
            vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
            if (vm == NULL) {
                virReportError(VIR_ERR_INTERNAL_ERROR,
                               _("No such domain %s"), dom->uuid);
                goto cleanup;
            }
      * Used 'ret = strdup("posix");' rather than VIR_STRDUP(ret, "posix");
        and added the virReportOOMError(); on failure.
      94c88b48
  8. 18 6月, 2013 3 次提交
  9. 01 6月, 2013 1 次提交
    • L
      qemu: prevent termination of guests w/hostdev on driver reconnect · 1056bbdb
      Laine Stump 提交于
      This should resolve:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=959191
      
      The problem was that qemuUpdateActivePciHostdevs was returning 0
      (success) when no hostdevs were present, but would otherwise return -1
      (failure) even when it completed successfully. It is only called from
      qemuProcessReconnect(), and when qemuProcessReconnect got back an
      error, it would not only stop reconnecting, but would terminate the
      guest qemu process "to remove danger of it ending up running twice if
      user tries to start it again later".
      
      (This bug was introduced in commit 011cf7ad, which was pushed between
      v1.0.2 and v1.0.3, so all maintenance branches from v1.0.3 up to 1.0.5
      will need this one line patch applied.)
      (cherry picked from commit 2ea45647)
      1056bbdb
  10. 16 5月, 2013 1 次提交
    • J
      daemon: fix leak after listing all volumes · 24317824
      Ján Tomko 提交于
      CVE-2013-1962
      
      remoteDispatchStoragePoolListAllVolumes wasn't freeing the pool.
      The pool also held a reference to the connection, preventing it from
      getting freed and closing the netcf interface driver, which held two
      sockets open.
      (cherry picked from commit ca697e90)
      24317824
  11. 09 5月, 2013 4 次提交
  12. 23 4月, 2013 3 次提交
    • E
      maint: update to latest gnulib · 4c003e79
      Eric Blake 提交于
      Upstream gnulib determined that we were needlessly compiling in
      gnulib's regex instead of glibc's when targetting new-enough glibc,
      because the m4 test was being too strict in requiring a particular
      answer to undefined behavior.
      https://lists.gnu.org/archive/html/bug-gnulib/2013-04/msg00032.html
      
      * .gnulib: Update to latest, for regex.
      (cherry picked from commit 84243239)
      
      Cherry picked because I hit a failure of test-regex when swapping
      between incremental builds of libvirt.git master then v1.0.4-maint.
      4c003e79
    • E
      maint: update to latest gnulib · 97cf1706
      Eric Blake 提交于
      While this update doesn't address any reported problems in libvirt,
      doing a post-release update to latest gnulib makes it easier to
      stay in sync with best upstream practices.
      
      * .gnulib: Update to latest.
      * bootstrap: Resynchronize.
      (cherry picked from commit d7468b7d)
      97cf1706
    • E
      audit: properly encode device path in cgroup audit · 79c23e03
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=922186
      
      Commit d04916fa introduced a regression in audit quality - even
      though the code was computing the proper escaped name for a
      path, it wasn't feeding that escaped name on to the audit message.
      As a result, /var/log/audit/audit.log would mention a pair of
      fields class=path path=/dev/hpet instead of the intended
      class=path path="/dev/hpet", which in turn caused ausearch to
      format the audit log with path=(null).
      
      * src/conf/domain_audit.c (virDomainAuditCgroupPath): Use
      constructed encoding.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 31c6bf35)
      79c23e03
  13. 10 4月, 2013 14 次提交
    • A
      98afc745
    • J
      spec: Require pod2man when running autoreconf · 0f641de1
      Jiri Denemark 提交于
      Since commit b8a32e0e, all man pages
      depend on configure.ac so that they are properly regenerated whenever
      libvirt version changes. Thus libvirt.spec needs to have a build
      dependency on pod2man when %{enable_autotools} is set.
      (cherry picked from commit 6f1b9c8d)
      0f641de1
    • E
      build: check correct protocol.o file · dfb42ed1
      Eric Blake 提交于
      By default, libtool builds two .o files for every .lo rule:
      src/foo.o - static builds
      src/.libs/foo.o - shared library builds
      
      But since commit ad42b34b disabled static builds, src/foo.o is
      no longer built by default.  On a fresh checkout, this means our
      protocol check rules using pdwtags were testing a missing file,
      and thanks to a lousy behavior of pdwtags happily giving no output
      and 0 exit status (http://bugzilla.redhat.com/949034), we were
      merely claiming that "dwarves is too old" and skipping the test.
      
      However, if you swap between branches and do incremental builds,
      such as building v0.10.2-maint and then switching back to master,
      you end up with src/foo.o being leftover from its 0.10.2 state,
      and then 'make check' fails because the .o file does not match
      the protocol-structs file due to API additions in the meantime.
      
      A simpler fix would be to always look in .libs for the .o to
      be parsed; but since it is possible to pass ./configure options
      to tell libtool to do a static-only build with no shared .o,
      I went with the approach of finding the newest of the two files,
      whenever both exist.
      
      * src/Makefile.am (PDWTAGS): Ensure we test just-built file.
      (cherry picked from commit 5899e09e)
      dfb42ed1
    • D
      Ensure LD_PRELOAD exists before running test case · a243e21c
      Daniel P. Berrange 提交于
      The linker will ignore LD_PRELOAD libraries which do not
      exist, just printing a warning message. This is not helpful
      for the test suite which will be utterly fubar without the
      preload library present. Add an explicit test for existence
      of the library to protect against this
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit b1d3154a)
      a243e21c
    • P
      rpc: Fix connection close callback race condition and memory corruption/crash · d6ee2113
      Peter Krempa 提交于
      The last Viktor's effort to fix the race and memory corruption unfortunately
      wasn't complete in the case the close callback was not registered in an
      connection. At that time, the trail of event's that I'll describe later could
      still happen and corrupt the memory or cause a crash of the client (including
      the daemon in case of a p2p migration).
      
      Consider the following prerequisities and trail of events:
      Let's have a remote connection to a hypervisor that doesn't have a close
      callback registered and the client is using the event loop. The crash happens in
      cooperation of 2 threads. Thread E is the event loop and thread W is the worker
      that does some stuff. R denotes the remote client.
      
      1.) W - The client finishes everything and sheds the last reference on the client
      2.) W - The virObject stuff invokes virConnectDispose that invokes doRemoteClose
      3.) W - the remote close method invokes the REMOTE_PROC_CLOSE RPC method.
      4.) W - The thread is preempted at this point.
      5.) R - The remote side receives the close and closes the socket.
      6.) E - poll() wakes up due to the closed socket and invokes the close callback
      7.) E - The event loop is preempted right before remoteClientCloseFunc is called
      8.) W - The worker now finishes, and frees the conn object.
      9.) E - The remoteClientCloseFunc accesses the now-freed conn object in the
              attempt to retrieve pointer for the real close callback.
      10.) Kaboom, corrupted memory/segfault.
      
      This patch tries to fix this by introducing a new object that survives the
      freeing of the connection object. We can't increase the reference count on the
      connection object itself or the connection would never be closed, as the
      connection is closed only when the reference count reaches zero.
      
      The new object - virConnectCloseCallbackData - is a lockable object that keeps
      the pointers to the real user registered callback and ensures that the
      connection callback is either not called if the connection was already freed or
      that the connection isn't freed while this is being called.
      (cherry picked from commit 8ad126e6)
      d6ee2113
    • P
      virsh: Register and unregister the close callback also in cmdConnect · 3e13977c
      Peter Krempa 提交于
      This patch improves the error message after disconnecting from the
      hypervisor and adds the close callback operations required not to leak
      the callback reference.
      (cherry picked from commit 69ab0756)
      3e13977c
    • P
      virsh: Move cmdConnect from virsh-host.c to virsh.c · f4a7891e
      Peter Krempa 提交于
      The function is used to establish connection so it should be in the main
      virsh file. This movement also enables further improvements done in next
      patches.
      
      Note that the "connect" command has moved from the host section of virsh to the
      main section. It is now listed by 'virsh help virsh' instead of 'virsh help
      host'.
      (cherry picked from commit ca9e73eb)
      f4a7891e
    • V
      virsh: Unregister the connection close notifier upon termination · bec3cc73
      Viktor Mihajlovski 提交于
      Before closing the connection we unregister the close callback
      to prevent a reference leak.
      
      Further, the messages on virConnectClose != 0 are a bit more specific
      now.
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      (cherry picked from commit e964ba27)
      bec3cc73
    • V
      libvirt: Increase connection reference count for callbacks · cf7dbdd4
      Viktor Mihajlovski 提交于
      By adjusting the reference count of the connection object we
      prevent races between callback function and virConnectClose.
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      (cherry picked from commit 03a43efa)
      cf7dbdd4
    • A
      storage: Fix volume cloning for logical volume. · 7156c8c7
      Atsushi Kumagai 提交于
      When creating a logical volume with virStorageVolCreateXMLFrom,
      "qemu-img convert" is called internally if clonevol is a file volume.
      Then, vol->target.format is used as output_fmt parameter but the
      target.format of logical volumes is always 0 because logical volumes
      haven't the volume format type element.
      
      Fortunately, 0 was treated as RAW file format before commit f772b3d9,
      so there was no problem. But now, 0 is treated as the type of none,
      qemu-img fails with "Unknown file format 'none'".
      
      This patch fixes this issue by treating output block devices as RAW
      file format like for input block devices.
      Signed-off-by: NAtsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
      (cherry picked from commit d369e508)
      7156c8c7
    • D
      Enable full RELRO mode · d990d6ae
      Daniel P. Berrange 提交于
      By passing the flags -z relro -z now to the linker, we can force
      it to resolve all library symbols at startup, instead of on-demand.
      This allows it to then make the global offset table (GOT) read-only,
      which makes some security attacks harder.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit fc8c1787)
      d990d6ae
    • D
      Build all binaries with PIE · f0158023
      Daniel P. Berrange 提交于
      PIE (position independent executable) adds security to executables
      by composing them entirely of position-independent code (PIC. The
      .so libraries already build with -fPIC. This adds -fPIE which is
      the equivalent to -fPIC, but for executables. This for allows Exec
      Shield to use address space layout randomization to prevent attackers
      from knowing where existing executable code is during a security
      attack using exploits that rely on knowing the offset of the
      executable code in the binary, such as return-to-libc attacks.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 1150999c)
      f0158023
    • P
      qemu: Fix crash when updating media with shared device · 2a702717
      Peter Krempa 提交于
      Mimic the fix done in 02b90972 to fix crash by
      accessing an already freed structure. Also copy the explaining comment why the
      pointer can't be accessed any more.
      (cherry picked from commit 43b6f304)
      2a702717
    • M
      virsh: Call virDomainFree in cmdDomFSTrim · 5fdccc85
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=928197
      
      The virsh domfstrim command was not freeing allocated domain,
      leaving leaked references behind.
      (cherry picked from commit deb86ee9)
      5fdccc85