]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
fix enforcement of tcp-clients (v1)
authorWitold Kręcicki <wpk@isc.org>
Thu, 3 Jan 2019 13:17:43 +0000 (14:17 +0100)
committerOndřej Surý <ondrej@sury.org>
Thu, 25 Apr 2019 14:32:04 +0000 (16:32 +0200)
tcp-clients settings could be exceeded in some cases by
creating more and more active TCP clients that are over
the set quota limit, which in the end could lead to a
DoS attack by e.g. exhaustion of file descriptors.

If TCP client we're closing went over the quota (so it's
not attached to a quota) mark it as mortal - so that it
will be destroyed and not set up to listen for new
connections - unless it's the last client for a specific
interface.

(cherry picked from commit eafcff07c25bdbe038ae1e4b6660602a080b9395)
(cherry picked from commit 9e7617cc84f465769be1a3f426f30cd516220902)

lib/ns/client.c

index 12fb45f4747cbac35e4fe3c2aaa7cc8f40926e92..6f101713afc73cb35bbf1a73de8f8ca97f9d132b 100644 (file)
@@ -439,8 +439,19 @@ exit_check(ns_client_t *client) {
                        isc_socket_detach(&client->tcpsocket);
                }
 
-               if (client->tcpquota != NULL)
+               if (client->tcpquota != NULL) {
                        isc_quota_detach(&client->tcpquota);
+               } else {
+                       /*
+                        * We went over quota with this client, we don't
+                        * want to restart listening unless this is the
+                        * last client on this interface, which is
+                        * checked later.
+                        */
+                       if (TCP_CLIENT(client)) {
+                               client->mortal = true;
+                       }
+               }
 
                if (client->timerset) {
                        (void)isc_timer_reset(client->timer,