diff options
| author | Eric Dumazet <edumazet@google.com> | 2026-02-16 14:28:28 +0000 |
|---|---|---|
| committer | Sasha Levin <sashal@kernel.org> | 2026-03-04 07:20:08 -0500 |
| commit | 89ebdf2d4fb4fc57349fba42365971e0f7d431b1 (patch) | |
| tree | 7f6a427ac72c10e7c44bda2191d02599fe3b89c2 | |
| parent | c82893aa0d65278561a677d96fc1784a459a7110 (diff) | |
icmp: prevent possible overflow in icmp_global_allow()
[ Upstream commit 034bbd806298e9ba4197dd1587b0348ee30996ea ]
Following expression can overflow
if sysctl_icmp_msgs_per_sec is big enough.
sysctl_icmp_msgs_per_sec * delta / HZ;
Fixes: 4cdf507d5452 ("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>
| -rw-r--r-- | net/ipv4/icmp.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index d2c7509135a3..374ec3aba66e 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -247,7 +247,8 @@ bool icmp_global_allow(struct net *net) if (delta < HZ / 50) return false; - incr = READ_ONCE(net->ipv4.sysctl_icmp_msgs_per_sec) * delta / HZ; + incr = READ_ONCE(net->ipv4.sysctl_icmp_msgs_per_sec); + incr = div_u64((u64)incr * delta, HZ); if (!incr) return false; |
