net/virtio: fix buffer leak on VLAN insert
authorStephen Hemminger <stephen@networkplumber.org>
Fri, 5 Apr 2019 16:31:15 +0000 (09:31 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 19 Apr 2019 12:51:54 +0000 (14:51 +0200)
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")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Jens Freimann <jfreimann@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/virtio/virtio_rxtx.c

index e6f3706..8c56f23 100644 (file)
@@ -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 */