Commit graph

11758 commits

Author SHA1 Message Date
Mark Andrews
0e6a620432 fix whitespace
(cherry picked from commit 32ba5a0494)
2019-05-07 10:27:18 +10:00
Mark Andrews
2ffdbe9eff return rdatasets when processing ANY queries in client_resfind
(cherry picked from commit 127333c71f)
2019-05-07 10:27:18 +10:00
Evan Hunt
fb58d23a94 simplify the isc_stat structure to take avantage of atomics
(cherry picked from commit 4e5edb35e4)
2019-05-06 14:02:41 -07:00
Evan Hunt
524d36bc2d attach memory context sooner so that cleanup will work correctly
(cherry picked from commit 0fd344e77a)
2019-04-26 15:53:48 -07:00
Ondřej Surý
e203d4d65a Replace atomic operations in bin/named/client.c with isc_refcount reference counting
(cherry picked from commit ef49780d30)
2019-04-26 21:33:50 +02:00
Tinderbox User
02cbca91d7 prep 9.14.1
(cherry picked from commit c7004347bc)
2019-04-25 17:00:56 +02:00
Evan Hunt
86e9e54766 restore allowance for tcp-clients < interfaces
in the "refactor tcpquota and pipeline refs" commit, the counting
of active interfaces was tightened in such a way that named could
fail to listen on an interface if there were more interfaces than
tcp-clients. when checking the quota to start accepting on an
interface, if the number of active clients was above zero, then
it was presumed that some other client was able to handle accepting
new connections. this, however, ignored the fact that the current client
could be included in that count, so if the quota was already exceeded
before all the interfaces were listening, some interfaces would never
listen.

we now check whether the current client has been marked active; if so,
then the number of active clients on the interface must be greater
than 1, not 0.

(cherry picked from commit 02365b87ea0b1ea5ea8b17376f6734c811c95e61)
(cherry picked from commit cae79e1bab)
2019-04-25 16:20:50 +02:00
Evan Hunt
a78af2f1d3 refactor tcpquota and pipeline refs; allow special-case overrun in isc_quota
- if the TCP quota has been exceeded but there are no clients listening
  for new connections on the interface, we can now force attachment to the
  quota using isc_quota_force(), instead of carrying on with the quota not
  attached.
- the TCP client quota is now referenced via a reference-counted
  'ns_tcpconn' object, one of which is created whenever a client begins
  listening for new connections, and attached to by members of that
  client's pipeline group. when the last reference to the tcpconn
  object is detached, it is freed and the TCP quota slot is released.
- reduce code duplication by adding mark_tcp_active() function
- convert counters to stdatomic

(cherry picked from commit a8dd133d270873b736c1be9bf50ebaa074f5b38f)
(cherry picked from commit 4a8fc979c4)
2019-04-25 16:20:50 +02:00
Evan Hunt
a41c9dbfc1 better tcpquota accounting and client mortality checks
- ensure that tcpactive is cleaned up correctly when accept() fails.
- set 'client->tcpattached' when the client is attached to the tcpquota.
  carry this value on to new clients sharing the same pipeline group.
  don't call isc_quota_detach() on the tcpquota unless tcpattached is
  set.  this way clients that were allowed to accept TCP connections
  despite being over quota (and therefore, were never attached to the
  quota) will not inadvertently detach from it and mess up the
  accounting.
- simplify the code for tcpquota disconnection by using a new function
  tcpquota_disconnect().
- before deciding whether to reject a new connection due to quota
  exhaustion, check to see whether there are at least two active
  clients. previously, this was "at least one", but that could be
  insufficient if there was one other client in READING state (waiting
  for messages on an open connection) but none in READY (listening
  for new connections).
- before deciding whether a TCP client object can to go inactive, we
  must ensure there are enough other clients to maintain service
  afterward -- both accepting new connections and reading/processing new
  queries.  A TCP client can't shut down unless at least one
  client is accepting new connections and (in the case of pipelined
  clients) at least one additional client is waiting to read.

(cherry picked from commit 427a2fb4d17bc04ca3262f58a9dcf5c93fc6d33e)
(cherry picked from commit 0896841272)
2019-04-25 16:20:49 +02:00
Michał Kępień
010e6f4bd7 use reference counter for pipeline groups (v3)
Track pipeline groups using a shared reference counter
instead of a linked list.

(cherry picked from commit 31f392db20207a1b05d6286c3c56f76c8d69e574)
(cherry picked from commit 2211120222)
2019-04-25 16:20:49 +02:00
Witold Kręcicki
ef28e8879b tcp-clients could still be exceeded (v2)
the TCP client quota could still be ineffective under some
circumstances.  this change:

- improves quota accounting to ensure that TCP clients are
  properly limited, while still guaranteeing that at least one client
  is always available to serve TCP connections on each interface.
- uses more descriptive names and removes one (ntcptarget) that
  was no longer needed
- adds comments

