Commit graph

12574 commits

Author SHA1 Message Date
Mark Andrews
6964a21fa6 Remove INSIST from from new_reference
RBTDB node can now appear on the deadnodes lists following the changes
to decrement_reference in 176b23b6cd to
defer checking of node->down when the tree write lock is not held.  The
node should be unlinked instead.

(cherry picked from commit 569cc155b8680d8ed12db1fabbe20947db24a0f9)
2020-06-18 10:18:42 +02:00
Mark Andrews
ee6f60349b Adjust NS_CLIENT_TCP_BUFFER_SIZE and cleanup client_allocsendbuf
NS_CLIENT_TCP_BUFFER_SIZE was 2 byte too large following the
move to netmgr add associated changes to lib/ns/client.c and
as a result an INSIST could be trigger if the DNS message being
constructed had a checkpoint stage that fell in those two extra
bytes.  Adjusted NS_CLIENT_TCP_BUFFER_SIZE and cleaned up
client_allocsendbuf now that the previously reserved 2 bytes
are no longer used.

(cherry picked from commit 5a92af19b7dce684b0e6670ae6ec1c4c58613263)
2020-06-18 10:18:41 +02:00
Ondřej Surý
8b4fe6c6c5 Add missing acquire memory barrier in isc_nmhandle_unref
The ThreadSanitizer uses system synchronization primitives to check for
data race.  The netmgr handle->references was missing acquire memory
barrier before resetting and reusing the memory occupied by isc_nmhandle_t.

(cherry picked from commit 1013c0930e)
2020-06-16 08:58:33 +02:00
Mark Andrews
06cebcb6b7 val->keynode is no longer needed
(cherry picked from commit ff4fc3f8dc)
2020-06-11 16:09:43 +10:00
Mark Andrews
70c27df941 The dsset returned by dns_keynode_dsset needs to be thread safe.
- clone keynode->dsset rather than return a pointer so that thread
  use is independent of each other.
- hold a reference to the dsset (keynode) so it can't be deleted
  while in use.
- create a new keynode when removing DS records so that dangling
  pointers to the deleted records will not occur.
- use a rwlock when accessing the rdatalist to prevent instabilities
  when DS records are added.

(cherry picked from commit e5b2eca1d3)
2020-06-11 16:09:43 +10:00
Witold Kręcicki
aa2282853a Fix a race in TCP accepting.
There's a possibility of a race in TCP accepting code:
T1 accepts a connection C1
T2 accepts a connection C2
T1 tries to accept a connection C3, but we hit a quota,
   isc_quota_cb_init() sets quota_accept_cb for the socket,
   we return from accept_connection
T2 drops C2, but we race in quota_release with accepting C3 so
   we don't see quota->waiting is > 0, we don't launch the callback
T1 accepts a connection C4, we are able to get the quota we clear
   the quota_accept_cb from sock->quotacb
T1 drops C1, tries to call the callback which is zeroed, sigsegv.
2020-06-10 11:39:43 -07:00
Witold Kręcicki
7ff1ff88f9 Don't clean quota cb cb_func/data, we don't own it 2020-06-10 17:52:53 +02:00
Witold Kręcicki
31897276d9 Fix 'error: ‘%s’ directive argument is null [-Werror=format-overflow=]' in assertions.c
(cherry picked from commit f4260dc0c5)
2020-06-08 15:57:31 +00:00
Witold Kręcicki
bbf1422614 Fix possible deadlock in unix/socket.c
In process_fd we lock sock->lock and then internal_accept locks mgr->lock,
in isc_sockmgr_render* functions we lock mgr->lock and then lock sock->lock,
that can cause a deadlock when accessing stats. Unlock sock->lock early in
all the internal_{send,recv,connect,accept} functions instead of late
in process_fd.
2020-06-08 15:30:10 +02:00
Witold Kręcicki
c3dcab5f13 Fix a data access race in resolver
We were passing client address to dns_resolver_createfetch as a pointer
and it was saved as a pointer. The client (with its address) could be
gone before the fetch is finished, and in a very odd scenario
log_formerr would call isc_sockaddr_format() which first checks if the
address family is valid (and at this point it still is), then the
sockaddr is cleared, and then isc_netaddr_fromsockaddr is called which
fails an assertion as the address family is now invalid.

