Skip to content
Snippets Groups Projects
  1. Jun 05, 2023
  2. Nov 04, 2020
    • Ding Hui's avatar
      vnc: fix resource leak when websocket channel error · 2ddafce7
      Ding Hui authored
      
      When we connect to vnc by websocket channel, and disconnect
      (maybe by some network exception) before handshake,
      qemu will left CLOSE_WAIT socket and never close it
      
      After 04d2529d ("ui: convert VNC server to use QIOChannelSocket")
      and dd154c4d ("io: fix handling of EOF / error conditions in websock GSource"),
      the vnc call qio_channel_add_watch only care about G_IO_IN,
      but mising G_IO_HUP and G_IO_ERR.
      When the websocket channel get EOF or error, it cannot callback,
      because the caller ignore the event, that leads to resource leak
      
      We need handle G_IO_HUP and G_IO_ERR event, then cleanup the channel
      
      Fixes: 04d2529d ("ui: convert VNC server to use QIOChannelSocket")
      Fixes: dd154c4d ("io: fix handling of EOF / error conditions in websock GSource")
      Cc: qemu-stable@nongnu.org
      Signed-off-by: default avatarDing Hui <dinghui@sangfor.com.cn>
      Message-id: 20201029032241.11040-1-dinghui@sangfor.com.cn
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      2ddafce7
  3. Feb 26, 2019
  4. Mar 06, 2018
  5. Oct 04, 2017
  6. Sep 29, 2017
  7. Jan 23, 2017
  8. Oct 27, 2016
  9. Oct 13, 2016
  10. May 19, 2016
  11. Mar 22, 2016
    • Markus Armbruster's avatar
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster authored
      
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  12. Feb 04, 2016
    • Peter Maydell's avatar
      ui: Clean up includes · e16f4c87
      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-2-git-send-email-peter.maydell@linaro.org
      e16f4c87
  13. Dec 18, 2015
  14. Sep 15, 2015
    • Daniel P. Berrangé's avatar
      ui: convert VNC server to use QCryptoTLSSession · 3e305e4a
      Daniel P. Berrangé authored
      
      Switch VNC server over to using the QCryptoTLSSession object
      for the TLS session. This removes the direct use of gnutls
      from the VNC server code. It also removes most knowledge
      about TLS certificate handling from the VNC server code.
      This has the nice effect that all the CONFIG_VNC_TLS
      conditionals go away and the user gets an actual error
      message when requesting TLS instead of it being silently
      ignored.
      
      With this change, the existing configuration options for
      enabling TLS with -vnc are deprecated.
      
      Old syntax for anon-DH credentials:
      
        -vnc hostname:0,tls
      
      New syntax:
      
        -object tls-creds-anon,id=tls0,endpoint=server \
        -vnc hostname:0,tls-creds=tls0
      
      Old syntax for x509 credentials, no client certs:
      
        -vnc hostname:0,tls,x509=/path/to/certs
      
      New syntax:
      
        -object tls-creds-x509,id=tls0,dir=/path/to/certs,endpoint=server,verify-peer=no \
        -vnc hostname:0,tls-creds=tls0
      
      Old syntax for x509 credentials, requiring client certs:
      
        -vnc hostname:0,tls,x509verify=/path/to/certs
      
      New syntax:
      
        -object tls-creds-x509,id=tls0,dir=/path/to/certs,endpoint=server,verify-peer=yes \
        -vnc hostname:0,tls-creds=tls0
      
      This aligns VNC with the way TLS credentials are to be
      configured in the future for chardev, nbd and migration
      backends. It also has the benefit that the same TLS
      credentials can be shared across multiple VNC server
      instances, if desired.
      
      If someone uses the deprecated syntax, it will internally
      result in the creation of a 'tls-creds' object with an ID
      based on the VNC server ID. This allows backwards compat
      with the CLI syntax, while still deleting all the original
      TLS code from the VNC server.
      
      Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
      3e305e4a
  15. Jul 08, 2015
  16. Jun 12, 2015
  17. Apr 30, 2015
  18. Apr 01, 2015
    • Daniel P. Berrangé's avatar
      CVE-2015-1779: limit size of HTTP headers from websockets clients · 2cdb5e14
      Daniel P. Berrangé authored
      
      The VNC server websockets decoder will read and buffer data from
      websockets clients until it sees the end of the HTTP headers,
      as indicated by \r\n\r\n. In theory this allows a malicious to
      trick QEMU into consuming an arbitrary amount of RAM. In practice,
      because QEMU runs g_strstr_len() across the buffered header data,
      it will spend increasingly long burning CPU time searching for
      the substring match and less & less time reading data. So while
      this does cause arbitrary memory growth, the bigger problem is
      that QEMU will be burning 100% of available CPU time.
      
      A novnc websockets client typically sends headers of around
      512 bytes in length. As such it is reasonable to place a 4096
      byte limit on the amount of data buffered while searching for
      the end of HTTP headers.
      
      Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      2cdb5e14
    • Daniel P. Berrangé's avatar
      CVE-2015-1779: incrementally decode websocket frames · a2bebfd6
      Daniel P. Berrangé authored
      
      The logic for decoding websocket frames wants to fully
      decode the frame header and payload, before allowing the
      VNC server to see any of the payload data. There is no
      size limit on websocket payloads, so this allows a
      malicious network client to consume 2^64 bytes in memory
      in QEMU. It can trigger this denial of service before
      the VNC server even performs any authentication.
      
      The fix is to decode the header, and then incrementally
      decode the payload data as it is needed. With this fix
      the websocket decoder will allow at most 4k of data to
      be buffered before decoding and processing payload.
      
      Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
      
      [ kraxel: fix frequent spurious disconnects, suggested by Peter Maydell ]
      
        @@ -361,7 +361,7 @@ int vncws_decode_frame_payload(Buffer *input,
        -        *payload_size = input->offset;
        +        *payload_size = *payload_remain;
      
      [ kraxel: fix 32bit build ]
      
        @@ -306,7 +306,7 @@ struct VncState
        -    uint64_t ws_payload_remain;
        +    size_t ws_payload_remain;
      
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      a2bebfd6
  19. Mar 18, 2015
  20. Mar 10, 2015
  21. Aug 22, 2013
  22. May 03, 2013
    • Tim Hardeck's avatar
      TLS support for VNC Websockets · 0057a0d5
      Tim Hardeck authored
      
      Added TLS support to the VNC QEMU Websockets implementation.
      VNC-TLS needs to be enabled for this feature to be used.
      
      The required certificates are specified as in case of VNC-TLS
      with the VNC parameter "x509=<path>".
      
      If the server certificate isn't signed by a rooth authority it needs to
      be manually imported in the browser because at least in case of Firefox
      and Chrome there is no user dialog, the connection just gets canceled.
      
      As a side note VEncrypt over Websocket doesn't work atm because TLS can't
      be stacked in the current implementation. (It also didn't work before)
      Nevertheless to my knowledge there is no HTML 5 VNC client which supports
      it and the Websocket connection can be encrypted with regular TLS now so
      it should be fine for most use cases.
      
      Signed-off-by: default avatarTim Hardeck <thardeck@suse.de>
      Reviewed-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
      Message-id: 1366727581-5772-1-git-send-email-thardeck@suse.de
      Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
      0057a0d5
  23. Jan 30, 2013
  24. Jan 21, 2013
    • Tim Hardeck's avatar
      vnc: added initial websocket protocol support · 7536ee4b
      Tim Hardeck authored
      
      This patch adds basic Websocket Protocol version 13 - RFC 6455 - support
      to QEMU VNC. Binary encoding support on the client side is mandatory.
      
      Because of the GnuTLS requirement the Websockets implementation is
      optional (--enable-vnc-ws).
      
      To activate Websocket support the VNC option "websocket"is used, for
      example "-vnc :0,websocket".
      The listen port for Websocket connections is (5700 + display) so if
      QEMU VNC is started with :0 the Websocket port would be 5700.
      As an alternative the Websocket port could be manually specified by
      using ",websocket=<port>" instead.
      
      Parts of the implementation base on Anthony Liguori's QEMU Websocket
      patch from 2010 and on Joel Martin's LibVNC Websocket implementation.
      
      Signed-off-by: default avatarTim Hardeck <thardeck@suse.de>
      Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
      7536ee4b
Loading