net: ena: avoid double-counting TX DMA mappings on failure
Subsystems (3)
PATCH v2 1/1 net: ena: avoid double-counting TX DMA mappings on failure
ena_tx_map_skb() increments tx_info->num_of_bufs after each successful DMA mapping. If a later fragment mapping fails, the error path adds the fragment index to this count before calling ena_unmap_tx_buff(). This can cause DMA unmapping of buffers that were never mapped and out-of-bounds access to the buffer array.
Remove the extra increment so that cleanup uses only the number of successfully mapped buffers.
Discovered by comparing the in-tree ENA driver with Amazon's standalone ENA driver.
Compiled with W=1 under x86_64 defconfig and allmodconfig configurations.
---
v2:
- add Evgeny Ostrovsky's Signed-off-by
drivers/net/ethernet/amazon/ena/ena_netdev.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +0 -1
@@ -2608,7 +2608,6 @@ static int ena_tx_map_skb(struct ena_ring *tx_ring, tx_info->skb =NULL ; - tx_info->num_of_bufs += i;ena_unmap_tx_buff (tx_ring, tx_info);return -EINVAL ;
base-commit: 30c71476d842b094651bd7712f6c8ee8716147d0
Signature · 1 line
2.43.0
Quoted 57 lines
-----Original Message-----
From: Avi Weiss <[email protected]>
Sent: Friday, November 13, 2026 10:57 PM
To: [email protected]
Cc: Kiyanovski, Arthur <[email protected]>; Arinzon, David <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ostrovsky, Evgeny <[email protected]>; Avi Weiss <[email protected]>
Subject: [EXTERNAL] [PATCH net v2] net: ena: avoid double-counting TX DMA mappings on failureCAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
ena_tx_map_skb()incrementstx_info->num_of_bufsafter each successful DMA mapping. If a later fragment mapping fails, the error path adds the fragment index to this count before callingena_unmap_tx_buff(). This can cause DMA unmapping of buffers that were never mapped and out-of- bounds access to the buffer array.Remove the extra increment so that cleanup uses only the number of successfully mapped buffers.
Discovered by comparing the in-tree ENA driver with Amazon's standalone ENA driver.
Compiled with W=1 under
x86_64defconfig and allmodconfig configurations.Fixes 38005ca816a7 ("net: ena: add functions for handling Low LatencyQueues in
ena_netdev")Signed-off-by Evgeny Ostrovsky <[email protected]>Signed-off-by Avi Weiss <[email protected]>---
v2:
- add Evgeny Ostrovsky's Signed-off-bydrivers/net/ethernet/amazon/ena/ena_netdev.c | 1 - 1 file changed, 1 deletion(-)drivers/net/ethernet/amazon/ena/ena_netdev.c +0
-1@@ -2608,7 +2608,6 @@ static int ena_tx_map_skb(struct ena_ring *tx_ring, tx_info->skb =NULL ; - tx_info->num_of_bufs += i;ena_unmap_tx_buff (tx_ring, tx_info);return -EINVAL ;
Quoted 3 lines
base-commit:
30c71476d842b094651bd7712f6c8ee8716147d0--
2.43.0