(cherry picked from commit 175c4d9055)
2020-06-05 18:58:13 -07:00
Mark Andrews
28a940fe69 Add +yaml support for EDE
(cherry picked from commit 0ec77c2b92)
2020-06-05 10:50:58 +10:00
Michal Nowak
e39685b579
Fix "array subscript is of type 'char'" 2020-06-04 16:27:43 +02:00
Mark Andrews
6ac4e62fbc Ignore attempts to add DS records at zone apex
DS records belong in the parent zone at a zone cut and
are not retrievable with modern recursive servers.

(cherry picked from commit ae55fbbe9c)
2020-06-04 16:06:45 +02:00
Mark Andrews
b17f6eba6a Reject primary zones with an DS record at the zone apex.
DS records only belong at delegation points and if present
at the zone apex are invariably the result of administrative
errors.  Additionally they can't be queried for with modern
resolvers as the parent servers will be queried.

(cherry picked from commit 35a58d30c9)
2020-06-04 16:06:07 +02:00
Ondřej Surý
ef50067fd2 Stop building release notes as a separate sphinx-doc document
The release notes were previously built as a separate document
(including the PDF version).  It was agreed that this doesn't make much
sense, so the release notes are now included only as an appendix to the
BIND 9 ARM.

(cherry picked from commit 8eb2323ec3)
2020-06-04 11:24:53 +02:00
Witold Kręcicki
091117b7ae isc_uv_import must pass UV__IPC_SOCKET_XFER_TCP_CONNECTION, not SERVER.
As a leftover from old TCP accept code isc_uv_import passed TCP_SERVER
flag when importing a socket on Windows.
Since now we're importing/exporting accepted connections it needs to
pass TCP_CONNECTION flag.

(cherry picked from commit 801f7af6e9)
2020-06-03 23:27:24 +02:00
Witold Kręcicki
c4f91575ca Clean quota callback after calling it
(cherry picked from commit 2f252a1068)
2020-06-03 23:00:52 +02:00
Witold Kręcicki
818afe613f Redesigned TCP accepting: one listen/accept loop, passing the connected socket.
Instead of using bind() and passing the listening socket to the children
threads using uv_export/uv_import use one thread that does the accepting,
and then passes the connected socket using uv_export/uv_import to a random
worker. The previous solution had thundering herd problems (all workers
waking up on one connection and trying to accept()), this one avoids this
and is simpler.
The tcp clients quota is simplified with isc_quota_attach_cb - a callback
is issued when the quota is available.

(cherry picked from commit 60629e5b0b)
2020-06-03 23:00:52 +02:00
Witold Kręcicki
ca26bcca38 tests: fix isc/socket_test.c teardown
In case of a test failure we weren't tearing down sockets and tasks
properly, causing the test to hang instead of failing nicely.

(cherry picked from commit 4a8d9250cf)
2020-06-03 14:12:18 +02:00
Ondřej Surý
1217916c1e Don't check the result of setting SO_INCOMING_CPU
The SO_INCOMING_CPU is available since Linux 3.19 for getting the value,
but only since Linux 4.4 for setting the value (see below for a full
description).  BIND 9 should not fail when setting the option on the
socket fails, as this is only an optimization and not hard requirement
to run BIND 9.

    SO_INCOMING_CPU (gettable since Linux 3.19, settable since Linux 4.4)
        Sets or gets the CPU affinity of a socket.  Expects an integer flag.

            int cpu = 1;
            setsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU, &cpu, sizeof(cpu));

        Because all of the packets for a single stream (i.e., all
	packets for the same 4-tuple) arrive on the single RX queue that
	is associated with a particular CPU, the typical use case is to
	employ one listening process per RX queue, with the incoming
	flow being handled by a listener on the same CPU that is
	handling the RX queue.  This provides optimal NUMA behavior and
	keeps CPU caches hot.

(cherry picked from commit 4ec357da0a)
2020-06-03 12:47:21 +02:00
Matthijs Mekking
a17dcccf7d Retire predecessor when creating successor
When creating the successor, the current active key (predecessor)
should change its goal state to HIDDEN.

Also add two useful debug logs in the keymgr_key_rollover function.

