DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/virtio: fix incorrect cast of void *
@ 2017-12-14 14:33 Olivier Matz
  2017-12-14 14:49 ` Maxime Coquelin
  0 siblings, 1 reply; 3+ messages in thread
From: Olivier Matz @ 2017-12-14 14:33 UTC (permalink / raw)
  To: dev, Yuanhan Liu, Maxime Coquelin; +Cc: Didier Pallard, stable

From: Didier Pallard <didier.pallard@6wind.com>

The rx_queues and tx_queues fields of the data structure points to a struct
virtnet_rx or virtnet_tx. Casting it to a virtqueue is an error.

It does not trigger any bug because pointer is not dereferenced inside the
function, but it can become a bug if this code is copy/pasted and vq is
dereferenced.

Fixes: 01ad44fd374f ("net/virtio: split Rx/Tx queue")
Cc: stable@dpdk.org

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/virtio/virtio_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index c0ba83b06..b398f9960 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -893,7 +893,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 		/* Note: limit checked in rte_eth_xstats_names() */
 
 		for (i = 0; i < dev->data->nb_rx_queues; i++) {
-			struct virtqueue *rxvq = dev->data->rx_queues[i];
+			struct virtnet_rx *rxvq = dev->data->rx_queues[i];
 			if (rxvq == NULL)
 				continue;
 			for (t = 0; t < VIRTIO_NB_RXQ_XSTATS; t++) {
@@ -906,7 +906,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 		}
 
 		for (i = 0; i < dev->data->nb_tx_queues; i++) {
-			struct virtqueue *txvq = dev->data->tx_queues[i];
+			struct virtnet_tx *txvq = dev->data->tx_queues[i];
 			if (txvq == NULL)
 				continue;
 			for (t = 0; t < VIRTIO_NB_TXQ_XSTATS; t++) {
-- 
2.11.0

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

* Re: [dpdk-dev] [PATCH] net/virtio: fix incorrect cast of void *
  2017-12-14 14:33 [dpdk-dev] [PATCH] net/virtio: fix incorrect cast of void * Olivier Matz
@ 2017-12-14 14:49 ` Maxime Coquelin
  2017-12-27 14:38   ` Yuanhan Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Maxime Coquelin @ 2017-12-14 14:49 UTC (permalink / raw)
  To: Olivier Matz, dev, Yuanhan Liu; +Cc: Didier Pallard, stable



On 12/14/2017 03:33 PM, Olivier Matz wrote:
> From: Didier Pallard <didier.pallard@6wind.com>
> 
> The rx_queues and tx_queues fields of the data structure points to a struct
> virtnet_rx or virtnet_tx. Casting it to a virtqueue is an error.
> 
> It does not trigger any bug because pointer is not dereferenced inside the
> function, but it can become a bug if this code is copy/pasted and vq is
> dereferenced.
> 
> Fixes: 01ad44fd374f ("net/virtio: split Rx/Tx queue")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> ---
>   drivers/net/virtio/virtio_ethdev.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index c0ba83b06..b398f9960 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -893,7 +893,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
>   		/* Note: limit checked in rte_eth_xstats_names() */
>   
>   		for (i = 0; i < dev->data->nb_rx_queues; i++) {
> -			struct virtqueue *rxvq = dev->data->rx_queues[i];
> +			struct virtnet_rx *rxvq = dev->data->rx_queues[i];
>   			if (rxvq == NULL)
>   				continue;
>   			for (t = 0; t < VIRTIO_NB_RXQ_XSTATS; t++) {
> @@ -906,7 +906,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
>   		}
>   
>   		for (i = 0; i < dev->data->nb_tx_queues; i++) {
> -			struct virtqueue *txvq = dev->data->tx_queues[i];
> +			struct virtnet_tx *txvq = dev->data->tx_queues[i];
>   			if (txvq == NULL)
>   				continue;
>   			for (t = 0; t < VIRTIO_NB_TXQ_XSTATS; t++) {
> 

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

Thanks,
Maxime

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

* Re: [dpdk-dev] [PATCH] net/virtio: fix incorrect cast of void *
  2017-12-14 14:49 ` Maxime Coquelin
@ 2017-12-27 14:38   ` Yuanhan Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Yuanhan Liu @ 2017-12-27 14:38 UTC (permalink / raw)
  To: Maxime Coquelin; +Cc: Olivier Matz, dev, Didier Pallard, stable

On Thu, Dec 14, 2017 at 03:49:32PM +0100, Maxime Coquelin wrote:
> 
> 
> On 12/14/2017 03:33 PM, Olivier Matz wrote:
> >From: Didier Pallard <didier.pallard@6wind.com>
> >
> >The rx_queues and tx_queues fields of the data structure points to a struct
> >virtnet_rx or virtnet_tx. Casting it to a virtqueue is an error.
> >
> >It does not trigger any bug because pointer is not dereferenced inside the
> >function, but it can become a bug if this code is copy/pasted and vq is
> >dereferenced.
> >
> >Fixes: 01ad44fd374f ("net/virtio: split Rx/Tx queue")
> >Cc: stable@dpdk.org
> >
> >Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
> >Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> >---
> >  drivers/net/virtio/virtio_ethdev.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> >diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> >index c0ba83b06..b398f9960 100644
> >--- a/drivers/net/virtio/virtio_ethdev.c
> >+++ b/drivers/net/virtio/virtio_ethdev.c
> >@@ -893,7 +893,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
> >  		/* Note: limit checked in rte_eth_xstats_names() */
> >  		for (i = 0; i < dev->data->nb_rx_queues; i++) {
> >-			struct virtqueue *rxvq = dev->data->rx_queues[i];
> >+			struct virtnet_rx *rxvq = dev->data->rx_queues[i];
> >  			if (rxvq == NULL)
> >  				continue;
> >  			for (t = 0; t < VIRTIO_NB_RXQ_XSTATS; t++) {
> >@@ -906,7 +906,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
> >  		}
> >  		for (i = 0; i < dev->data->nb_tx_queues; i++) {
> >-			struct virtqueue *txvq = dev->data->tx_queues[i];
> >+			struct virtnet_tx *txvq = dev->data->tx_queues[i];
> >  			if (txvq == NULL)
> >  				continue;
> >  			for (t = 0; t < VIRTIO_NB_TXQ_XSTATS; t++) {
> >
> 
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Applied to dpdk-next-virtio.

Thanks.

	--yliu

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

end of thread, other threads:[~2017-12-27 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-14 14:33 [dpdk-dev] [PATCH] net/virtio: fix incorrect cast of void * Olivier Matz
2017-12-14 14:49 ` Maxime Coquelin
2017-12-27 14:38   ` Yuanhan Liu

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