1. 02 4月, 2019 2 次提交
    • J
      net: drop too large packet early · b528bb28
      Jason Wang 提交于
      We try to detect and drop too large packet (>INT_MAX) in 1592a994
      ("net: ignore packet size greater than INT_MAX") during packet
      delivering. Unfortunately, this is not sufficient as we may hit
      another integer overflow when trying to queue such large packet in
      qemu_net_queue_append_iov():
      
      - size of the allocation may overflow on 32bit
      - packet->size is integer which may overflow even on 64bit
      
      Fixing this by moving the check to qemu_sendv_packet_async() which is
      the entrance of all networking codes and reduce the limit to
      NET_BUFSIZE to be more conservative. This works since:
      
      - For the callers that call qemu_sendv_packet_async() directly, they
        only care about if zero is returned to determine whether to prevent
        the source from producing more packets. A callback will be triggered
        if peer can accept more then source could be enabled. This is
        usually used by high speed networking implementation like virtio-net
        or netmap.
      - For the callers that call qemu_sendv_packet() that calls
        qemu_sendv_packet_async() indirectly, they often ignore the return
        value. In this case qemu will just the drop packets if peer can't
        receive.
      
      Qemu will copy the packet if it was queued. So it was safe for both
      kinds of the callers to assume the packet was sent.
      
      Since we move the check from qemu_deliver_packet_iov() to
      qemu_sendv_packet_async(), it would be safer to make
      qemu_deliver_packet_iov() static to prevent any external user in the
      future.
      
      This is a revised patch of CVE-2018-17963.
      
      Cc: qemu-stable@nongnu.org
      Cc: Li Qiang <liq3ea@163.com>
      Fixes: 1592a994 ("net: ignore packet size greater than INT_MAX")
      Reported-by: NLi Qiang <liq3ea@gmail.com>
      Reviewed-by: NLi Qiang <liq3ea@gmail.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Message-id: 20181204035347.6148-2-jasowang@redhat.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      (cherry picked from commit 25c01bd1)
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      b528bb28
    • M
      make-release: add skiboot .version file · 53a69e7e
      Michael Roth 提交于
      This is needed to build skiboot from tarball-distributed sources
      since the git data the make_release.sh script relies on to generate
      it is not available.
      
      Cc: qemu-stable@nongnu.org
      Reported-by: NMichael Tokarev <mjt@tls.msk.ru>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Message-id: 20181109161352.29873-1-mdroth@linux.vnet.ibm.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      (cherry picked from commit 3fccd3f2)
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      53a69e7e
  2. 27 3月, 2019 26 次提交
  3. 22 3月, 2019 9 次提交
  4. 19 3月, 2019 3 次提交
    • M
      monitor: fix oob command leak · d1c384fa
      Marc-André Lureau 提交于
      Spotted by ASAN, during make check...
      
      Direct leak of 40 byte(s) in 1 object(s) allocated from:
          #0 0x7f8e27262c48 in malloc (/lib64/libasan.so.5+0xeec48)
          #1 0x7f8e26a5f3c5 in g_malloc (/lib64/libglib-2.0.so.0+0x523c5)
          #2 0x555ab67078a8 in qstring_from_str /home/elmarco/src/qq/qobject/qstring.c:67
          #3 0x555ab67071e4 in qstring_new /home/elmarco/src/qq/qobject/qstring.c:24
          #4 0x555ab6713fbf in qstring_from_escaped_str /home/elmarco/src/qq/qobject/json-parser.c:144
          #5 0x555ab671738c in parse_literal /home/elmarco/src/qq/qobject/json-parser.c:506
          #6 0x555ab67179c3 in parse_value /home/elmarco/src/qq/qobject/json-parser.c:569
          #7 0x555ab6715123 in parse_pair /home/elmarco/src/qq/qobject/json-parser.c:306
          #8 0x555ab6715483 in parse_object /home/elmarco/src/qq/qobject/json-parser.c:357
          #9 0x555ab671798b in parse_value /home/elmarco/src/qq/qobject/json-parser.c:561
          #10 0x555ab6717a6b in json_parser_parse_err /home/elmarco/src/qq/qobject/json-parser.c:592
          #11 0x555ab4fd4dcf in handle_qmp_command /home/elmarco/src/qq/monitor.c:4257
          #12 0x555ab6712c4d in json_message_process_token /home/elmarco/src/qq/qobject/json-streamer.c:105
          #13 0x555ab67e01e2 in json_lexer_feed_char /home/elmarco/src/qq/qobject/json-lexer.c:323
          #14 0x555ab67e0af6 in json_lexer_feed /home/elmarco/src/qq/qobject/json-lexer.c:373
          #15 0x555ab6713010 in json_message_parser_feed /home/elmarco/src/qq/qobject/json-streamer.c:124
          #16 0x555ab4fd58ec in monitor_qmp_read /home/elmarco/src/qq/monitor.c:4337
          #17 0x555ab6559df2 in qemu_chr_be_write_impl /home/elmarco/src/qq/chardev/char.c:175
          #18 0x555ab6559e95 in qemu_chr_be_write /home/elmarco/src/qq/chardev/char.c:187
          #19 0x555ab6560127 in fd_chr_read /home/elmarco/src/qq/chardev/char-fd.c:66
          #20 0x555ab65d9c73 in qio_channel_fd_source_dispatch /home/elmarco/src/qq/io/channel-watch.c:84
          #21 0x7f8e26a598ac in g_main_context_dispatch (/lib64/libglib-2.0.so.0+0x4c8ac)
      Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20180809114417.28718-4-marcandre.lureau@redhat.com>
      [Screwed up in commit b2731456]
      Cc: qemu-stable@nongnu.org
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      (cherry picked from commit cb9ec42f)
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      d1c384fa
    • F
      aio: Do aio_notify_accept only during blocking aio_poll · 8f0e1478
      Fam Zheng 提交于
      An aio_notify() pairs with an aio_notify_accept(). The former should
      happen in the main thread or a vCPU thread, and the latter should be
      done in the IOThread.
      
      There is one rare case that the main thread or vCPU thread may "steal"
      the aio_notify() event just raised by itself, in bdrv_set_aio_context()
      [1]. The sequence is like this:
      
          main thread                     IO Thread
          ===============================================================
          bdrv_drained_begin()
            aio_disable_external(ctx)
                                          aio_poll(ctx, true)
                                            ctx->notify_me += 2
          ...
          bdrv_drained_end()
            ...
              aio_notify()
          ...
          bdrv_set_aio_context()
            aio_poll(ctx, false)
      [1]     aio_notify_accept(ctx)
                                            ppoll() /* Hang! */
      
      [1] is problematic. It will clear the ctx->notifier event so that
      the blocked ppoll() will not return.
      
      (For the curious, this bug was noticed when booting a number of VMs
      simultaneously in RHV.  One or two of the VMs will hit this race
      condition, making the VIRTIO device unresponsive to I/O commands. When
      it hangs, Seabios is busy waiting for a read request to complete (read
      MBR), right after initializing the virtio-blk-pci device, using 100%
      guest CPU. See also https://bugzilla.redhat.com/show_bug.cgi?id=1562750
      for the original bug analysis.)
      
      aio_notify() only injects an event when ctx->notify_me is set,
      correspondingly aio_notify_accept() is only useful when ctx->notify_me
      _was_ set. Move the call to it into the "blocking" branch. This will
      effectively skip [1] and fix the hang.
      
      Furthermore, blocking aio_poll is only allowed on home thread
      (in_aio_context_home_thread), because otherwise two blocking
      aio_poll()'s can steal each other's ctx->notifier event and cause
      hanging just like described above.
      
      Cc: qemu-stable@nongnu.org
      Suggested-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Message-Id: <20180809132259.18402-3-famz@redhat.com>
      Signed-off-by: NFam Zheng <famz@redhat.com>
      (cherry picked from commit b37548fc)
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      8f0e1478
    • F
      aio-posix: Don't count ctx->notifier as progress when polling · 98f6f212
      Fam Zheng 提交于
      The same logic exists in fd polling. This change is especially important
      to avoid busy loop once we limit aio_notify_accept() to blocking
      aio_poll().
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Message-Id: <20180809132259.18402-2-famz@redhat.com>
      Signed-off-by: NFam Zheng <famz@redhat.com>
      (cherry picked from commit 70232b52)
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      98f6f212