DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] virtio: fix buffer leak on vlan insert
@ 2019-04-05  0:03 Stephen Hemminger
  2019-04-05  0:03 ` Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Stephen Hemminger @ 2019-04-05  0:03 UTC (permalink / raw)
  To: maxime.coquelin; +Cc: dev, stable, Stephen Hemminger

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>
---
 drivers/net/virtio/virtio_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index e6f3706d6fe1..2ae4232c181d 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 */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH] virtio: fix buffer leak on vlan insert
  2019-04-05  0:03 [dpdk-dev] [PATCH] virtio: fix buffer leak on vlan insert Stephen Hemminger
@ 2019-04-05  0:03 ` Stephen Hemminger
  2019-04-05  7:43 ` Jens Freimann
  2019-04-05 16:31 ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
  2 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2019-04-05  0:03 UTC (permalink / raw)
  To: maxime.coquelin; +Cc: dev, stable, Stephen Hemminger

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>
---
 drivers/net/virtio/virtio_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index e6f3706d6fe1..2ae4232c181d 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 */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH] virtio: fix buffer leak on vlan insert
  2019-04-05  0:03 [dpdk-dev] [PATCH] virtio: fix buffer leak on vlan insert 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 ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
  2 siblings, 1 reply; 12+ messages in thread
From: Jens Freimann @ 2019-04-05  7:43 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: maxime.coquelin, dev, stable

On Thu, Apr 04, 2019 at 05:03:43PM -0700, Stephen Hemminger wrote:
>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>
>---
> drivers/net/virtio/virtio_rxtx.c | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
>index e6f3706d6fe1..2ae4232c181d 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 */

Good catch. I think we have the same bug in virtio_xmit_pkts() and
virtio_xmit_pkts_inorder() and should fix these as well. 


Thanks!

regards,
Jens 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH] virtio: fix buffer leak on vlan insert
  2019-04-05  7:43 ` Jens Freimann
@ 2019-04-05  7:43   ` Jens Freimann
  0 siblings, 0 replies; 12+ messages in thread
From: Jens Freimann @ 2019-04-05  7:43 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: maxime.coquelin, dev, stable

On Thu, Apr 04, 2019 at 05:03:43PM -0700, Stephen Hemminger wrote:
>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>
>---
> drivers/net/virtio/virtio_rxtx.c | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
>index e6f3706d6fe1..2ae4232c181d 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 */

Good catch. I think we have the same bug in virtio_xmit_pkts() and
virtio_xmit_pkts_inorder() and should fix these as well. 


Thanks!

regards,
Jens 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH v2] virtio: fix buffer leak on vlan insert
  2019-04-05  0:03 [dpdk-dev] [PATCH] virtio: fix buffer leak on vlan insert Stephen Hemminger
  2019-04-05  0:03 ` Stephen Hemminger
  2019-04-05  7:43 ` Jens Freimann
@ 2019-04-05 16:31 ` Stephen Hemminger
  2019-04-05 16:31   ` Stephen Hemminger
                     ` (3 more replies)
  2 siblings, 4 replies; 12+ messages in thread
From: Stephen Hemminger @ 2019-04-05 16:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH v2] virtio: fix buffer leak on vlan insert
  2019-04-05 16:31 ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
@ 2019-04-05 16:31   ` Stephen Hemminger
  2019-04-08  9:21   ` Jens Freimann
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2019-04-05 16:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v2] virtio: fix buffer leak on vlan insert
  2019-04-05 16:31 ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
  2019-04-05 16:31   ` 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:56   ` Maxime Coquelin
  3 siblings, 1 reply; 12+ messages in thread
From: Jens Freimann @ 2019-04-08  9:21 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, stable, maxime.coquelin

On Fri, Apr 05, 2019 at 09:31:15AM -0700, Stephen Hemminger wrote:
>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(+)
>

Added stable@ back to Cc list as it was for v1. 

Reviewed-by: Jens Freimann <jfreimann@redhat.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v2] virtio: fix buffer leak on vlan insert
  2019-04-08  9:21   ` Jens Freimann
@ 2019-04-08  9:21     ` Jens Freimann
  0 siblings, 0 replies; 12+ messages in thread
From: Jens Freimann @ 2019-04-08  9:21 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, stable, maxime.coquelin

On Fri, Apr 05, 2019 at 09:31:15AM -0700, Stephen Hemminger wrote:
>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(+)
>

Added stable@ back to Cc list as it was for v1. 

Reviewed-by: Jens Freimann <jfreimann@redhat.com>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v2] virtio: fix buffer leak on vlan insert
  2019-04-05 16:31 ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
  2019-04-05 16:31   ` Stephen Hemminger
  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
  3 siblings, 1 reply; 12+ messages in thread
From: Maxime Coquelin @ 2019-04-17  7:16 UTC (permalink / raw)
  To: Stephen Hemminger, dev



On 4/5/19 6:31 PM, Stephen Hemminger wrote:
> 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(+)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v2] virtio: fix buffer leak on vlan insert
  2019-04-17  7:16   ` Maxime Coquelin
@ 2019-04-17  7:16     ` Maxime Coquelin
  0 siblings, 0 replies; 12+ messages in thread
From: Maxime Coquelin @ 2019-04-17  7:16 UTC (permalink / raw)
  To: Stephen Hemminger, dev



On 4/5/19 6:31 PM, Stephen Hemminger wrote:
> 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(+)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v2] virtio: fix buffer leak on vlan insert
  2019-04-05 16:31 ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
                     ` (2 preceding siblings ...)
  2019-04-17  7:16   ` Maxime Coquelin
@ 2019-04-17  7:56   ` Maxime Coquelin
  2019-04-17  7:56     ` Maxime Coquelin
  3 siblings, 1 reply; 12+ messages in thread
From: Maxime Coquelin @ 2019-04-17  7:56 UTC (permalink / raw)
  To: Stephen Hemminger, dev



On 4/5/19 6:31 PM, Stephen Hemminger wrote:
> 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(+)
> 

Applied to dpdk-next-virtio/master.

Note that I fixed the commit title so that it passes check-git-log
script.

Thanks,
Maxime

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v2] virtio: fix buffer leak on vlan insert
  2019-04-17  7:56   ` Maxime Coquelin
@ 2019-04-17  7:56     ` Maxime Coquelin
  0 siblings, 0 replies; 12+ messages in thread
From: Maxime Coquelin @ 2019-04-17  7:56 UTC (permalink / raw)
  To: Stephen Hemminger, dev



On 4/5/19 6:31 PM, Stephen Hemminger wrote:
> 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(+)
> 

Applied to dpdk-next-virtio/master.

Note that I fixed the commit title so that it passes check-git-log
script.

Thanks,
Maxime

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-04-17  7:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-05  0:03 [dpdk-dev] [PATCH] virtio: fix buffer leak on vlan insert 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 ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
2019-04-05 16:31   ` 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

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).