qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Anthony Liguori <aliguori@amazon.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PULL 26/29] qemu-char: fix tcp_get_fds
Date: Mon, 3 Nov 2014 14:46:08 +0200	[thread overview]
Message-ID: <1415018633-16041-27-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1415018633-16041-1-git-send-email-mst@redhat.com>

tcp_get_fds API discards fds if there's more than 1 of these.

It's tricky to fix this without API changes in the generic case.

However, this API is only used by tests ATM, and tests know how
many fds they expect.

So let's not waste cycles trying to fix this properly:
simply assume at most 16 fds (tests use at most 8 now).
assert if some test tries to get more.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 qemu-char.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/qemu-char.c b/qemu-char.c
index bd0709b..1c4004c 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -88,6 +88,7 @@
 #define READ_BUF_LEN 4096
 #define READ_RETRIES 10
 #define CHR_MAX_FILENAME_SIZE 256
+#define TCP_MAX_FDS 16
 
 /***********************************************************/
 /* Socket address helpers */
@@ -2668,6 +2669,8 @@ static int tcp_get_msgfds(CharDriverState *chr, int *fds, int num)
     TCPCharDriver *s = chr->opaque;
     int to_copy = (s->read_msgfds_num < num) ? s->read_msgfds_num : num;
 
+    assert(num <= TCP_MAX_FDS);
+
     if (to_copy) {
         int i;
 
@@ -2762,7 +2765,7 @@ static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len)
     struct iovec iov[1];
     union {
         struct cmsghdr cmsg;
-        char control[CMSG_SPACE(sizeof(int))];
+        char control[CMSG_SPACE(sizeof(int) * TCP_MAX_FDS)];
     } msg_control;
     int flags = 0;
     ssize_t ret;
-- 
MST

  parent reply	other threads:[~2014-11-03 12:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-03 12:44 [Qemu-devel] [PULL 00/29] pc, virtio, misc bugfixes Michael S. Tsirkin
2014-11-03 12:44 ` [Qemu-devel] [PULL 01/29] smbios: Fix assertion on socket count calculation Michael S. Tsirkin
2014-11-03 12:44 ` [Qemu-devel] [PULL 02/29] well-defined listing order for machine types Michael S. Tsirkin
2014-11-03 12:44 ` [Qemu-devel] [PULL 03/29] i386/pc: add piix and q35 machtypes to sorting families for -M \? Michael S. Tsirkin
2014-11-03 12:44 ` [Qemu-devel] [PULL 04/29] pc: Fix disabling of vapic for compat PC models Michael S. Tsirkin
2014-11-03 12:44 ` [Qemu-devel] [PULL 05/29] i386: Add an ACPI_EXTRACT_NAME_BUFFER16 directive Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 06/29] pcie: change confused comment clearer Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 07/29] virtio-pci: fix migration for pci bus master Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 08/29] intel_iommu: fix VTD_SID_TO_BUS Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 09/29] tests: fix rebuild-expected-aml.sh for acpi-test rename Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 10/29] acpi: create separate file for TCPA log Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 11/29] acpi/cpu: add cpu hotplug callback function to match hotplug_handler API Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 12/29] acpi:ich9: convert cpu hotplug to " Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 13/29] acpi:piix4: " Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 14/29] pc: add cpu hotplug handler to PC_MACHINE Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 15/29] pc: Update rtc_cmos in pc_cpu_plug Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 16/29] qom/cpu: remove the unused CPU hot-plug notifier Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 17/29] cpu-hotplug: rename function for better readability Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 18/29] acpi/cpu-hotplug: introduce helper function to keep bit setting in one place Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 19/29] -machine vmport=off: Allow disabling of VMWare ioport emulation Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 20/29] hw/pci: fixed error flow in pci_qdev_init Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 21/29] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 22/29] hw/virtio/vring/event_idx: fix the vring_avail_event error Michael S. Tsirkin
2014-11-03 12:45 ` [Qemu-devel] [PULL 23/29] pc: Add pc_compat_2_1() function Michael S. Tsirkin
2014-11-03 12:46 ` [Qemu-devel] [PULL 24/29] smbios: Encode UUID according to SMBIOS specification Michael S. Tsirkin
2014-11-03 12:46 ` [Qemu-devel] [PULL 25/29] hw/i386/acpi-build.c: Fix memory leak in acpi_build_tables_cleanup() Michael S. Tsirkin
2014-11-03 12:46 ` Michael S. Tsirkin [this message]
2014-11-03 12:46 ` [Qemu-devel] [PULL 27/29] vhost-user: fix mmap offset calculation Michael S. Tsirkin
2014-11-03 12:46 ` [Qemu-devel] [PULL 28/29] vga: add default display to machine class Michael S. Tsirkin
2014-11-03 12:46 ` [Qemu-devel] [PULL 29/29] vga: flip qemu 2.2 pc machine types from cirrus to stdvga Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415018633-16041-27-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).