]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
octeontx2-pf: fix "UBSAN: shift-out-of-bounds error"
authorAnshumali Gaur <agaur@marvell.com>
Fri, 19 Dec 2025 06:22:26 +0000 (11:52 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Jan 2026 09:14:35 +0000 (10:14 +0100)
[ Upstream commit 85f4b0c650d9f9db10bda8d3acfa1af83bf78cf7 ]

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")
Signed-off-by: Anshumali Gaur <agaur@marvell.com>
Link: https://patch.msgid.link/20251219062226.524844-1-agaur@marvell.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c

index 5197ce816581e3cf503e4b671fb81c067a98adc3..cc6a63e2573f51ba10fafff40903eb8382e61861 100644 (file)
@@ -432,6 +432,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