net: xilinx: axienet: Fix IRQ coalescing packet count overflow
PATCH v5 1/1 net: xilinx: axienet: Fix IRQ coalescing packet count overflow
If coalesce_count is greater than 255 it will not fit in the register and will overflow. This can be reproduced by running
# ethtool -C ethX rx-frames 256
which will result in a timeout of 0us instead. Fix this by checking for invalid values and reporting an error.
---
Changes in v5:
- Fix typo in commit message
Changes in v4:
- Fix checking rx twice instead of rx and tx
Changes in v3:
- Validate and reject instead of silently clamping
Changes in v2:
- Use FIELD_MAX to extract the max value from the mask
- Expand the commit message with an example on how to reproduce this issue
drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6 -0
@@ -2056,6 +2056,12 @@ axienet_ethtools_set_coalesce(struct net_device *ndev,return -EBUSY ; } +if (ecoalesce->rx_max_coalesced_frames >255 || + ecoalesce->tx_max_coalesced_frames >255 ) { +NL_SET_ERR_MSG (extack,"frames must be less than 256" ); +return -EINVAL ; + } +if (ecoalesce->rx_max_coalesced_frames) lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames;if (ecoalesce->rx_coalesce_usecs)
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Quoted 16 lines
-----Original Message-----
From: Sean Anderson <[email protected]>
Sent: Monday, January 13, 2025 10:00 PM
To: Pandey, Radhey Shyam <[email protected]>; Nelson, Shannon <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]
Cc: [email protected]; Simon Horman <[email protected]>; Simek, Michal <[email protected]>; [email protected]; Daniel Borkmann <[email protected]>; Sean Anderson <[email protected]>
Subject: [PATCH net v5] net: xilinx: axienet: Fix IRQ coalescing packet count overflowIf
coalesce_countis greater than 255 it will not fit in the register and will overflow. This can be reproduced by running
Quoted 8 lines
# ethtool -C ethX rx-frames 256which will result in a timeout of 0us instead. Fix this by checking for invalid values and reporting an error.
Fixes 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver")Signed-off-by Sean Anderson <[email protected]>Reviewed-by Shannon Nelson <[email protected]>
Thanks!
Quoted 39 lines
---
Changes in v5:
- Fix typo in commit messageChanges in v4:
- Fix checking rx twice instead of rx and txChanges in v3:
- Validate and reject instead of silently clampingChanges in v2:
- UseFIELD_MAXto extract the max value from the mask
- Expand the commit message with an example on how to reproduce this issuedrivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-1@@ -2056,6 +2056,12 @@ axienet_ethtools_set_coalesce(struct net_device *ndev,return -EBUSY ; } +if (ecoalesce->rx_max_coalesced_frames >255 || + ecoalesce->tx_max_coalesced_frames >255 ) { +NL_SET_ERR_MSG (extack,"frames must be less than 256" ); +return -EINVAL ; + } +if (ecoalesce->rx_max_coalesced_frames) lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames;if (ecoalesce->rx_coalesce_usecs) --2.35.1.1320.gc452695387.dirty
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 13 Jan 2025 11:30:00 -0500 you wrote:
If
coalesce_countis greater than 255 it will not fit in the register and will overflow. This can be reproduced by running# ethtool -C ethX rx-frames 256which will result in a timeout of 0us instead. Fix this by checking for invalid values and reporting an error.
[...]
Here is the summary with links:
- [net,v5] net: xilinx: axienet: Fix IRQ coalescing packet count overflow
https://git.kernel.org/netdev/net/c/c17ff476f53a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html