Re: [PATCH net] bonding: fix u32 overflow in compute_gap()
Jakub Kicinski <[email protected]>
| Newsgroups | org.kernel.vger.netdev,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 10 Aug 2026 10:38:23 +0800 Hangbin Liu wrote: > From: Hangbin Liu <[email protected]> > > compute_gap() computes the gap between a slave's link capacity and its > current TLB load. Both terms use u32 left-shifts that overflow on modern > hardware: > > - slave->speed is u32 in Mbps; speed << 20 overflows at > 4Gbps. > - SLAVE_TLB_INFO(slave).load is u32; load << 3 overflows at > 512M. > > Cast both operands to s64 before shifting so the arithmetic is performed > in 64 bits. Also update the comment to make it more clear. Could you clarify the impact in the commit message a little more explicitly? If the links are the same speed -- does this fix still matter? AI over here says: The fix is incomplete for very high loads: each hash bucket’s u32 tx_bytes already wraps above roughly 3.44 Gbit/s sustained over the 10-second interval, and aggregate u32 load wraps above roughly 34.4 Gbit/s. While these are not exactly the same lines of code - I think it'd be worth to address them all in one series. > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Signed-off-by: Hangbin Liu <[email protected]> Oh, you work at KylinOS now -- please clearly state in the commit message if the issue was seen in real life or AI-detected.