Skip to content
/ linux Public

Commit 22023ff

Browse files
edumazetSasha Levin
authored andcommitted
icmp: prevent possible overflow in icmp_global_allow()
[ Upstream commit 034bbd8 ] Following expression can overflow if sysctl_icmp_msgs_per_sec is big enough. sysctl_icmp_msgs_per_sec * delta / HZ; Fixes: 4cdf507 ("icmp: add a global rate limitation") Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260216142832.3834174-2-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b0da610 commit 22023ff

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/ipv4/icmp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ bool icmp_global_allow(struct net *net)
247247
if (delta < HZ / 50)
248248
return false;
249249

250-
incr = READ_ONCE(net->ipv4.sysctl_icmp_msgs_per_sec) * delta / HZ;
250+
incr = READ_ONCE(net->ipv4.sysctl_icmp_msgs_per_sec);
251+
incr = div_u64((u64)incr * delta, HZ);
251252
if (!incr)
252253
return false;
253254

0 commit comments

Comments
 (0)