From: Stefan Hajnoczi <stefanha@gmail.com>
To: Thomas Huth <thuth@redhat.com>
Cc: "Michael S. Tsirkin" <mtsirkin@redhat.com>,
Huzaifa Sidhpurwala <huzaifas@redhat.com>,
P J P <pjp@fedoraproject.org>, Jason Wang <jasowang@redhat.com>,
qemu-stable@nongnu.org, qemu-devel@nongnu.org,
Stefan Hajnoczi <stefanha@redhat.com>, P J P <ppandit@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] e1000: Avoid infinite loop in processing transmit descriptor
Date: Wed, 9 Sep 2015 10:10:07 +0100 [thread overview]
Message-ID: <20150909091007.GA9777@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <55ED532F.2090905@redhat.com>
On Mon, Sep 07, 2015 at 11:04:47AM +0200, Thomas Huth wrote:
> On 04/09/15 18:21, Stefan Hajnoczi wrote:
> > From: P J P <pjp@fedoraproject.org>
> >
> > While processing transmit descriptors, it could lead to an infinite
> > loop if 'bytes' was to become zero; Add a check to avoid it.
> >
> > [The guest can force 'bytes' to 0 by setting the hdr_len and mss
> > descriptor fields to 0.
> > --Stefan]
>
> I wonder whether we should log an LOG_GUEST_ERROR in that case since
> this sounds like a problem in the guest ... ?
e1000.c seems to use DBGOUT(TXERR, ...) but doesn't do any
rate-limiting, which can pose a problem if a malicious guest keeps
triggering a warning message to fill up the disk on the host :(.
> > diff --git a/hw/net/e1000.c b/hw/net/e1000.c
> > index 5c6bcd0..09c9e9d 100644
> > --- a/hw/net/e1000.c
> > +++ b/hw/net/e1000.c
> > @@ -740,7 +740,8 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
> > memmove(tp->data, tp->header, tp->hdr_len);
> > tp->size = tp->hdr_len;
> > }
> > - } while (split_size -= bytes);
> > + split_size -= bytes;
> > + } while (bytes && split_size);
> > } else if (!tp->tse && tp->cptse) {
> > // context descriptor TSE is not set, while data descriptor TSE is set
> > DBGOUT(TXERR, "TCP segmentation error\n");
>
> Looks sane ... (but IMHO code would be more readable though if it would
> break out of the loop already earlier, as soon as it is clear that
> bytes == 0, so that e.g. the pci_dma_read(..., 0) is not called at all).
I agree. P J P probably chose this approach because it is the smallest
change. I'm happy enough as-is and you've posted your Reviewed-by too
so let's leave it.
next prev parent reply other threads:[~2015-09-09 9:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-04 16:21 [Qemu-devel] [PATCH] e1000: Avoid infinite loop in processing transmit descriptor Stefan Hajnoczi
2015-09-07 9:04 ` Thomas Huth
2015-09-09 9:10 ` Stefan Hajnoczi [this message]
2015-09-09 9:10 ` Stefan Hajnoczi
2015-09-09 9:49 ` pjp
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=20150909091007.GA9777@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--cc=huzaifas@redhat.com \
--cc=jasowang@redhat.com \
--cc=mtsirkin@redhat.com \
--cc=pjp@fedoraproject.org \
--cc=ppandit@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
/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).