Skip to content
Snippets Groups Projects
  1. Mar 02, 2018
  2. Feb 09, 2018
  3. Jan 26, 2018
  4. Dec 21, 2017
  5. Jun 15, 2017
    • Eric Blake's avatar
      nbd: Fix regression on resiliency to port scan · 0c9390d9
      Eric Blake authored
      Back in qemu 2.5, qemu-nbd was immune to port probes (a transient
      server would not quit, regardless of how many probe connections
      came and went, until a connection actually negotiated).  But we
      broke that in commit ee7d7aab when removing the return value to
      nbd_client_new(), although that patch also introduced a bug causing
      an assertion failure on a client that fails negotiation.  We then
      made it worse during refactoring in commit 1a6245a5 (a segfault
      before we could even assert); the (masked) assertion was cleaned
      up in d3780c2d (still in 2.6), and just recently we finally fixed
      the segfault ("nbd: Fully intialize client in case of failed
      negotiation").  But that still means that ever since we added
      TLS support to qemu-nbd, we have been vulnerable to an ill-timed
      port-scan being able to cause a denial of service by taking down
      qemu-nbd before a real client has a chance to connect.
      
      Since negotiation is now handled asynchronously via coroutines,
      we no longer have a synchronous point of return by re-adding a
      return value to nbd_client_new().  So this patch instead wires
      things up to pass the negotiation status through the close_fn
      callback function.
      
      Simple test across two terminals:
      $ qemu-nbd -f raw -p 30001 file
      $ nmap 127.0.0.1 -p 30001 && \
        qemu-io -c 'r 0 512' -f raw nbd://localhost:30001
      
      Note that this patch does not change what constitutes successful
      negotiation (thus, a client must enter transmission phase before
      that client can be considered as a reason to terminate the server
      when the connection ends).  Perhaps we may want to tweak things
      in a later patch to also treat a client that uses NBD_OPT_ABORT
      as being a 'successful' negotiation (the client correctly talked
      the NBD protocol, and informed us it was not going to use our
      export after all), but that's a discussion for another day.
      
      Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1451614
      
      
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20170608222617.20376-1-eblake@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      0c9390d9
  6. May 09, 2017
  7. Apr 03, 2017
  8. Jan 31, 2017
  9. Oct 27, 2016
  10. Sep 05, 2016
    • Kevin Wolf's avatar
      nbd-server: Allow node name for nbd-server-add · 094138d0
      Kevin Wolf authored
      
      There is no reason why an NBD server couldn't be started for any node,
      even if it's not on the top level. This converts nbd-server-add to
      accept a node-name.
      
      Note that there is a semantic difference between using a BlockBackend
      name and the node name of its root: In the former case, the NBD server
      is closed on eject; in the latter case, the NBD server doesn't drop its
      reference and keeps the image file open this way.
      
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      094138d0
    • Kevin Wolf's avatar
      nbd-server: Use a separate BlockBackend · cd7fca95
      Kevin Wolf authored
      
      The builtin NBD server uses its own BlockBackend now instead of reusing
      the monitor/guest device one.
      
      This means that it has its own writethrough setting now. The builtin
      NBD server always uses writeback caching now regardless of whether the
      guest device has WCE enabled. qemu-nbd respects the cache mode given on
      the command line.
      
      We still need to keep a reference to the monitor BB because we put an
      eject notifier on it, but we don't use it for any I/O.
      
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      cd7fca95
  11. Feb 16, 2016
  12. Feb 04, 2016
    • Peter Maydell's avatar
      all: Clean up includes · d38ea87a
      Peter Maydell authored
      
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
      d38ea87a
  13. Feb 02, 2016
  14. Jan 15, 2016
    • Fam Zheng's avatar
      nbd: Always call "close_fn" in nbd_client_new · ee7d7aab
      Fam Zheng authored
      
      Rename the parameter "close" to "close_fn" to disambiguous with
      close(2).
      
      This unifies error handling paths of NBDClient allocation:
      nbd_client_new will shutdown the socket and call the "close_fn" callback
      if negotiation failed, so the caller don't need a different path than
      the normal close.
      
      The returned pointer is never used, make it void in preparation for the
      next patch.
      
      Signed-off-by: default avatarFam Zheng <famz@redhat.com>
      Message-Id: <1452760863-25350-2-git-send-email-famz@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      ee7d7aab
  15. Jun 22, 2015
  16. Jun 12, 2015
  17. Mar 25, 2015
  18. Mar 18, 2015
  19. Dec 10, 2014
  20. Aug 20, 2014
    • Markus Armbruster's avatar
      block: Use g_new() & friends where that makes obvious sense · 5839e53b
      Markus Armbruster authored
      
      g_new(T, n) is neater than g_malloc(sizeof(T) * n).  It's also safer,
      for two reasons.  One, it catches multiplication overflowing size_t.
      Two, it returns T * rather than void *, which lets the compiler catch
      more type errors.
      
      Patch created with Coccinelle, with two manual changes on top:
      
      * Add const to bdrv_iterate_format() to keep the types straight
      
      * Convert the allocation in bdrv_drop_intermediate(), which Coccinelle
        inexplicably misses
      
      Coccinelle semantic patch:
      
          @@
          type T;
          @@
          -g_malloc(sizeof(T))
          +g_new(T, 1)
          @@
          type T;
          @@
          -g_try_malloc(sizeof(T))
          +g_try_new(T, 1)
          @@
          type T;
          @@
          -g_malloc0(sizeof(T))
          +g_new0(T, 1)
          @@
          type T;
          @@
          -g_try_malloc0(sizeof(T))
          +g_try_new0(T, 1)
          @@
          type T;
          expression n;
          @@
          -g_malloc(sizeof(T) * (n))
          +g_new(T, n)
          @@
          type T;
          expression n;
          @@
          -g_try_malloc(sizeof(T) * (n))
          +g_try_new(T, n)
          @@
          type T;
          expression n;
          @@
          -g_malloc0(sizeof(T) * (n))
          +g_new0(T, n)
          @@
          type T;
          expression n;
          @@
          -g_try_malloc0(sizeof(T) * (n))
          +g_try_new0(T, n)
          @@
          type T;
          expression p, n;
          @@
          -g_realloc(p, sizeof(T) * (n))
          +g_renew(T, p, n)
          @@
          type T;
          expression p, n;
          @@
          -g_try_realloc(p, sizeof(T) * (n))
          +g_try_renew(T, p, n)
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarJeff Cody <jcody@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      5839e53b
  21. Jun 30, 2014
  22. Jun 27, 2014
    • Hani Benhabiles's avatar
      nbd: Don't export a block device with no medium. · 60fe4fac
      Hani Benhabiles authored
      
      The device is exported with erroneous values and can't be read.
      
      Before the patch:
      $ sudo nbd-client localhost -p 10809 /dev/nbd0 -name floppy0
      Negotiation: ..size = 17592186044415MB
      bs=1024, sz=18446744073709547520 bytes
      
      $ sudo mount /dev/nbd0 /mnt/tmp/
      mount: block device /dev/nbd0 is write-protected, mounting read-only
      mount: /dev/nbd0: can't read superblock
      
      After the patch:
      (qemu) nbd_server_add ide0-hd0
      (qemu) nbd_server_add floppy0
      Device 'floppy0' has no medium
      
      Signed-off-by: default avatarHani Benhabiles <kroosec@gmail.com>
      Cc: qemu-stable@nongnu.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      60fe4fac
  23. May 23, 2014
  24. Sep 06, 2013
  25. Apr 08, 2013
    • Paolo Bonzini's avatar
      hw: move headers to include/ · 0d09e41a
      Paolo Bonzini authored
      
      Many of these should be cleaned up with proper qdev-/QOM-ification.
      Right now there are many catch-all headers in include/hw/ARCH depending
      on cpu.h, and this makes it necessary to compile these files per-target.
      However, fixing this does not belong in these patches.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      0d09e41a
  26. Dec 19, 2012
  27. Nov 28, 2012
Loading