DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH v2] virtio: fix buffer leak on vlan insert
Date: Fri,  5 Apr 2019 09:31:15 -0700	[thread overview]
Message-ID: <20190405163115.5068-1-stephen@networkplumber.org> (raw)
Message-ID: <20190405163115.qCYFrftenroZxqX2_fz6l26m_HByzvvJMmTzbSTZ10w@z> (raw)
In-Reply-To: <20190405000343.24424-1-stephen@networkplumber.org>

The function rte_vlan_insert may allocate a new buffer for the
vlan header and return a different mbuf than originally passed.
In this case, the stored mbuf in txm[] array could point to wrong
buffer.

Fixes: dd856dfcb9e7 ("virtio: use any layout on Tx")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2 - catch a couple more places.
     The virtio code needs some refactoring to not have 3 copies of same
     loop...

 drivers/net/virtio/virtio_rxtx.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index e6f3706d6fe1..8c56f238f965 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -2003,6 +2003,8 @@ virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts,
 				rte_pktmbuf_free(txm);
 				continue;
 			}
+			/* vlan_insert may add a header mbuf */
+			tx_pkts[nb_tx] = txm;
 		}
 
 		/* optimize ring usage */
@@ -2090,6 +2092,8 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 				rte_pktmbuf_free(txm);
 				continue;
 			}
+			/* vlan_insert may add a header mbuf */
+			tx_pkts[nb_tx] = txm;
 		}
 
 		/* optimize ring usage */
@@ -2193,6 +2197,8 @@ virtio_xmit_pkts_inorder(void *tx_queue,
 				rte_pktmbuf_free(txm);
 				continue;
 			}
+			/* vlan_insert may add a header mbuf */
+			tx_pkts[nb_tx] = txm;
 		}
 
 		/* optimize ring usage */
-- 
2.17.1


  parent reply	other threads:[~2019-04-05 16:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-05  0:03 [dpdk-dev] [PATCH] " Stephen Hemminger
2019-04-05  0:03 ` Stephen Hemminger
2019-04-05  7:43 ` Jens Freimann
2019-04-05  7:43   ` Jens Freimann
2019-04-05 16:31 ` Stephen Hemminger [this message]
2019-04-05 16:31   ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
2019-04-08  9:21   ` Jens Freimann
2019-04-08  9:21     ` Jens Freimann
2019-04-17  7:16   ` Maxime Coquelin
2019-04-17  7:16     ` Maxime Coquelin
2019-04-17  7:56   ` Maxime Coquelin
2019-04-17  7:56     ` Maxime Coquelin

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=20190405163115.5068-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.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).