lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 22 Sep 2014 13:25:12 -0700
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	David Miller <davem@...emloft.net>
Cc:	netdev@...r.kernel.org
Subject: Re: [PATCH net-next] icmp: add a global rate limitation

On Mon, 2014-09-22 at 16:09 -0400, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@...il.com>
> Date: Fri, 19 Sep 2014 07:38:40 -0700
> 
> > Current ICMP rate limiting uses inetpeer cache, which is an RBL tree
> > protected by a lock, meaning that hosts can be stuck hard if all cpus
> > want to check ICMP limits.
> 
> However, the replacement uses a single global spinlock for
> synchronization.
> 
>  ...
> > Note that if we really want to send millions of ICMP messages per
> > second, we might extend idea and infra added in commit 04ca6973f7c1a
> > ("ip: make IP identifiers less predictable") :
> > add a token bucket in the ip_idents hash and no longer rely on inetpeer.
> 
> That would be preferred.


> 
> I don't really see how this patch makes things better.  The code goes
> through a global spinlock unconditionally, and if it passes then it
> looks up the inetpeer anyways.
> 

The inetpeer is only hit at most 1000 times per second, which is a
rather low rate.


> I need more information to be convinced that this is an improvement
> and that it actually solves the stated problem.  I'm sure you also
> have some performance metrics to share, right? :-)

It does not use the global spinlock in the stress situation.

I tested this patch I can tell you it works ;)

+       /* Check if token bucket is empty and cannot be refilled
+        * without taking the spinlock.
+        */
+       if (!icmp_global.credit) {
+               delta = min_t(u32, now - icmp_global.stamp, HZ);
+               if (delta < HZ / 50)
+                       return false;
+       }
+

So if we are under pressure (credit is exhausted), we exit early unless
20ms were elapsed, and in this case we'll refill the token bucket.

Thanks


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