[v2] ethdev: limit maximum number of queues

Message ID 20191127143121.10590-1-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Headers
Series [v2] ethdev: limit maximum number of queues |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed

Commit Message

Thomas Monjalon Nov. 27, 2019, 2:31 p.m. UTC
  A buffer overflow happens in testpmd with some drivers
since the queue arrays are limited to RTE_MAX_QUEUES_PER_PORT.

The advertised capabilities of mlx4, mlx5 and softnic
for the number of queues were the maximum number: UINT16_MAX.
They must be limited by the configured RTE_MAX_QUEUES_PER_PORT
that applications expect to be respected.

The limitation is applied at ethdev level (function rte_eth_dev_info_get),
in order to force the configured limit for all drivers.

Fixes: 14b53e27b30e ("ethdev: fix crash with multiprocess")
Cc: stable@dpdk.org

Reported-by: Raslan Darawsheh <rasland@mellanox.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
v2: remove changes in drivers, keep limit only in ethdev
---
 lib/librte_ethdev/rte_ethdev.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

David Marchand Nov. 27, 2019, 2:47 p.m. UTC | #1
On Wed, Nov 27, 2019 at 3:31 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> A buffer overflow happens in testpmd with some drivers
> since the queue arrays are limited to RTE_MAX_QUEUES_PER_PORT.
>
> The advertised capabilities of mlx4, mlx5 and softnic
> for the number of queues were the maximum number: UINT16_MAX.
> They must be limited by the configured RTE_MAX_QUEUES_PER_PORT
> that applications expect to be respected.
>
> The limitation is applied at ethdev level (function rte_eth_dev_info_get),
> in order to force the configured limit for all drivers.
>
> Fixes: 14b53e27b30e ("ethdev: fix crash with multiprocess")
> Cc: stable@dpdk.org
>
> Reported-by: Raslan Darawsheh <rasland@mellanox.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Reviewed-by: David Marchand <david.marchand@redhat.com>
  
Thomas Monjalon Nov. 27, 2019, 3:09 p.m. UTC | #2
27/11/2019 15:47, David Marchand:
> On Wed, Nov 27, 2019 at 3:31 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> >
> > A buffer overflow happens in testpmd with some drivers
> > since the queue arrays are limited to RTE_MAX_QUEUES_PER_PORT.
> >
> > The advertised capabilities of mlx4, mlx5 and softnic
> > for the number of queues were the maximum number: UINT16_MAX.
> > They must be limited by the configured RTE_MAX_QUEUES_PER_PORT
> > that applications expect to be respected.
> >
> > The limitation is applied at ethdev level (function rte_eth_dev_info_get),
> > in order to force the configured limit for all drivers.
> >
> > Fixes: 14b53e27b30e ("ethdev: fix crash with multiprocess")
> > Cc: stable@dpdk.org
> >
> > Reported-by: Raslan Darawsheh <rasland@mellanox.com>
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
> 
> Reviewed-by: David Marchand <david.marchand@redhat.com>

Applied
  

Patch

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 8d2ce31a81..6e9cb243ea 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -2986,6 +2986,12 @@  rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
 		return eth_err(port_id, diag);
 	}
 
+	/* Maximum number of queues should be <= RTE_MAX_QUEUES_PER_PORT */
+	dev_info->max_rx_queues = RTE_MIN(dev_info->max_rx_queues,
+			RTE_MAX_QUEUES_PER_PORT);
+	dev_info->max_tx_queues = RTE_MIN(dev_info->max_tx_queues,
+			RTE_MAX_QUEUES_PER_PORT);
+
 	dev_info->driver_name = dev->device->driver->name;
 	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
 	dev_info->nb_tx_queues = dev->data->nb_tx_queues;