1. 15 1月, 2018 17 次提交
  2. 13 1月, 2018 2 次提交
    • P
      Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180112-pull-request' into staging · c7947342
      Peter Maydell 提交于
      sdl2: bugfixes.
      spice: cleanups.
      input: mem leak fix.
      gtk: deprecate 2.x support.
      
      # gpg: Signature made Fri 12 Jan 2018 14:52:39 GMT
      # gpg:                using RSA key 0x4CB6D8EED3E87138
      # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
      # gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
      # gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
      # Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138
      
      * remotes/kraxel/tags/ui-20180112-pull-request:
        sdl2: Ignore UI hotkeys after a focus change when GUI modifier is held
        sdl2 uses surface relative coordinates
        sdl2: Do not hide the cursor on auxilliary windows
        spice: remove unused timer list
        spice: remove only written event_mask field
        spice: remove unused watch list
        spice: remove QXLWorker interface field
        ui: deprecate use of GTK 2.x in favour of 3.x series
        input: fix memory leak
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      c7947342
    • P
      Merge remote-tracking branch 'remotes/kraxel/tags/vnc-20180112-pull-request' into staging · 7398166d
      Peter Maydell 提交于
      vnc: limit memory usage (CVE-2017-15124)
      
      # gpg: Signature made Fri 12 Jan 2018 12:57:22 GMT
      # gpg:                using RSA key 0x4CB6D8EED3E87138
      # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
      # gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
      # gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
      # Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138
      
      * remotes/kraxel/tags/vnc-20180112-pull-request:
        ui: mix misleading comments & return types of VNC I/O helper methods
        ui: add trace events related to VNC client throttling
        ui: place a hard cap on VNC server output buffer size
        ui: fix VNC client throttling when forced update is requested
        ui: fix VNC client throttling when audio capture is active
        ui: refactor code for determining if an update should be sent to the client
        ui: correctly reset framebuffer update state after processing dirty regions
        ui: introduce enum to track VNC client framebuffer update request state
        ui: track how much decoded data we consumed when doing SASL encoding
        ui: avoid pointless VNC updates if framebuffer isn't dirty
        ui: remove redundant indentation in vnc_client_update
        ui: remove unreachable code in vnc_update_client
        ui: remove 'sync' parameter from vnc_update_client
        vnc: fix debug spelling
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      7398166d
  3. 12 1月, 2018 21 次提交
    • J
      sdl2: Ignore UI hotkeys after a focus change when GUI modifier is held · 849bbe60
      Jindrich Makovicka 提交于
      When SDL2 windows change focus while a key is held, the window that
      receives the focus also receives a new KeyDown event, without an
      autorepeat flag. This means that if a WM places the qemu console
      over the main window after Ctrl-Alt-2, the console closes immediately
      after opening. Then, the main window receives the KeyDown event again
      and the whole process repeats.
      
      This patch makes the SDL2 UI ignore the KeyDown events on a window that
      just received the focus, if the GUI modifier was held. The ignore flag
      is reset on a first KeyUp event. This effectively works around the issue
      above.
      Signed-off-by: NJindrich Makovicka <makovick@gmail.com>
      Message-Id: <20171117112258.5888-4-makovick@gmail.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      849bbe60
    • J
      sdl2 uses surface relative coordinates · d9f06262
      Jindrich Makovicka 提交于
      This patch fixes mouse positioning with -device usb-tablet and fullscreen
      or resized window.
      
      Fixes: 46522a82Signed-off-by: NJindrich Makovicka <makovick@gmail.com>
      Message-Id: <20171117112258.5888-3-makovick@gmail.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      d9f06262
    • J
      sdl2: Do not hide the cursor on auxilliary windows · 28216716
      Jindrich Makovicka 提交于
      Signed-off-by: NJindrich Makovicka <makovick@gmail.com>
      Message-Id: <20171117112258.5888-2-makovick@gmail.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      28216716
    • P
      target/xtensa: Remove duplicate typedef of DisasContext · a3380cf6
      Peter Maydell 提交于
      Some older versions of gcc complain if a typedef is defined twice:
      
      target/xtensa/translate.c:81: error: redefinition of typedef 'DisasContext'
      target/xtensa/cpu.h:339: note: previous declaration of 'DisasContext' was here
      
      Remove the now-redundant typedef from the definition of the struct in
      translate.c.
      Reported-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1515762528-22818-1-git-send-email-peter.maydell@linaro.org
      a3380cf6
    • F
      spice: remove unused timer list · abda4766
      Frediano Ziglio 提交于
      Signed-off-by: NFrediano Ziglio <fziglio@redhat.com>
      Message-id: 20171122135625.16625-4-fziglio@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      abda4766
    • F
      spice: remove only written event_mask field · 58a5d33a
      Frediano Ziglio 提交于
      Signed-off-by: NFrediano Ziglio <fziglio@redhat.com>
      Message-id: 20171122135625.16625-3-fziglio@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      58a5d33a
    • F
      spice: remove unused watch list · 44e8f229
      Frediano Ziglio 提交于
      Signed-off-by: NFrediano Ziglio <fziglio@redhat.com>
      Message-id: 20171122135625.16625-2-fziglio@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      44e8f229
    • F
      spice: remove QXLWorker interface field · 9fedfa49
      Frediano Ziglio 提交于
      This fields points to an old interface that is no more
      used in the current code.
      Signed-off-by: NFrediano Ziglio <fziglio@redhat.com>
      Message-id: 20171122135625.16625-1-fziglio@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      9fedfa49
    • D
      ui: deprecate use of GTK 2.x in favour of 3.x series · b7715af2
      Daniel P. Berrange 提交于
      The GTK 3.0 release was made in Feb, 2011:
      
        https://blog.gtk.org/2011/02/10/gtk-3-0-released/
      
      That will soon be 7 years ago, which is enough time to consider
      the 3.x series widely supported.
      
      Thus we deprecate the GTK 2.x support, which will allow us to
      delete it in the last release of 2018. By this time, GTK 3.x
      will be almost 8 years old.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-id: 20171212113440.16483-1-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      b7715af2
    • L
      input: fix memory leak · fca4774a
      linzhecheng 提交于
      If kbd_queue is not empty and queue_count >= queue_limit,
      we should free evt.
      
      Change-Id: Ieeacf90d5e7e370a40452ec79031912d8b864d83
      Signed-off-by: Nlinzhecheng <linzhecheng@huawei.com>
      Message-id: 20171225023730.5512-1-linzhecheng@huawei.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      fca4774a
    • D
      ui: mix misleading comments & return types of VNC I/O helper methods · 30b80fd5
      Daniel P. Berrange 提交于
      While the QIOChannel APIs for reading/writing data return ssize_t, with negative
      value indicating an error, the VNC code passes this return value through the
      vnc_client_io_error() method. This detects the error condition, disconnects the
      client and returns 0 to indicate error. Thus all the VNC helper methods should
      return size_t (unsigned), and misleading comments which refer to the possibility
      of negative return values need fixing.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20171218191228.31018-14-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      30b80fd5
    • D
      ui: add trace events related to VNC client throttling · 6aa22a29
      Daniel P. Berrange 提交于
      The VNC client throttling is quite subtle so will benefit from having trace
      points available for live debugging.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20171218191228.31018-13-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      6aa22a29
    • D
      ui: place a hard cap on VNC server output buffer size · f887cf16
      Daniel P. Berrange 提交于
      The previous patches fix problems with throttling of forced framebuffer updates
      and audio data capture that would cause the QEMU output buffer size to grow
      without bound. Those fixes are graceful in that once the client catches up with
      reading data from the server, everything continues operating normally.
      
      There is some data which the server sends to the client that is impractical to
      throttle. Specifically there are various pseudo framebuffer update encodings to
      inform the client of things like desktop resizes, pointer changes, audio
      playback start/stop, LED state and so on. These generally only involve sending
      a very small amount of data to the client, but a malicious guest might be able
      to do things that trigger these changes at a very high rate. Throttling them is
      not practical as missed or delayed events would cause broken behaviour for the
      client.
      
      This patch thus takes a more forceful approach of setting an absolute upper
      bound on the amount of data we permit to be present in the output buffer at
      any time. The previous patch set a threshold for throttling the output buffer
      by allowing an amount of data equivalent to one complete framebuffer update and
      one seconds worth of audio data. On top of this it allowed for one further
      forced framebuffer update to be queued.
      
      To be conservative, we thus take that throttling threshold and multiply it by
      5 to form an absolute upper bound. If this bound is hit during vnc_write() we
      forceably disconnect the client, refusing to queue further data. This limit is
      high enough that it should never be hit unless a malicious client is trying to
      exploit the sever, or the network is completely saturated preventing any sending
      of data on the socket.
      
      This completes the fix for CVE-2017-15124 started in the previous patches.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20171218191228.31018-12-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      f887cf16
    • D
      ui: fix VNC client throttling when forced update is requested · ada8d2e4
      Daniel P. Berrange 提交于
      The VNC server must throttle data sent to the client to prevent the 'output'
      buffer size growing without bound, if the client stops reading data off the
      socket (either maliciously or due to stalled/slow network connection).
      
      The current throttling is very crude because it simply checks whether the
      output buffer offset is zero. This check is disabled if the client has requested
      a forced update, because we want to send these as soon as possible.
      
      As a result, the VNC client can cause QEMU to allocate arbitrary amounts of RAM.
      They can first start something in the guest that triggers lots of framebuffer
      updates eg play a youtube video. Then repeatedly send full framebuffer update
      requests, but never read data back from the server. This can easily make QEMU's
      VNC server send buffer consume 100MB of RAM per second, until the OOM killer
      starts reaping processes (hopefully the rogue QEMU process, but it might pick
      others...).
      
      To address this we make the throttling more intelligent, so we can throttle
      full updates. When we get a forced update request, we keep track of exactly how
      much data we put on the output buffer. We will not process a subsequent forced
      update request until this data has been fully sent on the wire. We always allow
      one forced update request to be in flight, regardless of what data is queued
      for incremental updates or audio data. The slight complication is that we do
      not initially know how much data an update will send, as this is done in the
      background by the VNC job thread. So we must track the fact that the job thread
      has an update pending, and not process any further updates until this job is
      has been completed & put data on the output buffer.
      
      This unbounded memory growth affects all VNC server configurations supported by
      QEMU, with no workaround possible. The mitigating factor is that it can only be
      triggered by a client that has authenticated with the VNC server, and who is
      able to trigger a large quantity of framebuffer updates or audio samples from
      the guest OS. Mostly they'll just succeed in getting the OOM killer to kill
      their own QEMU process, but its possible other processes can get taken out as
      collateral damage.
      
      This is a more general variant of the similar unbounded memory usage flaw in
      the websockets server, that was previously assigned CVE-2017-15268, and fixed
      in 2.11 by:
      
        commit a7b20a8e
        Author: Daniel P. Berrange <berrange@redhat.com>
        Date:   Mon Oct 9 14:43:42 2017 +0100
      
          io: monitor encoutput buffer size from websocket GSource
      
      This new general memory usage flaw has been assigned CVE-2017-15124, and is
      partially fixed by this patch.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20171218191228.31018-11-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      ada8d2e4
    • D
      ui: fix VNC client throttling when audio capture is active · e2b72cb6
      Daniel P. Berrange 提交于
      The VNC server must throttle data sent to the client to prevent the 'output'
      buffer size growing without bound, if the client stops reading data off the
      socket (either maliciously or due to stalled/slow network connection).
      
      The current throttling is very crude because it simply checks whether the
      output buffer offset is zero. This check must be disabled if audio capture is
      enabled, because when streaming audio the output buffer offset will rarely be
      zero due to queued audio data, and so this would starve framebuffer updates.
      
      As a result, the VNC client can cause QEMU to allocate arbitrary amounts of RAM.
      They can first start something in the guest that triggers lots of framebuffer
      updates eg play a youtube video. Then enable audio capture, and simply never
      read data back from the server. This can easily make QEMU's VNC server send
      buffer consume 100MB of RAM per second, until the OOM killer starts reaping
      processes (hopefully the rogue QEMU process, but it might pick others...).
      
      To address this we make the throttling more intelligent, so we can throttle
      when audio capture is active too. To determine how to throttle incremental
      updates or audio data, we calculate a size threshold. Normally the threshold is
      the approximate number of bytes associated with a single complete framebuffer
      update. ie width * height * bytes per pixel. We'll send incremental updates
      until we hit this threshold, at which point we'll stop sending updates until
      data has been written to the wire, causing the output buffer offset to fall
      back below the threshold.
      
      If audio capture is enabled, we increase the size of the threshold to also
      allow for upto 1 seconds worth of audio data samples. ie nchannels * bytes
      per sample * frequency. This allows the output buffer to have a mixture of
      incremental framebuffer updates and audio data queued, but once the threshold
      is exceeded, audio data will be dropped and incremental updates will be
      throttled.
      
      This unbounded memory growth affects all VNC server configurations supported by
      QEMU, with no workaround possible. The mitigating factor is that it can only be
      triggered by a client that has authenticated with the VNC server, and who is
      able to trigger a large quantity of framebuffer updates or audio samples from
      the guest OS. Mostly they'll just succeed in getting the OOM killer to kill
      their own QEMU process, but its possible other processes can get taken out as
      collateral damage.
      
      This is a more general variant of the similar unbounded memory usage flaw in
      the websockets server, that was previously assigned CVE-2017-15268, and fixed
      in 2.11 by:
      
        commit a7b20a8e
        Author: Daniel P. Berrange <berrange@redhat.com>
        Date:   Mon Oct 9 14:43:42 2017 +0100
      
          io: monitor encoutput buffer size from websocket GSource
      
      This new general memory usage flaw has been assigned CVE-2017-15124, and is
      partially fixed by this patch.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20171218191228.31018-10-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      e2b72cb6
    • D
      ui: refactor code for determining if an update should be sent to the client · 0bad8342
      Daniel P. Berrange 提交于
      The logic for determining if it is possible to send an update to the client
      will become more complicated shortly, so pull it out into a separate method
      for easier extension later.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20171218191228.31018-9-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      0bad8342
    • D
      ui: correctly reset framebuffer update state after processing dirty regions · 728a7ac9
      Daniel P. Berrange 提交于
      According to the RFB protocol, a client sends one or more framebuffer update
      requests to the server. The server can reply with a single framebuffer update
      response, that covers all previously received requests. Once the client has
      read this update from the server, it may send further framebuffer update
      requests to monitor future changes. The client is free to delay sending the
      framebuffer update request if it needs to throttle the amount of data it is
      reading from the server.
      
      The QEMU VNC server, however, has never correctly handled the framebuffer
      update requests. Once QEMU has received an update request, it will continue to
      send client updates forever, even if the client hasn't asked for further
      updates. This prevents the client from throttling back data it gets from the
      server. This change fixes the flawed logic such that after a set of updates are
      sent out, QEMU waits for a further update request before sending more data.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20171218191228.31018-8-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      728a7ac9
    • D
      ui: introduce enum to track VNC client framebuffer update request state · fef1bbad
      Daniel P. Berrange 提交于
      Currently the VNC servers tracks whether a client has requested an incremental
      or forced update with two boolean flags. There are only really 3 distinct
      states to track, so create an enum to more accurately reflect permitted states.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20171218191228.31018-7-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      fef1bbad
    • D
      ui: track how much decoded data we consumed when doing SASL encoding · 8f61f1c5
      Daniel P. Berrange 提交于
      When we encode data for writing with SASL, we encode the entire pending output
      buffer. The subsequent write, however, may not be able to send the full encoded
      data in one go though, particularly with a slow network. So we delay setting the
      output buffer offset back to zero until all the SASL encoded data is sent.
      
      Between encoding the data and completing sending of the SASL encoded data,
      however, more data might have been placed on the pending output buffer. So it
      is not valid to set offset back to zero. Instead we must keep track of how much
      data we consumed during encoding and subtract only that amount.
      
      With the current bug we would be throwing away some pending data without having
      sent it at all. By sheer luck this did not previously cause any serious problem
      because appending data to the send buffer is always an atomic action, so we
      only ever throw away complete RFB protocol messages. In the case of frame buffer
      updates we'd catch up fairly quickly, so no obvious problem was visible.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20171218191228.31018-6-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      8f61f1c5
    • D
      ui: avoid pointless VNC updates if framebuffer isn't dirty · 3541b084
      Daniel P. Berrange 提交于
      The vnc_update_client() method checks the 'has_dirty' flag to see if there are
      dirty regions that are pending to send to the client. Regardless of this flag,
      if a forced update is requested, updates must be sent. For unknown reasons
      though, the code also tries to sent updates if audio capture is enabled. This
      makes no sense as audio capture state does not impact framebuffer contents, so
      this check is removed.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20171218191228.31018-5-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      3541b084
    • D
      ui: remove redundant indentation in vnc_client_update · b939eb89
      Daniel P. Berrange 提交于
      Now that previous dead / unreachable code has been removed, we can simplify
      the indentation in the vnc_client_update method.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20171218191228.31018-4-berrange@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      b939eb89