Skip to contentSkip to conversation

octeontx2-pf: fix "UBSAN: shift-out-of-bounds error"

PATCH Applied Anshumali Gaur 3 participants 3 messages Dec 19, 2025 – Dec 29, 2025

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

PATCH 1/1 octeontx2-pf: fix "UBSAN: shift-out-of-bounds error"

This patch ensures that the RX ring size (rx_pending) is not set below the permitted length. This avoids UBSAN shift-out-of-bounds errors when users passes small or zero ring sizes via ethtool -G.

Fixes d45d8979840d ("octeontx2-pf: Add basic ethtool support")
Change-Id I6de6770dbc0dd952725ccd71ce521f801bc7b15b
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +8 -0
index b90e23dc49de..b6449f0a9e7d 100644
@@ -418,6 +418,14 @@ static int otx2_set_ringparam(struct net_device *netdev,
 	 */
 	if (rx_count < pfvf->hw.rq_skid)
 		rx_count =  pfvf->hw.rq_skid;
+
+	if (ring->rx_pending < 16) {
+		netdev_err(netdev,
+			   "rx ring size %u invalid, min is 16\n",
+			   ring->rx_pending);
+		return -EINVAL;
+	}
+
 	rx_count = Q_COUNT(Q_SIZE(rx_count, 3));
 
 	/* Due pipelining impact minimum 2000 unused SQ CQE's
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 8 lines · Anshumali Gaur

This patch ensures that the RX ring size (rx_pending) is not set below the permitted length. This avoids UBSAN shift-out-of-bounds errors when users passes small or zero ring sizes via ethtool -G.

Fixes d45d8979840d ("octeontx2-pf: Add basic ethtool support")
Change-Id I6de6770dbc0dd952725ccd71ce521f801bc7b15b

Please strip the above tag in future submissions.

Thanks,

Paolo

#2 lore raw
In reply to Anshumali Gaur
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Fri, 19 Dec 2025 11:52:26 +0530 you wrote:

This patch ensures that the RX ring size (rx_pending) is not set below the permitted length. This avoids UBSAN shift-out-of-bounds errors when users passes small or zero ring sizes via ethtool -G.

Fixes d45d8979840d ("octeontx2-pf: Add basic ethtool support")
Change-Id I6de6770dbc0dd952725ccd71ce521f801bc7b15b

[...]

Here is the summary with links:
- octeontx2-pf: fix "UBSAN: shift-out-of-bounds error"

    https://git.kernel.org/netdev/net/c/85f4b0c650d9

You are awesome, thank you!

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