(cherry picked from commit e71d60299f)
2020-06-02 14:54:41 +02:00
Matthijs Mekking
ef1a4a416a If prepub > retire, prepub now
Catch a case where if the prepublication time of the successor key
is later than the retire time of the predecessor. If that is the
case we should prepublish as soon as possible, a.k.a. now.

(cherry picked from commit c08d0f7dd6)
2020-06-02 14:54:32 +02:00
Matthijs Mekking
b0737b8c61 Put new key rollover logic in separate function
The `dns_keymgr_run()` function became quite long, put the logic
that looks if a new key needs to be created (start a key rollover)
in a separate function.

(cherry picked from commit bcf8192438)
2020-06-02 14:54:20 +02:00
Matthijs Mekking
168d362b54 Fix bug in keymgr_key_has_successor
The logic in `keymgr_key_has_successor(key, keyring)` is flawed, it
returns true if there is any key in the keyring that has a successor,
while what we really want here is to make sure that the given key
has a successor in the given keyring.

Rather than relying on `keymgr_key_exists_with_state`, walk the
list of keys in the keyring and check if the key is a successor of
the given predecessor key.

(cherry picked from commit 0d578097ef)
2020-06-02 14:54:08 +02:00
Matthijs Mekking
f026332f88 Test keytimes on CSK rollover
This improves keytime testing on CSK rollover.  It now
tests for specific times, and also tests for SyncPublish and
Removed keytimes.

Since an "active key" for ZSK and KSK means something
different, this makes it tricky to decide when a CSK is
active. An "active key" intuitively means the key is signing
so we say a CSK is active when it is creating zone signatures.

This change means a lot of timings for the CSK rollover tests
need to be adjusted.

The keymgr code needs a slight change on calculating the
prepublication time: For a KSK we need to include the parent
registration delay, but for CSK we look at the zone signing
property and stick with the ZSK prepublication calculation.

(cherry picked from commit e233433772)
2020-06-02 11:35:52 +02:00
Matthijs Mekking
437ec25c0c kasp: registration delay adjustments
Registration delay is not part of the Iret retire interval, thus
removed from the calculation when setting the Delete time metadata.

Include the registration delay in prepublication time, because
we need to prepublish the key sooner than just the Ipub
publication interval.

(cherry picked from commit 50bbbb76a8)
2020-06-02 11:35:32 +02:00
Matthijs Mekking
cad5ae1682 Set SyncPublish on keys
Set the SyncPublish metadata on keys that don't have them yet.

(cherry picked from commit 30cb5c97c2)
2020-06-02 11:34:57 +02:00
Matthijs Mekking
6879cdca77 Set keytimes appropriately when using kasp
While kasp relies on key states to determine when a key needs to
be published or be used for signing, the keytimes are used by
operators to get some expectation of key publication and usage.

Update the code such that these keytimes are set appropriately.
That means:
- Print "PublishCDS" and "DeleteCDS" times in the state files.
- The keymgr sets the "Removed" and "PublishCDS" times and derives
  those from the dnssec-policy.
- Tweak setting of the "Retired" time, when retiring keys, only
  update the time to now when the retire time is not yet set, or is
  in the future.

This also fixes a bug in "keymgr_transition_time" where we may wait
too long before zone signatrues become omnipresent or hidden. Not
only can we skip waiting the sign delay Dsgn if there is no
predecessor, we can also skip it if there is no successor.

Finally, this commit moves setting the lifetime, reducing two calls
to one.

(cherry picked from commit 18dc27afd3)
2020-06-02 11:34:04 +02:00
Evan Hunt
b580eb2fb3 add support for building sphinx documentation 2020-06-01 09:54:46 +02:00
Witold Kręcicki
3461aab083 Clear sock->magic to 0 when destroying a netmgr socket
(cherry picked from commit 7ef756f639)
2020-05-30 07:50:30 +02:00
Witold Kręcicki
4ceddeee78 Add missing isc_mutex_destroy and isc_conditional_destroy calls.
While harmless on Linux, missing isc_{mutex,conditional}_destroy
causes a memory leak on *BSD. Missing calls were added.

