net: mana: hardening: Reject zero max_num_queues from GDMA_QUERY_MAX_RESOURCES
PATCH v2 1/1 net: mana: hardening: Reject zero max_num_queues from GDMA_QUERY_MAX_RESOURCES
In a CVM environment, hardware responses cannot be trusted. The GDMA_QUERY_MAX_RESOURCES command returns resource limits used to determine the maximum number of queues.
In mana_gd_query_max_resources(), gc->max_num_queues is initialized from num_online_cpus() and successively clamped by the hardware-reported max_eq, max_cq, max_sq, max_rq, and num_msix_usable values. If any of these hardware values is zero, gc->max_num_queues becomes zero and the function returns success. This leads to a confusing failure later when alloc_etherdev_mq() is called with zero queues, returning NULL and producing a misleading -ENOMEM error.
Add an explicit zero check for gc->max_num_queues after all clamping steps and return -ENOSPC for a clear early failure, consistent with the existing gc->num_msix_usable <= 1 guard.
---
Changes in v2:
* Rebase to latest main.
--- drivers/net/ethernet/microsoft/mana/gdma_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/microsoft/mana/gdma_main.c +3 -0
@@ -194,6 +194,9 @@ static int mana_gd_query_max_resources(struct pci_dev *pdev)if (gc->max_num_queues > gc->num_msix_usable -1 ) gc->max_num_queues = gc->num_msix_usable -1 ; +if (gc->max_num_queues ==0 ) +return -ENOSPC ; +return 0 ; }
Signature · 1 line
2.34.1
Quoted 29 lines · Erni Sri Satya Vennela
In a CVM environment, hardware responses cannot be trusted. The
GDMA_QUERY_MAX_RESOURCEScommand returns resource limits used to determine the maximum number of queues.In
mana_gd_query_max_resources(),gc->max_num_queuesis initialized fromnum_online_cpus()and successively clamped by the hardware-reportedmax_eq,max_cq,max_sq,max_rq, andnum_msix_usablevalues. If any of these hardware values is zero,gc->max_num_queuesbecomes zero and the function returns success. This leads to a confusing failure later whenalloc_etherdev_mq()is called with zero queues, returning NULL and producing a misleading-ENOMEMerror.Add an explicit zero check for
gc->max_num_queuesafter all clamping steps and return-ENOSPCfor a clear early failure, consistent with the existinggc->num_msix_usable<= 1 guard.Signed-off-by Erni Sri Satya Vennela <[email protected]>---
Changes in v2:
* Rebase to latest main.--- drivers/net/ethernet/microsoft/mana/gdma_main.c | 3 +++ 1 file changed, 3 insertions(+)drivers/net/ethernet/microsoft/mana/gdma_main.c +0
-0
drivers/net/ethernet/microsoft/mana/gdma_main.c static int mana_gd_query_max_resources(struct pci_dev *pdev) · line 202
Quoted 9 lines
drivers/net/ethernet/microsoft/mana/gdma_main.c +3
-0@@ -194,6 +194,9 @@ static int mana_gd_query_max_resources(struct pci_dev *pdev)if (gc->max_num_queues > gc->num_msix_usable -1 ) gc->max_num_queues = gc->num_msix_usable -1 ; +if (gc->max_num_queues ==0 ) +return -ENOSPC ; +return 0 ; }
Quoted 2 lines
Signature · 1 line
2.34.1
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 12 lines · On Thu, 30 Apr 2026 01:36:21 -0700 you wrote:
In a CVM environment, hardware responses cannot be trusted. The
GDMA_QUERY_MAX_RESOURCEScommand returns resource limits used to determine the maximum number of queues.In
mana_gd_query_max_resources(),gc->max_num_queuesis initialized fromnum_online_cpus()and successively clamped by the hardware-reportedmax_eq,max_cq,max_sq,max_rq, andnum_msix_usablevalues. If any of these hardware values is zero,gc->max_num_queuesbecomes zero and the function returns success. This leads to a confusing failure later whenalloc_etherdev_mq()is called with zero queues, returning NULL and producing a misleading-ENOMEMerror.
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,v2] net: mana: hardening: Reject zero max_num_queues from GDMA_QUERY_MAX_RESOURCES
https://git.kernel.org/netdev/net-next/c/f7622e58e802
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html