(cherry picked from commit 9e74969f85329fe26df2fad390468715215e2edd)
(cherry picked from commit d7e84cee0b)
2019-04-25 16:20:49 +02:00
Witold Kręcicki
4ca208adb8 fix enforcement of tcp-clients (v1)
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 9e7617cc84)
2019-04-25 16:20:49 +02:00
Matthijs Mekking
6b22e1f4fe Fix nxdomain-redirect assertion failure
- Always set is_zonep in query_getdb; previously it was only set if
  result was ISC_R_SUCCESS or ISC_R_NOTFOUND.
- Don't reset is_zone for redirect.
- Style cleanup.

(cherry picked from commit a85cc641d7a4c66cbde03cc4e31edc038a24df46)
(cherry picked from commit 486a201149)
2019-04-25 15:59:43 +02:00
Witold Kręcicki
434ef46661 When resuming from qname-minimization increase fetches-per-zone counters for the 'new' zone
(cherry picked from commit 7043c6eaf5)
2019-04-24 11:03:37 +10:00
Mark Andrews
1b432b3633 compute the RSAMD5 key id
(cherry picked from commit ffaa5a07dd)
2019-04-24 08:51:50 +10:00
Mark Andrews
ca51ee2bb3 use isc_refcount_decrement to decrement NEWCONNSOCK(dev)->references; use isc_refcount_increment instead of isc_refcount_init in socket_create
(cherry picked from commit 265554f895)
2019-04-23 14:47:20 +10:00
Mark Andrews
ff2c10cced add assertions to silence clang false positive
(cherry picked from commit bed9ad79ba)
2019-04-23 14:05:47 +10:00
Evan Hunt
fcd2c2b644 force SERVFAIL response in the gotanswer failure case
- named could return FORMERR if parsing iterative responses
  ended with a result code such as DNS_R_OPTERR. instead of
  computing a response code based on the result, in this case
  we now just force the response to be SERVFAIL.

(cherry picked from commit 7402615697)
2019-04-22 19:11:41 -07:00
Mark Andrews
d5d4ddd764 using 0 instead of false
(cherry picked from commit da7f683abf)
2019-04-23 11:45:33 +10:00
Ondřej Surý
3349792aa3 On non-GNUC systems, use uintmax_t in the ISC_ALIGN macro
(cherry picked from commit 2e40cc94dc)
2019-04-18 13:17:21 +02:00
Ondřej Surý
cd40d65e1b Refactor the DNS_RDATASET_FIXED code to use constants instead of ifdefs
(cherry picked from commit 4edbb773a1)
2019-04-17 11:34:17 +02:00
Evan Hunt
19f249ffa5 if recursion is allowed and minimal-responses is no, search other databases
this restores functionality that was removed in commit 03be5a6b4e,
allowing named to search in authoritative zone databases outside the
current zone for additional data, if and only if recursion is allowed
and minimal-responses is disabled.

(cherry picked from commit 7fff3295f5)
2019-04-15 11:38:28 -07:00
Matthijs Mekking
f4dc62f33b With update-check-ksk also consider offline keys
The option `update-check-ksk` will look if both KSK and ZSK are
available before signing records.  It will make sure the keys are
active and available.  However, for operational practices keys may
be offline.  This commit relaxes the update-check-ksk check and will
mark a key that is offline to be available when adding signature
tasks.

(cherry picked from commit 3cb8c49c73)
2019-04-12 11:33:06 +02:00
Matthijs Mekking
244870844c Style: some curly brackets
(cherry picked from commit 2e83e3255a)
2019-04-12 11:33:06 +02:00
Evan Hunt
f6c3b13522 dnstap: if recursion is not available, log queries as AQ instead of CQ
(cherry picked from commit 1f578cdb12)
2019-04-11 15:45:52 -07:00
Mark Andrews
b27ef87c38 Add debug printfs
(cherry picked from commit b78e128a2f)
2019-04-11 19:47:44 +10:00
Mark Andrews
86bb6e23ce Prevent WIRE_INVALID() being called without a argument
(cherry picked from commit e73a5b0ce3)
2019-04-11 19:47:44 +10:00
Mark Andrews
1eb7267e60 Check multi-line output from dns_rdata_tofmttext()
Check that multi-line output from dns_rdata_tofmttext() can be read
back in by dns_rdata_fromtext().

(cherry picked from commit b089f43b7a)
2019-04-11 19:47:44 +10:00
Mark Andrews
14c2db8c5d Process master file comments and make input invalid again
(cherry picked from commit 1a75a5cee6)
2019-04-11 19:47:43 +10:00
Mark Andrews
4395311280 Set 'specials' to match 'specials' in 'lib/dns/master.c'
(cherry picked from commit 7941a9554f)
2019-04-11 19:47:43 +10:00
Mark Andrews
c5b191e78f Fix whitespace so that the names align
(cherry picked from commit cc5e16e4d3)
2019-04-11 19:47:43 +10:00
Mark Andrews
56a534ab06 Add dns_rdata_totext() and dns_rdata_fromtext() to fromwire
Add dns_rdata_totext() and dns_rdata_fromtext() to fromwire for
valid inputs to ensure that what we accept in dns_rdata_fromwire()
can be written out and read back in.