(cherry picked from commit a8807d9a7b)
2020-05-30 07:50:30 +02:00
Mark Andrews
69c43a03d0 Ensure tree lock is always held when dns_rbt_fullnamefromnode is called
(cherry picked from commit eded3efb79)
2020-05-29 15:02:09 -07:00
Evan Hunt
8b154d0f9f pass the nodename to add32() instead of calling dns_rbt_fullnamefromnode()
in addition to being more efficient, this prevents a possible crash by
looking up the node name before the tree sructure can be changed when
cleaning up dead nodes in addrdataset().

(cherry picked from commit db9d10e3c1)
2020-05-29 15:02:09 -07:00
Evan Hunt
c19a593d3e change "expr == false" to "!expr" in conditionals
(cherry picked from commit 57e54c46e4)
2020-05-25 17:04:04 -07:00
Evan Hunt
00c816778d change 'expr == true' to 'expr' in conditionals
(cherry picked from commit 68a1c9d679)
2020-05-25 17:03:59 -07:00
Mark Andrews
4df013f0ea Extend loop count by 1 to account for non-exact timing in usleep().
(cherry picked from commit 3012e1ad9b)
2020-05-21 14:09:42 +10:00
Michał Kępień
e67d247ee7 Adjust library API versions 2020-05-19 13:57:37 +02:00
Tinderbox User
046f56f5ab prep 9.16.3 2020-05-19 13:57:36 +02:00
Mark Andrews
39bb741927 Count queries to the root and TLD servers as well 2020-05-19 13:57:07 +02:00
Mark Andrews
b9c4f1b648 Reduce the number of fetches we make when looking up addresses
If there are more that 5 NS record for a zone only perform a
maximum of 4 address lookups for all the name servers.  This
limits the amount of remote lookup performed for server
addresses at each level for a given query.
2020-05-19 13:57:07 +02:00
Mark Andrews
baa7ec24e2 Only look at tsig.error in responses 2020-05-19 13:57:07 +02:00
Mark Andrews
89c1bc58e4 move provide-ixfr testing after the serial has been checked
(cherry picked from commit c7cdc47cc5)
2020-05-15 14:29:12 +10:00
Mark Andrews
c13fb2c67f Also print out valid printable utf8
(cherry picked from commit 1c8f9d06e2)
2020-05-13 10:26:39 +10:00
Mark Andrews
eed4fab37b Report Extended DNS Error codes
(cherry picked from commit b144ae1bb0)
2020-05-13 10:26:39 +10:00
Evan Hunt
1ccfadefe0 don't bother checking for empty nodes when searching the NSEC3 tree
this avoids a time-wasting search that could occur during an
IXFR that replaced an NSEC3 chain.

(cherry picked from commit 7192edf9c2)
2020-05-12 13:36:55 -07:00
Ondřej Surý
af1b56240f Resolve the overlinking of the system libraries
Originally, every library and binaries got linked to everything, which
creates unnecessary overlinking.  This wasn't as straightforward as it
should be as we still support configuration without libtool for 9.16.

Couple of smaller issues related to include headers and an issue where
sanitizer overload dlopen and dlclose symbols, so we were getting false
negatives in the autoconf test.
2020-05-11 09:49:54 +02:00
Ondřej Surý
b75778042f libns and libirs were underlinked (missing libisc, libdns, libisccfg)
Underlinking states for the situation when a binary uses a symbol not provided
by libraries it is directly linked to.  The libns was not linked to libisc and
libdns, and libirs was not linked to libisc, libdns and libisccfg) while using
symbols from these libraries directly.
2020-05-11 09:49:53 +02:00
Evan Hunt
a654989716 initialize sockaddrdscp to prevent spurious output from 'named-checkconf -p'
(cherry picked from commit f8d753d452)
2020-05-06 12:42:11 -07:00
Witold Kręcicki
444a16bff9 Don't set UDP recv/send buffer sizes - use system defaults (unless explicitly defined)
(cherry picked from commit fa02f6438b)
2020-05-01 17:47:19 +02:00
Ondřej Surý
c56cd29bbb Use SO_REUSEPORT only on Linux, use SO_REUSEPORT_LB on FreeBSD
The SO_REUSEPORT socket option on Linux means something else on BSD
based systems.  On FreeBSD there's 1:1 option SO_REUSEPORT_LB, so we can
use that.

(cherry picked from commit 09ba47b067)
2020-05-01 16:50:06 +02:00