Skip to contentSkip to conversation

drivers: net: xgene: Fix dma_unmap_single() size

PATCH Applied Thomas Fourier 5 participants 6 messages Oct 15 – Oct 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drivers: net: xgene: Fix dma_unmap_single() size

In xgene_enet_refill_bufpool(), the skb->data is dma-mapped with length len which is set to XGENE_ENET_STD_MTU which equals 1536. However, in xgene_enet_delete_bufpool(), the same buffer is unmapped with length XGENE_ENET_MAX_MTU which is 9600. This may erroneously unmap other DMA buffers or cause other issues.

Change unmap length to XGENE_ENET_STD_MTU.

Fixes a9380b0f7be8 ("drivers: net: xgene: Add support for Jumbo frame")

---
v1->v2:
- Fix function name in commit description
- Change Fixes tag

 drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/apm/xgene/xgene_enet_main.c +1 -1
index 507db46daf2b..2ddcbf27014e 100644
@@ -185,7 +185,7 @@ static void xgene_enet_delete_bufpool(struct xgene_enet_desc_ring *buf_pool)
 
 			raw_desc = &buf_pool->raw_desc16[i];
 			dma_addr = GET_VAL(DATAADDR, le64_to_cpu(raw_desc->m1));
-			dma_unmap_single(dev, dma_addr, XGENE_ENET_MAX_MTU,
+			dma_unmap_single(dev, dma_addr, XGENE_ENET_STD_MTU,
 					 DMA_FROM_DEVICE);
 		}
 	}
Signature · 1 line
2.53.0
#1 lore raw
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.

- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.

The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.

#2 lore raw
In reply to Thomas Fourier
Quoted 7 lines · Thomas Fourier

In xgene_enet_refill_bufpool(), the skb->data is dma-mapped with length len which is set to XGENE_ENET_STD_MTU which equals 1536. However, in xgene_enet_delete_bufpool(), the same buffer is unmapped with length XGENE_ENET_MAX_MTU which is 9600. This may erroneously unmap other DMA buffers or cause other issues.

Change unmap length to XGENE_ENET_STD_MTU.

I don't know this driver, so i could be wrong.....

map/unmap is expensive, because it needs to flush/invalidate the cache etc. So the hot path part of the code, dealing with real frame data, sometimes only maps/unmaps the length of the frame, which is less than the length of the buffer, particularly when jumbo is involved.

So you could allocate a buffer for 9600 jumbo, but in the hot path only map/unmap part of it, but when you release the buffer, you need to unmap the full 9600 size of the buffer, to be on the safe size.

Please look at the driver and consider this. As i said, i could be wrong...

Andrew

#3 lore raw
Quoted 10 lines
Quoted 7 lines

In xgene_enet_refill_bufpool(), the skb->data is dma-mapped with length len which is set to XGENE_ENET_STD_MTU which equals 1536. However, in xgene_enet_delete_bufpool(), the same buffer is unmapped with length XGENE_ENET_MAX_MTU which is 9600. This may erroneously unmap other DMA buffers or cause other issues.

Change unmap length to XGENE_ENET_STD_MTU.

I don't know this driver, so i could be wrong.....

Quoted 8 lines

map/unmap is expensive, because it needs to flush/invalidate the cache etc. So the hot path part of the code, dealing with real frame data, sometimes only maps/unmaps the length of the frame, which is less than the length of the buffer, particularly when jumbo is involved.

So you could allocate a buffer for 9600 jumbo, but in the hot path only map/unmap part of it, but when you release the buffer, you need to unmap the full 9600 size of the buffer, to be on the safe size.

I don't think that applies here. The bufpool skbs are mapped and unmapped in the RX path with XGENE_ENET_STD_MTU, never with the frame length. The teardown unmap with XGENE_ENET_MAX_MTU is the only mismatch (AFAICT), and that is what this patch fixes.

Quoted 6 lines

Please look at the driver and consider this. As i said, i could be wrong...

Andrew

/Daniel

Reviewed-by on v2 1/1
#4 lore raw
In reply to Thomas Fourier
Quoted 7 lines

In xgene_enet_refill_bufpool(), the skb->data is dma-mapped with length len which is set to XGENE_ENET_STD_MTU which equals 1536. However, in xgene_enet_delete_bufpool(), the same buffer is unmapped with length XGENE_ENET_MAX_MTU which is 9600. This may erroneously unmap other DMA buffers or cause other issues.

Change unmap length to XGENE_ENET_STD_MTU.

#5 lore raw
In reply to Thomas Fourier
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 9 lines · On Thu, 15 Oct 2026 14:45:46 +0200 you wrote:

In xgene_enet_refill_bufpool(), the skb->data is dma-mapped with length len which is set to XGENE_ENET_STD_MTU which equals 1536. However, in xgene_enet_delete_bufpool(), the same buffer is unmapped with length XGENE_ENET_MAX_MTU which is 9600. This may erroneously unmap other DMA buffers or cause other issues.

Change unmap length to XGENE_ENET_STD_MTU.

[...]

Here is the summary with links:
- [net-next,v2] drivers: net: xgene: Fix dma_unmap_single() size

    https://git.kernel.org/netdev/net-next/c/03977f8f1a63

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html