All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: Adam Litke <agl@us.ibm.com>
Cc: abeekhof@redhat.com, agl@linux.vnet.ibm.com,
	qemu-devel@nongnu.org, aliguori@linux.vnet.ibm.com
Subject: [Qemu-devel] Re: [RFC][RESEND][PATCH v1 09/15] virtproxy: add handler for data packets
Date: Thu, 04 Nov 2010 13:23:51 -0500	[thread overview]
Message-ID: <4CD2FA37.3090706@linux.vnet.ibm.com> (raw)
In-Reply-To: <1288831578.2846.83.camel@aglitke>

On 11/03/2010 07:46 PM, Adam Litke wrote:
> On Wed, 2010-11-03 at 10:28 -0500, Michael Roth wrote:
>> Process VPPackets coming in from channel and send them to the
>> appropriate server/client connections.
>>
>> Signed-off-by: Michael Roth<mdroth@linux.vnet.ibm.com>
>> ---
>>   virtproxy.c |   42 ++++++++++++++++++++++++++++++++++++++++++
>>   1 files changed, 42 insertions(+), 0 deletions(-)
>>
>> diff --git a/virtproxy.c b/virtproxy.c
>> index 6c3611b..57ab2b0 100644
>> --- a/virtproxy.c
>> +++ b/virtproxy.c
>> @@ -235,6 +235,48 @@ static void vp_channel_accept(void *opaque)
>>       vp_set_fd_handler(drv->listen_fd, NULL, NULL, NULL);
>>   }
>>
>> +/* handle data packets
>> + *
>> + * process VPPackets containing data and send them to the corresponding
>> + * FDs
>> + */
>> +static int vp_handle_data_packet(void *drv, const VPPacket *pkt)
>> +{
>> +    int fd, ret;
>> +
>> +    TRACE("called with drv: %p", drv);
>> +
>> +    if (pkt->type == VP_PKT_CLIENT) {
>> +        TRACE("recieved client packet, client fd: %d, server fd: %d",
>> +              pkt->payload.proxied.client_fd, pkt->payload.proxied.server_fd);
>> +        fd = pkt->payload.proxied.server_fd;
>> +    } else if (pkt->type == VP_PKT_SERVER) {
>> +        TRACE("recieved server packet, client fd: %d, server fd: %d",
>> +              pkt->payload.proxied.client_fd, pkt->payload.proxied.server_fd);
>> +        fd = pkt->payload.proxied.client_fd;
>> +    } else {
>> +        TRACE("unknown packet type");
>> +        return -1;
>> +    }
>> +
>> +    /* TODO: proxied in non-blocking mode can causes us to spin here
>> +     * for slow servers/clients. need to use write()'s and maintain
>> +     * a per-conn write queue that we clear out before sending any
>> +     * more data to the fd
>> +     */
>
> Hmm, so a guest can cause a denial of service in the host qemu process?
> Are you working on adding the write queues?
>

Not a guest...though they could DoS the agent in this manner. But there 
seems to be an analogous situation in qemu currently, where a malicious 
client connects to, say, a socket setup to listen for telnet connections 
to the qemu monitor, sends a bunch of info commands, and doesn't read 
anything coming back to it. That might eventually cause the qemu process 
to hang when a monitor_flush->qemu_chr_write->send_all(client_fd) 
happens. A malicious client connecting to a forwarding port/socket on 
the host side could cause a similiar situation.

So if it's a problem, it seems like a problem that should be addressed 
more generally. A general, asynchronous implementation of send_all for 
instance.

>> +    ret = vp_send_all(fd, (void *)pkt->payload.proxied.data,
>> +            pkt->payload.proxied.bytes);
>> +    if (ret == -1) {
>> +        LOG("error sending data over channel");
>> +        return -1;
>> +    } else if (ret != pkt->payload.proxied.bytes) {
>> +        TRACE("buffer full?");
>
> This can happen?  Does this bring the whole connection down?  The whole
> virtproxy instance?
>

It can if write() returns 0, so only if we do a non-blocking write() 
inside vp_send_all/send_all. It's basically a TODO...since right now the 
writes are blocking ones, so it shouldn't happen. If we used 
non-blocking writes though we'd need to call vp_send_all(fd, (void 
*)pkt->payload.proxied.data + ret, pkt->payload.proxied.bytes - ret) in 
a loop, it wouldn't be an error case. I'll clean this up a bit.

  reply	other threads:[~2010-11-04 18:23 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-03 15:27 [Qemu-devel] [RFC][RESEND][PATCH v1 00/15] virtproxy: host/guest communication layer Michael Roth
2010-11-03 15:27 ` [Qemu-devel] [RFC][RESEND][PATCH v1 01/15] virtproxy: base data structures and constants Michael Roth
2010-11-03 22:33   ` [Qemu-devel] " Adam Litke
2010-11-03 15:27 ` [Qemu-devel] [RFC][RESEND][PATCH v1 02/15] virtproxy: qemu-vp, standalone daemon skeleton Michael Roth
2010-11-03 22:47   ` [Qemu-devel] " Adam Litke
2010-11-04 13:57     ` Michael Roth
2010-11-05 13:32       ` Adam Litke
2010-11-09 10:45         ` Amit Shah
2010-11-10  2:51           ` Michael Roth
2010-11-03 15:27 ` [Qemu-devel] [RFC][RESEND][PATCH v1 03/15] virtproxy: add debug functions for virtproxy core Michael Roth
2010-11-03 22:51   ` [Qemu-devel] " Adam Litke
2010-11-03 15:27 ` [Qemu-devel] [RFC][RESEND][PATCH v1 04/15] virtproxy: list look-up functions conns/oforwards/iforwards Michael Roth
2010-11-03 22:56   ` [Qemu-devel] " Adam Litke
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 05/15] virtproxy: add accept handler for communication channel Michael Roth
2010-11-03 23:02   ` [Qemu-devel] " Adam Litke
2010-11-04 16:17     ` Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 06/15] virtproxy: add read " Michael Roth
2010-11-03 23:38   ` [Qemu-devel] " Adam Litke
2010-11-04 17:00     ` Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 07/15] virtproxy: add vp_new() VPDriver constructor Michael Roth
2010-11-03 23:45   ` [Qemu-devel] " Adam Litke
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 08/15] virtproxy: interfaces to set/remove/handle VPOForwards Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 09/15] virtproxy: add handler for data packets Michael Roth
2010-11-04  0:46   ` [Qemu-devel] " Adam Litke
2010-11-04 18:23     ` Michael Roth [this message]
2010-11-04  1:48   ` Adam Litke
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 10/15] virtproxy: add handler for control packet Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 11/15] virtproxy: add vp_handle_packet() Michael Roth
2010-11-04  1:13   ` [Qemu-devel] " Adam Litke
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 12/15] virtproxy: interfaces to set/remove VPIForwards Michael Roth
2010-11-04  1:12   ` [Qemu-devel] " Adam Litke
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 13/15] virtproxy: add read handler for proxied connections Michael Roth
2010-11-04  1:21   ` [Qemu-devel] " Adam Litke
2010-11-04 18:26     ` Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 14/15] virtproxy: Makefile/configure changes to build qemu-vp Michael Roth
2010-11-03 15:28 ` [Qemu-devel] [RFC][RESEND][PATCH v1 15/15] virtproxy: qemu-vp, main logic Michael Roth
2010-11-03 23:44 ` [Qemu-devel] Re: [RFC][RESEND][PATCH v1 00/15] virtproxy: host/guest communication layer Adam Litke
2010-11-04 18:46   ` Michael Roth

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=4CD2FA37.3090706@linux.vnet.ibm.com \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=abeekhof@redhat.com \
    --cc=agl@linux.vnet.ibm.com \
    --cc=agl@us.ibm.com \
    --cc=aliguori@linux.vnet.ibm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.