From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0C7A1A04E1 for ; Wed, 27 Nov 2019 14:42:38 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DC1C92BE9; Wed, 27 Nov 2019 14:42:37 +0100 (CET) Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by dpdk.org (Postfix) with ESMTP id 95C45CF3; Wed, 27 Nov 2019 14:42:34 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id CFAF370FF; Wed, 27 Nov 2019 08:42:33 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 27 Nov 2019 08:42:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=mesmtp; bh=37i+5GSjFlL2Z2fU3pFjf88 DV/LrfxlJd0kFvhKRiCA=; b=L/e5LgCbQknptuJVI8Rw12HbZWfLFINhtu12H94 e5SCOdfxKtAK45SYjKWwjRdqdTVLrEaiOQwLMv3Iy/yVfH1GDAmymVoGzYkEI5/d 7maNqk1PpXsolJFEermOk1fO+OwkVZ8IuSrqZTlmw6v84TqwRAZYSE6payJu+pDN L2Cs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=37i+5GSjFlL2Z2fU3 pFjf88DV/LrfxlJd0kFvhKRiCA=; b=ksYTDPDpCwO5dsfESfJjPG2oFks7BHbbA +4isdhDUR+p+N7tc0J4VJzj6Jp/48RYL9DQ8MZi4NTzgNAFIf+Hu8m8CkQ3ofYXd NpxFPyG7RXctks+96RhrNio/1hjwWsvXVncfLkmuC0iGAcvtWCKrODv0SEL8iK5A B+3i2Z4NrzUs6PvT/b9YnymHH9BF97DYvWU9+/cQ7OSA9JIYed/v2QqPJ0V+Tez/ mIqxnJPdCCY1U2OcQ6IU0K2KFO2Wl3InVacp8Q5/DlJ8v/vqsLqixhHBbld42FIY W6xePGJcKLBwkO4dMIfC18BwnItwz7OdgSODMilQWwhHhlSW94T6g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudeihedgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgrshcu ofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecukfhppe ejjedrudefgedrvddtfedrudekgeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhm rghssehmohhnjhgrlhhonhdrnhgvthenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 927D580061; Wed, 27 Nov 2019 08:42:31 -0500 (EST) From: Thomas Monjalon To: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Jasvinder Singh , Cristian Dumitrescu , Ferruh Yigit , Andrew Rybchenko Cc: david.marchand@redhat.com, dev@dpdk.org, stable@dpdk.org, Raslan Darawsheh Date: Wed, 27 Nov 2019 14:42:13 +0100 Message-Id: <20191127134213.9003-1-thomas@monjalon.net> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH] ethdev: limit maximum number of queues X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 in above drivers having no limitation, and at ethdev level (function rte_eth_dev_info_get), in order to force the configured limit for all drivers. Fixes: 7fae69eeff13 ("mlx4: new poll mode driver") Fixes: e60fbd5b24fc ("mlx5: add device configure/start/stop") Fixes: cc6d421574fe ("net/softnic: add softnic PMD") Fixes: 9e6b36c34ce9 ("app/testpmd: reduce memory consumption") Cc: stable@dpdk.org Reported-by: Raslan Darawsheh Signed-off-by: Thomas Monjalon --- drivers/net/mlx4/mlx4_ethdev.c | 4 +--- drivers/net/mlx5/mlx5_ethdev.c | 4 +--- drivers/net/softnic/rte_eth_softnic.c | 4 ++-- lib/librte_ethdev/rte_ethdev.c | 6 ++++++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index dfb24c22d0..a18a66cb4a 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -646,9 +646,7 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) */ max = ((priv->device_attr.max_cq > priv->device_attr.max_qp) ? priv->device_attr.max_qp : priv->device_attr.max_cq); - /* If max >= 65535 then max = 0, max_rx_queues is uint16_t. */ - if (max >= 65535) - max = 65535; + max = RTE_MIN(max, (unsigned int)RTE_MAX_QUEUES_PER_PORT); info->max_rx_queues = max; info->max_tx_queues = max; info->max_mac_addrs = RTE_DIM(priv->mac); diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index d80ae458bc..045dae6b5a 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -617,9 +617,7 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) */ max = RTE_MIN(priv->sh->device_attr.orig_attr.max_cq, priv->sh->device_attr.orig_attr.max_qp); - /* If max >= 65535 then max = 0, max_rx_queues is uint16_t. */ - if (max >= 65535) - max = 65535; + max = RTE_MIN(max, (unsigned int)RTE_MAX_QUEUES_PER_PORT); info->max_rx_queues = max; info->max_tx_queues = max; info->max_mac_addrs = MLX5_MAX_UC_MAC_ADDRESSES; diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c index 11723778fd..1065cbf847 100644 --- a/drivers/net/softnic/rte_eth_softnic.c +++ b/drivers/net/softnic/rte_eth_softnic.c @@ -91,8 +91,8 @@ pmd_dev_infos_get(struct rte_eth_dev *dev __rte_unused, struct rte_eth_dev_info *dev_info) { dev_info->max_rx_pktlen = UINT32_MAX; - dev_info->max_rx_queues = UINT16_MAX; - dev_info->max_tx_queues = UINT16_MAX; + dev_info->max_rx_queues = RTE_MAX_QUEUES_PER_PORT; + dev_info->max_tx_queues = RTE_MAX_QUEUES_PER_PORT; return 0; } 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; -- 2.23.0