mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] bonding: alb: Fix overflow in TLB gap calculation
@ 2026-09-13 12:58 lirongqing
  2026-09-14  3:24 ` Xuanqiang Luo
  2026-09-14 13:49 ` netdev-bot+sashiko
  0 siblings, 2 replies; 3+ messages in thread
From: lirongqing @ 2026-09-13 12:58 UTC (permalink / raw)
  To: Jay Vosburgh, Andrew Lunn, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jiri Pirko, netdev, linux-kernel
  Cc: Li RongQing, stable

From: Li RongQing <lirongqing@baidu.com>

compute_gap() shifts 32-bit values before converting them to s64,
which can overflow for high speed network devices. The overflowed
value is then incorrectly used in the TLB load balancing calculation.

Convert the operands to s64 before shifting so the arithmetic is done
in 64-bit width.

Fixes: 097811bb48c7 ("bonding: optimize tlb_get_least_loaded_slave")
Cc: stable@vger.kernel.org
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 drivers/net/bonding/bond_alb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 43ac8e2..b520040 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -160,8 +160,8 @@ static void tlb_deinitialize(struct bonding *bond)
 
 static long long compute_gap(struct slave *slave)
 {
-	return (s64) (slave->speed << 20) - /* Convert to Megabit per sec */
-	       (s64) (SLAVE_TLB_INFO(slave).load << 3); /* Bytes to bits */
+	return ((s64)slave->speed << 20) - /* Convert to Megabit per sec */
+	       ((s64)SLAVE_TLB_INFO(slave).load << 3); /* Bytes to bits */
 }
 
 static struct slave *tlb_get_least_loaded_slave(struct bonding *bond)
-- 
2.9.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-14 13:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-13 12:58 [PATCH] bonding: alb: Fix overflow in TLB gap calculation lirongqing
2026-09-14  3:24 ` Xuanqiang Luo
2026-09-14 13:49 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®