net/cxgbe: fix use-after-free in control queue teardown
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · B T Dhanush
t4_free_sge_resources()frees ctrl Tx queue and firmware event queue DMA memzones usingadapter->eth_dev, read at teardown time. This runs only once, when the last port on the adapter closes.
rte_eth_dev_close()frees a port'seth_dev->dataright after that port's owndev_close()returns, regardless of other ports' state. If port 0 is not the last port closed,adapter->eth_dev->datais already freed by the timet4_free_sge_resources()runs, causing a NULL pointer dereference inrte_eth_dma_zone_free()and a crash on exit.
Quoted 5 lines
Fix by not dereferencing
eth_devat teardown. Store theport_idused for each queue's memzone name at allocation time instead, and free each memzone directly via rte_memzone_lookup()/rte_memzone_free().Fixes 36c46e738120 ("ethdev: cleanup shared data with the last port")
This commit may have made the bug more visible but I doubt this is the reason for the reported issue.
Quoted 4 lines
Signed-off-by B T Dhanush <[email protected]>Signed-off-by Potnuri Bharat Teja <[email protected]>
I don't understand the issue for now.
Something looks wrong in the driver, and the description above.
The adapter object seems to embed shared resources across multiple eth_dev objects, is that correct?
If so, any function taking only a adapter pointer as input can only deal with the first port related.
This is probably the reported crash and then I would point at:
Which releases only the first port DMA resources even for another port.
If those DMA resources are shared, the driver should not use rte_eth_dma_zone_reserve() and this driver should come with its own helper.
But otherwise, if each eth_dev object has its DMA resources (which seems more likely to me), then my suggestion is to pass a eth_dev object to the related functions.
And a followup cleanup would be to remove the back reference to the first eth_dev in the adapter object which I find really confusing and could be a source of bugs.
Signature · 1 line
David Marchand
Quoted 16 lines
I don't understand the issue for now.
Something looks wrong in the driver, and the description above.The adapter object seems to embed shared resources across multiple
eth_devobjects, is that correct?
If so, any function taking only a adapter pointer as input can only deal with the first port related.This is probably the reported crash and then I would point at:
Fixes 6b78a629954c ("net/cxgbe: fix queue DMA ring leaks during port close").Which releases only the first port DMA resources even for another port.
If those DMA resources are shared, the driver should not use
rte_eth_dma_zone_reserve()and this driver should come with its own helper.
Quoted 6 lines
But otherwise, if each
eth_devobject has its DMA resources (which seems more likely to me), then my suggestion is to pass aeth_devobject to the related functions.
And a followup cleanup would be to remove the back reference to the firsteth_devin the adapter object which I find really confusing and could be a source of bugs.
Thanks for your review, I am working on the v2 based on your suggestions.
________________________________
From: David Marchand <[email protected]>
Sent: Wednesday, September 2, 2026 5:25 PM
To: Dhanush BT. <[email protected]>
Cc: [email protected] <[email protected]>; Potnuri Bharat Teja <[email protected]>; [email protected] <[email protected]>
Subject: Re: [PATCH] net/cxgbe: fix use-after-free in control queue teardown
Quoted 11 lines · B T Dhanush
t4_free_sge_resources()frees ctrl Tx queue and firmware event queue DMA memzones usingadapter->eth_dev, read at teardown time. This runs only once, when the last port on the adapter closes.
rte_eth_dev_close()frees a port'seth_dev->dataright after that port's owndev_close()returns, regardless of other ports' state. If port 0 is not the last port closed,adapter->eth_dev->datais already freed by the timet4_free_sge_resources()runs, causing a NULL pointer dereference inrte_eth_dma_zone_free()and a crash on exit.
Quoted 5 lines
Fix by not dereferencing
eth_devat teardown. Store theport_idused for each queue's memzone name at allocation time instead, and free each memzone directly via rte_memzone_lookup()/rte_memzone_free().Fixes 36c46e738120 ("ethdev: cleanup shared data with the last port")
This commit may have made the bug more visible but I doubt this is the reason for the reported issue.
Quoted 4 lines
Signed-off-by B T Dhanush <[email protected]>Signed-off-by Potnuri Bharat Teja <[email protected]>
I don't understand the issue for now.
Something looks wrong in the driver, and the description above.
The adapter object seems to embed shared resources across multiple eth_dev objects, is that correct?
If so, any function taking only a adapter pointer as input can only deal with the first port related.
This is probably the reported crash and then I would point at:
Which releases only the first port DMA resources even for another port.
If those DMA resources are shared, the driver should not use rte_eth_dma_zone_reserve() and this driver should come with its own helper.
But otherwise, if each eth_dev object has its DMA resources (which seems more likely to me), then my suggestion is to pass a eth_dev object to the related functions.
And a followup cleanup would be to remove the back reference to the first eth_dev in the adapter object which I find really confusing and could be a source of bugs.
--
David Marchand