git: 49fc8bbbffae - stable/14 - ixgbe: avoid signed overflow in pause time calculation

Kevin Bowling <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a767bd9.3ecbe.48d029bc__27194.1987726436$1786149953$gmane$org@gitrepo.freebsd.org>
The branch stable/14 has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=49fc8bbbffae366e3063647b62e4f548226ddd94

commit 49fc8bbbffae366e3063647b62e4f548226ddd94
Author:     Kevin Bowling <[email protected]>
AuthorDate: 2026-07-28 11:10:09 +0000
Commit:     Kevin Bowling <[email protected]>
CommitDate: 2026-08-08 00:42:06 +0000

    ixgbe: avoid signed overflow in pause time calculation
    
    pause_time is promoted to signed int before multiplication.  Its default
    value of 65535 multiplied by 65537 exceeds INT_MAX and triggers UBSAN,
    even though the result is assigned to a u32.
    
    Make the multiplier unsigned so the calculation has the intended u32
    semantics.  Linux commit 3b70683fc4d6 reported the failure in the generic
    path and used the same mechanical correction.  The 82598-specific flow
    control operation contains the identical expression, so correct it as well.
    
    (cherry picked from commit 35374c3ec69aa87561431e6236706c485bdeeacc)
---
 sys/dev/ixgbe/ixgbe_82598.c  | 2 +-
 sys/dev/ixgbe/ixgbe_common.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/ixgbe/ixgbe_82598.c b/sys/dev/ixgbe/ixgbe_82598.c
index e32fdb8f039c..f27f263dd07f 100644
--- a/sys/dev/ixgbe/ixgbe_82598.c
+++ b/sys/dev/ixgbe/ixgbe_82598.c
@@ -535,7 +535,7 @@ s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
 	}
 
 	/* Configure pause time (2 TCs per register) */
-	reg = hw->fc.pause_time * 0x00010001;
+	reg = hw->fc.pause_time * 0x00010001U;
 	for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
 		IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
 
diff --git a/sys/dev/ixgbe/ixgbe_common.c b/sys/dev/ixgbe/ixgbe_common.c
index c836ccebff0c..6495bfdecc60 100644
--- a/sys/dev/ixgbe/ixgbe_common.c
+++ b/sys/dev/ixgbe/ixgbe_common.c
@@ -2932,7 +2932,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
 	}
 
 	/* Configure pause time (2 TCs per register) */
-	reg = hw->fc.pause_time * 0x00010001;
+	reg = hw->fc.pause_time * 0x00010001U;
 	for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
 		IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.