(cherry picked from commit 36f30f5731)
2019-04-11 19:47:43 +10:00
Mark Andrews
10fba8fd8d Initialise mincachettl and minncachettl to zero in dns_view_create.
(cherry picked from commit 8fd4308bda)
2019-04-10 15:08:33 +10:00
Mark Andrews
480bcb314d add ds unit test
(cherry picked from commit 6eb28eda1e)
2019-04-10 14:44:05 +10:00
Mark Andrews
b24c128a2c enforce DS hash exists
(cherry picked from commit b274f3fad7)
2019-04-10 14:44:05 +10:00
Mark Andrews
d006ae2195 check that from fromtext produces valid towire input
(cherry picked from commit 7b0a653858)
2019-04-10 13:24:17 +10:00
Mark Andrews
53a62e2977 for rkey flags MUST be zero
(cherry picked from commit 82d4931440)
2019-04-09 14:22:50 +10:00
Mark Andrews
07d024a4da check flags for no key in fromwire for *KEY
(cherry picked from commit 2592e91516)
2019-04-09 14:22:50 +10:00
Mark Andrews
14313d798a <dns/ecs.h> was missing ISC_LANG_ENDDECLS.
(cherry picked from commit 698a6f955e)
2019-04-09 12:05:57 +10:00
Witold Kręcicki
6e63d7047d Fix deadlock in RPZ update code.
In dns_rpz_update_from_db we call setup_update which creates the db
iterator and calls dns_dbiterator_first. This unpauses the iterator and
might cause db->tree_lock to be acquired. We then do isc_task_send(...)
on an event to do quantum_update, which (correctly) after each iteration
calls dns_dbiterator_pause, and re-isc_task_sends itself.

That's an obvious bug, as we're holding a lock over an async task send -
if a task requesting write (e.g. prune_tree) is scheduled on the same
workers queue as update_quantum but before it, it will wait for the
write lock indefinitely, resulting in a deadlock.

To fix it we have to pause dbiterator in setup_update.

(cherry picked from commit 06021b3529)
2019-04-06 12:41:36 -07:00
Witold Kręcicki
9ff296afeb In resume_qmin check if the fetch context is already shutting down - if so, try to destroy it, don't continue
(cherry picked from commit 7c960e89ea)
2019-04-03 16:34:33 +02:00
Witold Kręcicki
69d3bb78c2 Fix assertion failure in nslookup/dig/mdig when message has multiple SIG(0) options.
When parsing message with DNS_MESSAGE_BESTEFFORT (used exclusively in
tools, never in named itself) if we hit an invalid SIG(0) in wrong
place we continue parsing the message, and put the sig0 in msg->sig0.
If we then hit another sig0 in a proper place we see that msg->sig0
is already 'taken' and we don't free name and rdataset, and we don't
set seen_problem. This causes an assertion failure.
This fixes that issue by setting seen_problem if we hit second sig0,
tsig or opt, which causes name and rdataset to be always freed.

(cherry picked from commit 51a55ddbb7)
2019-03-26 21:32:08 +11:00
Ondřej Surý
7485a4332e Make lib/dns/dnstap.pb-c.h private header
This changes dns_dtdata struct to not expose data types from dnstap.pb-c.h to
prevent the need for including this header where not really needed.

(cherry picked from commit 8ccce7e24b)
2019-03-22 12:07:31 +01:00
Evan Hunt
dde35a8edf don't fail when allow-update{,-forwarding} is used globally
(cherry picked from commit 91dca0f8da)
2019-03-22 00:14:52 -07:00
Mark Andrews
753d77c51f Disallow empty ZONEMD hashes
This change is the result of discussions with the authors of
draft-wessels-dns-zone-digest.

(cherry picked from commit 473987d8d9)
2019-03-22 06:52:10 +11:00
Mark Andrews
c52dfb2063 add brackets for multi-line output
(cherry picked from commit 40a770b932)
2019-03-21 20:26:02 +11:00
Petr Menšík
7885bbff99 Fix regression in dnstap_test with native pkcs11
Change to cmocka broken initialization of TZ environment. This time,
commit 1cf1254051 is not soon enough. Has
to be moved more forward, before any other tests. It library is not full
reinitialized on each test.

(cherry picked from commit 71c4fad592)
2019-03-15 16:17:52 +11:00
Mark Andrews
b30e5f11fb force promotion to unsigned int
(cherry picked from commit 1eba2c5b06)
2019-03-14 13:51:30 -07:00
Mark Andrews
68608eaa3c assert hevent->rdataset is non NULL
(cherry picked from commit d8d04edfba)
2019-03-14 13:16:43 -07:00
Mark Andrews
cdaf04f043 missing #include <isc/lang.h>
(cherry picked from commit 719b1d7fdc)
2019-03-14 12:24:19 -07:00