From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: [PATCH RFC 3/4] virtio_net: stricter short buffer length checks
Date: Fri, 24 Oct 2014 00:28:05 +0300 [thread overview]
Message-ID: <1414099656-28090-3-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1414099656-28090-2-git-send-email-mst@redhat.com>
Our buffer length check is not strict enough for mergeable
buffers: buffer can still be shorter that header + address
by 2 bytes.
Fix that up.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/net/virtio_net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index a795a23..9c6d50f 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -437,7 +437,7 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
struct sk_buff *skb;
struct virtio_net_hdr_mrg_rxbuf *hdr;
- if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) {
+ if (unlikely(len < vi->hdr_len + ETH_HLEN)) {
pr_debug("%s: short packet %i\n", dev->name, len);
dev->stats.rx_length_errors++;
if (vi->mergeable_rx_bufs) {
--
MST
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: cornelia.huck@de.ibm.com, Rusty Russell <rusty@rustcorp.com.au>,
virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org
Subject: [PATCH RFC 3/4] virtio_net: stricter short buffer length checks
Date: Fri, 24 Oct 2014 00:28:05 +0300 [thread overview]
Message-ID: <1414099656-28090-3-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1414099656-28090-2-git-send-email-mst@redhat.com>
Our buffer length check is not strict enough for mergeable
buffers: buffer can still be shorter that header + address
by 2 bytes.
Fix that up.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/net/virtio_net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index a795a23..9c6d50f 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -437,7 +437,7 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
struct sk_buff *skb;
struct virtio_net_hdr_mrg_rxbuf *hdr;
- if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) {
+ if (unlikely(len < vi->hdr_len + ETH_HLEN)) {
pr_debug("%s: short packet %i\n", dev->name, len);
dev->stats.rx_length_errors++;
if (vi->mergeable_rx_bufs) {
--
MST
next prev parent reply other threads:[~2014-10-23 21:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-23 21:27 [PATCH RFC 1/4] virtio_net: pass vi around Michael S. Tsirkin
2014-10-23 21:27 ` Michael S. Tsirkin
2014-10-23 21:28 ` [PATCH RFC 2/4] virtio_net: get rid of virtio_net_hdr/skb_vnet_hdr Michael S. Tsirkin
2014-10-23 21:28 ` Michael S. Tsirkin
2014-10-23 21:28 ` Michael S. Tsirkin [this message]
2014-10-23 21:28 ` [PATCH RFC 3/4] virtio_net: stricter short buffer length checks Michael S. Tsirkin
2014-10-23 21:28 ` [PATCH RFC 4/4] virtio_net: bigger header when VERSION_1 is set Michael S. Tsirkin
2014-10-23 21:28 ` Michael S. Tsirkin
2014-10-28 0:28 ` Rusty Russell
2014-10-28 0:28 ` Rusty Russell
2014-10-28 0:27 ` [PATCH RFC 2/4] virtio_net: get rid of virtio_net_hdr/skb_vnet_hdr Rusty Russell
2014-10-28 0:27 ` Rusty Russell
2014-10-24 10:02 ` [PATCH RFC 1/4] virtio_net: pass vi around David Laight
2014-10-24 10:02 ` David Laight
2014-10-24 14:10 ` Michael S. Tsirkin
2014-10-24 14:10 ` Michael S. Tsirkin
2014-10-28 0:27 ` Rusty Russell
2014-10-28 0:27 ` Rusty Russell
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=1414099656-28090-3-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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.