Skip to contentSkip to conversation

net: xilinx: axienet: Fix IRQ coalescing packet count overflow

PATCH Superseded Sean Anderson 1 participant 2 messages Jan 9, 2025

Subsystems (4)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 net: xilinx: axienet: Fix IRQ coalescing packet count overflow

If coalece_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.

Fixes 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver")

---

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
index 0f4b02fe6f85..c2991aeccf2b 100644
@@ -2056,6 +2056,12 @@ axienet_ethtools_set_coalesce(struct net_device *ndev,
 		return -EBUSY;
 	}
 
+	if (ecoalesce->rx_max_coalesced_frames > 255 ||
+	    ecoalesce->rx_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
#1 lore raw
Quoted 28 lines · Sean Anderson

If coalece_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.

Fixes 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver")

---

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 +0 -0
index 0f4b02fe6f85..c2991aeccf2b 100644

drivers/net/ethernet/xilinx/xilinx_axienet_main.c axienet_ethtools_set_coalesce(struct net_device *ndev, · line 2060

Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2 -0
@@ -2056,6 +2056,12 @@ axienet_ethtools_set_coalesce(struct net_device *ndev,
 		return -EBUSY;
 	}
 
+	if (ecoalesce->rx_max_coalesced_frames > 255 ||
+	    ecoalesce->rx_max_coalesced_frames > 255) {

The second line should be for tx and not rx.

Will resend tomorrow if no other feedback.

--Sean

Quoted 7 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4 -0
+		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)