Files
linux-rockchip/include/net
Eric Dumazet 997ba88896 icmp: change the order of rate limits
commit 8c2bd38b95f75f3d2a08c93e35303e26d480d24e upstream.

ICMP messages are ratelimited :

After the blamed commits, the two rate limiters are applied in this order:

1) host wide ratelimit (icmp_global_allow())

2) Per destination ratelimit (inetpeer based)

In order to avoid side-channels attacks, we need to apply
the per destination check first.

This patch makes the following change :

1) icmp_global_allow() checks if the host wide limit is reached.
   But credits are not yet consumed. This is deferred to 3)

2) The per destination limit is checked/updated.
   This might add a new node in inetpeer tree.

3) icmp_global_consume() consumes tokens if prior operations succeeded.

This means that host wide ratelimit is still effective
in keeping inetpeer tree small even under DDOS.

As a bonus, I removed icmp_global.lock as the fast path
can use a lock-free operation.

Fixes: c0303efeab ("net: reduce cycles spend on ICMP replies that gets rate limited")
Fixes: 4cdf507d54 ("icmp: add a global rate limitation")
Reported-by: Keyu Man <keyu.man@email.ucr.edu>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Cc: Jesper Dangaard Brouer <hawk@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20240829144641.3880376-2-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-10-17 15:21:27 +02:00
..
2022-08-23 10:43:11 +02:00
2022-08-09 22:14:02 -07:00
2021-12-16 07:18:35 -08:00
2023-11-20 11:52:15 +01:00
2021-10-15 11:33:08 +01:00
2024-01-31 16:17:04 -08:00
2024-10-17 15:21:27 +02:00
2021-10-13 09:40:46 -07:00
2022-05-11 12:43:10 +01:00
2023-10-10 22:00:46 +02:00
2023-04-13 16:55:23 +02:00
2022-06-19 10:00:02 +01:00
2023-06-14 11:15:20 +02:00
2024-06-16 13:41:40 +02:00
2021-08-03 13:05:26 +01:00
2024-01-10 17:10:27 +01:00
2023-08-11 12:08:17 +02:00