]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
5 years agoFix the clang 12 warnings with multi-line strings in string arrays
Ondřej Surý [Wed, 16 Sep 2020 08:33:01 +0000 (10:33 +0200)] 
Fix the clang 12 warnings with multi-line strings in string arrays

The clang 12 has a new warning that warns when using multi-line strings
in the string arrays, f.e.:

    { "aa",
      "b"
      "b",
      "cc" }

would generate warning like this:

    private_test.c:162:7: error: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Werror,-Wstring-concatenation]
                                      "33333/RSASHA1" };
                                      ^
    private_test.c:161:7: note: place parentheses around the string literal to silence warning
                                      "Done removing signatures for key "
                                      ^
    private_test.c:197:7: error: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Werror,-Wstring-concatenation]
                                      "NSEC chain",
                                      ^
    private_test.c:196:7: note: place parentheses around the string literal to silence warning
                                      "Removing NSEC3 chain 1 0 30 DEAF / creating "
                                      ^
    2 errors generated.

(cherry picked from commit 7b07f22969149ceb24ad9491696fabb66c333524)

5 years agoMerge branch 'ondrej/cherry-picked-netmgr-v9_16' into 'v9_16'
Ondřej Surý [Thu, 1 Oct 2020 16:30:38 +0000 (16:30 +0000)] 
Merge branch 'ondrej/cherry-picked-netmgr-v9_16' into 'v9_16'

Synchronize the netmgr changes with main branch

See merge request isc-projects/bind9!4211

5 years agoAdd separate prefetch nmhandle to ns_client_t
Ondřej Surý [Tue, 15 Sep 2020 10:55:03 +0000 (12:55 +0200)] 
Add separate prefetch nmhandle to ns_client_t

As the query_prefetch() or query_rpzfetch() could be called during
"regular" fetch, we need to introduce separate storage for attaching
the nmhandle during prefetching the records.  The query_prefetch()
and query_rpzfetch() are guarded for re-entrance by .query.prefetch
member of ns_client_t, so we can reuse the same .prefetchhandle for
both.

(cherry picked from commit d4976e0ebeb6a29a6844d83bcd4be626fb9f8fbf)

5 years agoCHANGES
Evan Hunt [Thu, 3 Sep 2020 22:44:33 +0000 (15:44 -0700)] 
CHANGES

(cherry picked from commit e460e321bd9d1789bdd8b1e79272e7001337a97c)

5 years agofix LD_WRAP test in configure
Evan Hunt [Sat, 5 Sep 2020 19:10:35 +0000 (12:10 -0700)] 
fix LD_WRAP test in configure

The LD_WRAP test in configure was broken, and failed to
indicate LD_WRAP support correctly, resulting in some unit
tests failing to run.

(cherry picked from commit cfa4ea64bc06685f210a4187dcc05cc0aac84851)

5 years agoRefactor the pausing/unpausing and finishing the nm_thread
Ondřej Surý [Wed, 23 Sep 2020 19:49:46 +0000 (21:49 +0200)] 
Refactor the pausing/unpausing and finishing the nm_thread

The isc_nm_pause(), isc_nm_resume() and finishing the nm_thread() from
nm_destroy() has been refactored, so all use the netievents instead of
directly touching the worker structure members.  This allows us to
remove most of the locking as the .paused and .finished members are
always accessed from the matching nm_thread.

When shutting down the nm_thread(), instead of issuing uv_stop(), we
just shutdown the .async handler, so all uv_loop_t events are properly
finished first and uv_run() ends gracefully with no outstanding active
handles in the loop.

(cherry picked from commit e5ab137ba3181d7dbf761843d06027822e5b9683)

5 years agotracing of active sockets and handles
Witold Kręcicki [Wed, 2 Sep 2020 15:57:44 +0000 (17:57 +0200)] 
tracing of active sockets and handles

If NETMGR_TRACE is defined, we now maintain a list of active sockets
in the netmgr object and a list of active handles in each socket
object; by walking the list and printing `backtrace` in a debugger
we can see where they were created, to assist in in debugging of
reference counting errors.

On shutdown, if netmgr finds there are still active sockets after
waiting, isc__nm_dump_active() will be called to log the list of
active sockets and their underlying handles, along with some details
about them.

(cherry picked from commit 00e04a86c8b6828a066573031cc539adab565061)

5 years agolimit the time we wait for netmgr to be destroyed
Evan Hunt [Thu, 16 Jul 2020 00:57:58 +0000 (17:57 -0700)] 
limit the time we wait for netmgr to be destroyed

if more than 10 seconds pass while we wait for netmgr events to
finish running on shutdown, something is almost certainly wrong
and we should assert and crash.

(cherry picked from commit 2f2d60a9898faeeb8e9c8d7b80061d7e7845687c)

5 years agoadd more logging to the shutdown system test
Evan Hunt [Thu, 16 Jul 2020 22:47:58 +0000 (15:47 -0700)] 
add more logging to the shutdown system test

the test server running in shutdown/resolver was not logging
any debug info, which made it difficult to diagnose test failures.

(cherry picked from commit cc7ceace7dcaade77e7197e9ca2cd916edb7e51a)

5 years agoproperly lock the setting/unsetting of callbacks in isc_nmsocket_t
Ondřej Surý [Fri, 11 Sep 2020 08:53:31 +0000 (10:53 +0200)] 
properly lock the setting/unsetting of callbacks in isc_nmsocket_t

changes to socket callback functions were not thread safe.

(cherry picked from commit 89c534d3b9eddba5e2aaaaf54a5ff24bbe38257a)

5 years agochange from isc_nmhandle_ref/unref to isc_nmhandle attach/detach
Evan Hunt [Thu, 3 Sep 2020 20:31:27 +0000 (13:31 -0700)] 
change from isc_nmhandle_ref/unref to isc_nmhandle attach/detach

Attaching and detaching handle pointers will make it easier to
determine where and why reference counting errors have occurred.

A handle needs to be referenced more than once when multiple
asynchronous operations are in flight, so callers must now maintain
multiple handle pointers for each pending operation. For example,
ns_client objects now contain:

        - reqhandle:    held while waiting for a request callback (query,
                        notify, update)
        - sendhandle:   held while waiting for a send callback
        - fetchhandle:  held while waiting for a recursive fetch to
                        complete
        - updatehandle: held while waiting for an update-forwarding
                        task to complete

(cherry picked from commit 57b4dde9749c88d21d1dc8afd22201224cf83cab)

5 years agoassorted small netmgr-related changes
Witold Kręcicki [Wed, 10 Jun 2020 09:32:39 +0000 (11:32 +0200)] 
assorted small netmgr-related changes

- rename isc_nmsocket_t->tcphandle to statichandle
- cancelread functions now take handles instead of sockets
- add a 'client' flag in socket objects, currently unused, to
  indicate whether it is to be used as a client or server socket

(cherry picked from commit 7eb4564895037d72c46150acb6a8fc04edf4f8d9)

5 years agoUse different allocators for UDP and TCP
Evan Hunt [Thu, 2 Jul 2020 14:27:38 +0000 (16:27 +0200)] 
Use different allocators for UDP and TCP

Each worker has a receive buffer with space for 20 DNS messages of up
to 2^16 bytes each, and the allocator function passed to uv_read_start()
or uv_udp_recv_start() will reserve a portion of it for use by sockets.
UDP can use recvmmsg() and so it needs that entire space, but TCP reads
one message at a time.

This commit introduces separate allocator functions for TCP and UDP
setting different buffer size limits, so that libuv will provide the
correct buffer sizes to each of them.

(cherry picked from commit 38264b6a4d272dbbe948cf66eef9634041d14f98)

5 years agonetmgr: retry binding with IP_FREEBIND when EADDRNOTAVAIL is returned.
Witold Kręcicki [Tue, 21 Jul 2020 11:29:14 +0000 (13:29 +0200)] 
netmgr: retry binding with IP_FREEBIND when EADDRNOTAVAIL is returned.

When a new IPv6 interface/address appears it's first in a tentative
state - in which we cannot bind to it, yet it's already being reported
by the route socket. Because of that BIND9 is unable to listen on any
newly detected IPv6 addresses. Fix it by setting IP_FREEBIND option (or
equivalent option on other OSes) and then retrying bind() call.

(cherry picked from commit a0f7d28967f95c904614bbe44efde789e430a80e)

5 years agouse handles for isc_nm_pauseread() and isc_nm_resumeread()
Evan Hunt [Wed, 1 Jul 2020 23:17:09 +0000 (16:17 -0700)] 
use handles for isc_nm_pauseread() and isc_nm_resumeread()

by having these functions act on netmgr handles instead of socket
objects, they can be used in callback functions outside the netgmr.

(cherry picked from commit 55896df79d9f537577834375cb21676e8176b5ed)

5 years agodon't use exclusive mode for rndc commands that don't need it
Evan Hunt [Wed, 15 Apr 2020 21:37:47 +0000 (14:37 -0700)] 
don't use exclusive mode for rndc commands that don't need it

"showzone" and "tsig-list" both used exclusive mode unnecessarily;
changing this will simplify future refactoring a bit.

(cherry picked from commit 002c328437e7dbc59bbbc23d5bfea5bd6150bdc9)

5 years agoDon't destroy a non-closed socket, wait for all the callbacks.
Evan Hunt [Wed, 1 Jul 2020 07:49:12 +0000 (00:49 -0700)] 
Don't destroy a non-closed socket, wait for all the callbacks.

We erroneously tried to destroy a socket after issuing
isc__nm_tcp{,dns}_close. Under some (race) circumstances we could get
nm_socket_cleanup to be called twice for the same socket, causing an
access to a dead memory.

(cherry picked from commit 233f134a4ff806187925a106270a1f3794d5a1d5)

5 years agoFix possible race in isc__nm_tcpconnect.
Witold Kręcicki [Mon, 29 Jun 2020 06:43:54 +0000 (08:43 +0200)] 
Fix possible race in isc__nm_tcpconnect.

There's a possibility of race in isc__nm_tcpconnect if the asynchronous
connect operation finishes with all the callbacks before we exit the
isc__nm_tcpconnect itself we might access an already freed memory.
Fix it by creating an additional reference to the socket freed at the
end of isc__nm_tcpconnect.

(cherry picked from commit 896db0f41988f66bd06d6fa840b18be66a22200a)

5 years agoAdd missing libisc.def definitions, netmgr version of isc_sockettype_t.
Witold Kręcicki [Wed, 1 Jul 2020 10:25:35 +0000 (12:25 +0200)] 
Add missing libisc.def definitions, netmgr version of isc_sockettype_t.

(cherry picked from commit 25f84ffc688072a79ba11d6c89042a71e317a97f)

5 years agorestore "blackhole" functionality
Evan Hunt [Wed, 17 Jun 2020 19:09:10 +0000 (12:09 -0700)] 
restore "blackhole" functionality

the blackhole ACL was accidentally disabled with respect to client
queries during the netmgr conversion.

in order to make this work for TCP, it was necessary to add a return
code to the accept callback functions passed to isc_nm_listentcp() and
isc_nm_listentcpdns().

(cherry picked from commit 23c7373d68d2b5aca838aab2ebb16e1c9156ed60)

5 years agoupdate the acl system test to include a blackhole test case
Evan Hunt [Wed, 17 Jun 2020 22:30:59 +0000 (15:30 -0700)] 
update the acl system test to include a blackhole test case

this ACL was previously untested, which allowed a regression to
go undetected.

(cherry picked from commit e3ee138098897e0f53b2950dfe8a234543ec134e)

5 years agoMake netmgr tcpdns send calls asynchronous
Evan Hunt [Mon, 22 Jun 2020 23:45:47 +0000 (16:45 -0700)] 
Make netmgr tcpdns send calls asynchronous

isc__nm_tcpdns_send() was not asynchronous and accessed socket
internal fields in an unsafe manner, which could lead to a race
condition and subsequent crash. Fix it by moving tcpdns processing
to a proper netmgr thread.

(cherry picked from commit 591b79b597435766e474e5bac09cf3957d914ec3)

5 years agoFix a shutdown race in netmgr udp
Witold Kręcicki [Mon, 22 Jun 2020 22:46:11 +0000 (15:46 -0700)] 
Fix a shutdown race in netmgr udp

We need to mark the socket as inactive early (and synchronously)
in the stoplistening process; otherwise we might destroy the
callback argument before we actually stop listening, and call
the callback on bad memory.

(cherry picked from commit 1cf65cd8829f01cc38f47b1180d7fbe3ab710d35)

5 years agoclean up outerhandle when a tcpdns socket is disconnected
Evan Hunt [Sat, 20 Jun 2020 22:03:05 +0000 (15:03 -0700)] 
clean up outerhandle when a tcpdns socket is disconnected

this prevents a crash when some non-netmgr thread, such as a
recursive lookup, times out after the TCP socket is already
disconnected.

(cherry picked from commit 3704c4fff2757ade6dda56865aa87935d0c447b9)

5 years agochange the signature of recv callbacks to include a result code
Evan Hunt [Thu, 16 Apr 2020 02:26:49 +0000 (19:26 -0700)] 
change the signature of recv callbacks to include a result code

this will allow recv event handlers to distinguish between cases
in which the region is NULL because of error, shutdown, or cancelation.

(cherry picked from commit 75c985c07f2208d434977b27fe3eb41a433924d7)

5 years agoimplement isc_nm_cancelread()
Evan Hunt [Sat, 6 Jun 2020 00:32:36 +0000 (17:32 -0700)] 
implement isc_nm_cancelread()

The isc_nm_cancelread() function cancels reading on a connected
socket and calls its read callback function with a 'result'
parameter of ISC_R_CANCELED.

(cherry picked from commit 5191ec8f86717c0c709aff8971b26951ab5f7353)

5 years agoshorten the sleep in isc_nm_destroy()
Evan Hunt [Fri, 10 Apr 2020 23:59:24 +0000 (16:59 -0700)] 
shorten the sleep in isc_nm_destroy()

when isc_nm_destroy() is called, there's a loop that waits for
other references to be detached, pausing and unpausing the netmgr
to ensure that all the workers' events are run, followed by a
1-second sleep. this caused a delay on shutdown which will be
noticeable when netmgr is used in tools other than named itself,
so the delay has now been reduced to a hundredth of a second.

(cherry picked from commit 870204fe47b093b3a0ff43f6f20696c63b9582d5)

5 years agoimplement isc_nm_tcpconnect()
Evan Hunt [Tue, 17 Dec 2019 02:24:55 +0000 (18:24 -0800)] 
implement isc_nm_tcpconnect()

the isc_nm_tcpconnect() function establishes a client connection via
TCP.  once the connection is esablished, a callback function will be
called with a newly created network manager handle.

(cherry picked from commit abbb79f9d18d3313973e214b7118a6436ff47063)

5 years agoallow tcpdns sockets to self-reference while connected
Witold Kręcicki [Wed, 10 Jun 2020 00:07:16 +0000 (17:07 -0700)] 
allow tcpdns sockets to self-reference while connected

A TCPDNS socket creates a handle for each complete DNS message.

Previously, when all the handles were disconnected, the socket
would be closed, but the wrapped TCP socket might still have
more to read.

Now, when a connection is established, the TCPDNS socket creates
a reference to itself by attaching itself to sock->self. This
reference isn't cleared until the connection is closed via
EOF, timeout, or server shutdown. This allows the socket to remain
open even when there are no active handles for it.

(cherry picked from commit cd79b4953800daf87b6bfcea0b6f3ce3bec29988)

5 years agomodify reference counting within netmgr
Evan Hunt [Fri, 5 Jun 2020 06:13:54 +0000 (23:13 -0700)] 
modify reference counting within netmgr

- isc__nmhandle_get() now attaches to the sock in the nmhandle object.
  the caller is responsible for dereferencing the original socket
  pointer when necessary.
- tcpdns listener sockets attach sock->outer to the outer tcp listener
  socket. tcpdns connected sockets attach sock->outerhandle to the handle
  for the tcp connected socket.
- only listener sockets need to be attached/detached directly. connected
  sockets should only be accessed and reference-counted via their
  associated handles.

(cherry picked from commit 5ea26ee1f11e2e3d294e9e92bc4810f7c525727a)

5 years agomake isc_nmsocket_{attach,detach}{} functions private
Evan Hunt [Thu, 4 Jun 2020 21:54:36 +0000 (14:54 -0700)] 
make isc_nmsocket_{attach,detach}{} functions private

there is no need for a caller to reference-count socket objects.
they need tto be able tto close listener sockets (i.e., those
returned by isc_nm_listen{udp,tcp,tcpdns}), and an isc_nmsocket_close()
function has been added for that. other sockets are only accessed via
handles.

(cherry picked from commit 9e740cad21972194c063f9e471a7ba7d910ee01f)

5 years agoRevert the tree to allow cherry-picking netmgr changes from main
Ondřej Surý [Thu, 1 Oct 2020 12:58:39 +0000 (14:58 +0200)] 
Revert the tree to allow cherry-picking netmgr changes from main

The following reverted changes will be picked again as part of the
netmgr sync with main branch.

Revert "Merge branch '1996-confidential-issue-v9_16' into 'security-v9_16'"

This reverts commit e160b1509fd5027db283617baec2f7c616ba381a, reversing
changes made to c01e6437155e14fbed37e19c2bd7c49ae366c0ac.

Revert "Merge branch '2038-use-freebind-when-bind-fails-v9_16' into 'v9_16'"

This reverts commit 5f8ecfb9182e9bcd706e33fe78e247690c5bd65c, reversing
changes made to 23021385d5453807a741d31ed75627f9bf90a93d.

Revert "Merge branch '1936-blackhole-fix-v9_16' into 'v9_16'"

This reverts commit f20bc90a727bb100275197cac16da88f9795b946, reversing
changes made to 490016ebf126ea3d77261effb4c06791dc71b11d.

Revert "Merge branch '1938-fix-udp-race' into 'v9_16'"

This reverts commit 0a6c7ab2a960b2a9e418a9785869cad42e3451fd, reversing
changes made to 4ea84740e64f44ff1d397f1a317682633f174b0d.

Revert "Merge branch '1947-fix-tcpdns-race' into 'v9_16'"

This reverts commit 4ea84740e64f44ff1d397f1a317682633f174b0d, reversing
changes made to d761cd576bd61f6118341aa35edf4870f8775f8c.

5 years agoMerge branch '2112-allow-task_test-subtests-to-be-selected-at-runtime-v9_16' into...
Mark Andrews [Thu, 1 Oct 2020 13:15:11 +0000 (13:15 +0000)] 
Merge branch '2112-allow-task_test-subtests-to-be-selected-at-runtime-v9_16' into 'v9_16'

Resolve "Allow task_test subtests to be selected at runtime."

See merge request isc-projects/bind9!4209

5 years agoAdd the ability select individual tests to rdata_test
Mark Andrews [Fri, 11 Sep 2020 04:17:36 +0000 (14:17 +1000)] 
Add the ability select individual tests to rdata_test

(cherry picked from commit 6293682020472e66a92094b57475a6b13ca1fa77)

5 years agoAdd the ability to print out the list of test names (-l)
Mark Andrews [Tue, 8 Sep 2020 00:38:24 +0000 (10:38 +1000)] 
Add the ability to print out the list of test names (-l)

(cherry picked from commit a9c337471767b75861557c93b4fd7fff66227de0)

5 years agoAdd the ability to select tests to run
Mark Andrews [Wed, 2 Sep 2020 08:22:21 +0000 (18:22 +1000)] 
Add the ability to select tests to run

task_test [-t <test_name>]

(cherry picked from commit 76837484e7d6f9a70c8217f9bd7f5aa1784fe353)

5 years agoAlphabetise tests
Mark Andrews [Fri, 11 Sep 2020 03:37:56 +0000 (13:37 +1000)] 
Alphabetise tests

(cherry picked from commit 96febe6b38092ab02f9fa734af8a95dd34b09d1c)

5 years agoMerge branch '2191-missing-locks-when-accessing-keynode-initial-and-keynode-managed...
Mark Andrews [Thu, 1 Oct 2020 08:34:49 +0000 (08:34 +0000)] 
Merge branch '2191-missing-locks-when-accessing-keynode-initial-and-keynode-managed-triggering-tsan-v9_16' into 'v9_16'

Add missing rwlock calls when access keynode.initial and keynode.managed

See merge request isc-projects/bind9!4207

5 years agoAdd missing rwlock calls when access keynode.initial and keynode.managed
Mark Andrews [Thu, 1 Oct 2020 00:39:49 +0000 (10:39 +1000)] 
Add missing rwlock calls when access keynode.initial and keynode.managed

    WARNING: ThreadSanitizer: data race
    Write of size 1 at 0x000000000001 by thread T1 (mutexes: write M1):
    #0 dns_keynode_trust lib/dns/keytable.c:836
    #1 keyfetch_done lib/dns/zone.c:10187
    #2 dispatch lib/isc/task.c:1152
    #3 run lib/isc/task.c:1344
    #4 <null> <null>

    Previous read of size 1 at 0x000000000001 by thread T2 (mutexes: read M2):
    #0 keynode_dslist_totext lib/dns/keytable.c:682
    #1 dns_keytable_totext lib/dns/keytable.c:732
    #2 named_server_dumpsecroots bin/named/server.c:11357
    #3 named_control_docommand bin/named/control.c:264
    #4 control_command bin/named/controlconf.c:390
    #5 dispatch lib/isc/task.c:1152
    #6 run lib/isc/task.c:1344
    #7 <null> <null>

    Location is heap block of size 241 at 0x000000000010 allocated by thread T3:
    #0 malloc <null>
    #1 default_memalloc lib/isc/mem.c:713
    #2 mem_get lib/isc/mem.c:622
    #3 mem_allocateunlocked lib/isc/mem.c:1268
    #4 isc___mem_allocate lib/isc/mem.c:1288
    #5 isc__mem_allocate lib/isc/mem.c:2453
    #6 isc___mem_get lib/isc/mem.c:1037
    #7 isc__mem_get lib/isc/mem.c:2432
    #8 new_keynode lib/dns/keytable.c:346
    #9 insert lib/dns/keytable.c:393
    #10 dns_keytable_add lib/dns/keytable.c:421
    #11 process_key bin/named/server.c:955
    #12 load_view_keys bin/named/server.c:983
    #13 configure_view_dnsseckeys bin/named/server.c:1140
    #14 configure_view bin/named/server.c:5371
    #15 load_configuration bin/named/server.c:9110
    #16 loadconfig bin/named/server.c:10310
    #17 named_server_reconfigcommand bin/named/server.c:10693
    #18 named_control_docommand bin/named/control.c:250
    #19 control_command bin/named/controlconf.c:390
    #20 dispatch lib/isc/task.c:1152
    #21 run lib/isc/task.c:1344
    #22 <null> <null>

    Mutex M1 is already destroyed.

    Mutex M2 is already destroyed.

    Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create pthreads/thread.c:73
    #2 isc_taskmgr_create lib/isc/task.c:1434
    #3 create_managers bin/named/main.c:915
    #4 setup bin/named/main.c:1223
    #5 main bin/named/main.c:1523

    Thread T2 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create pthreads/thread.c:73
    #2 isc_taskmgr_create lib/isc/task.c:1434
    #3 create_managers bin/named/main.c:915
    #4 setup bin/named/main.c:1223
    #5 main bin/named/main.c:1523

    Thread T3 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create pthreads/thread.c:73
    #2 isc_taskmgr_create lib/isc/task.c:1434
    #3 create_managers bin/named/main.c:915
    #4 setup bin/named/main.c:1223
    #5 main bin/named/main.c:1523

    SUMMARY: ThreadSanitizer: data race lib/dns/keytable.c:836 in dns_keynode_trust

(cherry picked from commit 840cf7adb3ccc9f95fa0b36c1b3af3800af520c1)

5 years agoMerge branch 'ondrej/remove-dot-at-start-of-the-line-rst-v9_16' into 'v9_16'
Ondřej Surý [Wed, 30 Sep 2020 20:56:36 +0000 (20:56 +0000)] 
Merge branch 'ondrej/remove-dot-at-start-of-the-line-rst-v9_16' into 'v9_16'

Remove the .key from the beginning of the line in rst file

See merge request isc-projects/bind9!4204

5 years agoRegenerate couple of generated files
Ondřej Surý [Wed, 30 Sep 2020 20:14:39 +0000 (22:14 +0200)] 
Regenerate couple of generated files

5 years agoRemove the .key from the beginning of the line in rst file
Ondřej Surý [Wed, 30 Sep 2020 19:12:15 +0000 (21:12 +0200)] 
Remove the .key from the beginning of the line in rst file

The handling of . (dot) characted at the beginning of the line has
changed between the sphinx-doc versions, and it was constantly giving us
trouble when generating man pages when using different sphinx-doc.  This
commit just changes the source rst file, so there's no more . (dot) the
beginning of the line.

(cherry picked from commit a00ca65ae6d186fac4268b5b2d7964d96b404ce0)

5 years agoMerge branch '2180-threadsanitizer-data-race-bin-named-server-c-9678-25-in-view_loade...
Mark Andrews [Wed, 30 Sep 2020 15:03:25 +0000 (15:03 +0000)] 
Merge branch '2180-threadsanitizer-data-race-bin-named-server-c-9678-25-in-view_loaded-v9_16' into 'v9_16'

make (named_server_t).reload_status atomic

See merge request isc-projects/bind9!4202

5 years agomake (named_server_t).reload_status atomic
Mark Andrews [Tue, 22 Sep 2020 23:37:35 +0000 (09:37 +1000)] 
make (named_server_t).reload_status atomic

    WARNING: ThreadSanitizer: data race
    Write of size 4 at 0x000000000001 by thread T1:
    #0 view_loaded bin/named/server.c:9678:25
    #1 call_loaddone lib/dns/zt.c:308:3
    #2 doneloading lib/dns/zt.c:582:3
    #3 zone_asyncload lib/dns/zone.c:2322:3
    #4 dispatch lib/isc/task.c:1152:7
    #5 run lib/isc/task.c:1344:2

    Previous read of size 4 at 0x000000000001 by thread T2:
    #0 named_server_status bin/named/server.c:11903:14
    #1 named_control_docommand bin/named/control.c:272:12
    #2 control_command bin/named/controlconf.c:390:17
    #3 dispatch lib/isc/task.c:1152:7
    #4 run lib/isc/task.c:1344:2

    Location is heap block of size 409 at 0x000000000011 allocated by main thread:
    #0 malloc <null>
    #1 default_memalloc lib/isc/mem.c:713:8
    #2 mem_get lib/isc/mem.c:622:8
    #3 mem_allocateunlocked lib/isc/mem.c:1268:8
    #4 isc___mem_allocate lib/isc/mem.c:1288:7
    #5 isc__mem_allocate lib/isc/mem.c:2453:10
    #6 isc___mem_get lib/isc/mem.c:1037:11
    #7 isc__mem_get lib/isc/mem.c:2432:10
    #8 named_server_create bin/named/server.c:9978:27
    #9 setup bin/named/main.c:1256:2
    #10 main bin/named/main.c:1523:2

    Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create lib/isc/pthreads/thread.c:73:8
    #2 isc_taskmgr_create lib/isc/task.c:1434:3
    #3 create_managers bin/named/main.c:915:11
    #4 setup bin/named/main.c:1223:11
    #5 main bin/named/main.c:1523:2

    Thread T2 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create lib/isc/pthreads/thread.c:73:8
    #2 isc_taskmgr_create lib/isc/task.c:1434:3
    #3 create_managers bin/named/main.c:915:11
    #4 setup bin/named/main.c:1223:11
    #5 main bin/named/main.c:1523:2

    SUMMARY: ThreadSanitizer: data race bin/named/server.c:9678:25 in view_loaded

(cherry picked from commit b00ba7ac94b11fb085ac262e8d6848ed9d5f8f97)

5 years agoMerge branch '2190-in-new-yaml-output-when-truncation-is-query-time-usec-v9_16' into...
Mark Andrews [Wed, 30 Sep 2020 14:30:24 +0000 (14:30 +0000)] 
Merge branch '2190-in-new-yaml-output-when-truncation-is-query-time-usec-v9_16' into 'v9_16'

Resolve "dig: "-u" (microsecond timestamp precision) does not work in YAML output mode"

See merge request isc-projects/bind9!4201

5 years agoadd CHANGES
Mark Andrews [Tue, 29 Sep 2020 05:02:24 +0000 (15:02 +1000)] 
add CHANGES

(cherry picked from commit b7512e87b1e3e1339c6816aceb1f3044a6db04fa)

5 years agoOutput timestamps in yaml to the microsecond if -u is specified.
Mark Andrews [Tue, 29 Sep 2020 04:59:40 +0000 (14:59 +1000)] 
Output timestamps in yaml to the microsecond if -u is specified.

(cherry picked from commit 3fe7fa3db2bcae8f8b622f5e19f4dbf4323bcd04)

5 years agoAdd ISO time stamps to the microsecond
Mark Andrews [Tue, 29 Sep 2020 04:58:56 +0000 (14:58 +1000)] 
Add ISO time stamps to the microsecond

(cherry picked from commit 519b070618050ca221779bc61cad4695e2d985e1)

5 years agoMerge branch '2124-fix-assertion-failure-in-dns-message-v9_16' into 'v9_16'
Ondřej Surý [Wed, 30 Sep 2020 12:53:35 +0000 (12:53 +0000)] 
Merge branch '2124-fix-assertion-failure-in-dns-message-v9_16' into 'v9_16'

Resolve "Bind 9.16.6 Assertion failure message.c:4733: REQUIRE(msg->state == (-1)) failed"

See merge request isc-projects/bind9!4196

5 years agoAdd CHANGES and release note for GL #2124
Ondřej Surý [Fri, 25 Sep 2020 10:51:39 +0000 (12:51 +0200)] 
Add CHANGES and release note for GL #2124

(cherry picked from commit 6179a3881059aeef851a19b09d598cc791eeda83)

5 years agoThe dns_message_create() cannot fail, change the return to void
Ondřej Surý [Fri, 25 Sep 2020 09:51:36 +0000 (11:51 +0200)] 
The dns_message_create() cannot fail, change the return to void

The dns_message_create() function cannot soft fail (as all memory
allocations either succeed or cause abort), so we change the function to
return void and cleanup the calls.

(cherry picked from commit 33eefe9f8565592c31d1ab086107c83733530f3f)

5 years agococci: Add semantic patch to refactor dns_message_destroy()
Diego Fronza [Mon, 21 Sep 2020 21:19:49 +0000 (18:19 -0300)] 
cocci: Add semantic patch to refactor dns_message_destroy()

dns_message_t objects are now being handled using reference counting
semantics, so now dns_message_destroy() is not called directly anymore,
dns_message_detach must be called instead.

(cherry picked from commit 7deaf9a93cba04460cacf453279ee87f0dc6d8cb)

5 years agoProperly handling dns_message_t shared references
Diego Fronza [Mon, 21 Sep 2020 20:44:29 +0000 (17:44 -0300)] 
Properly handling dns_message_t shared references

This commit fix the problems that arose when moving the dns_message_t
object from fetchctx_t to the query structure.

Since the lifetime of query objects are different than that of a
fetchctx and the dns_message_t object held by the query may be being
used by some external module, e.g. validator, even after the query
may have been destroyed, propery handling of the references to the
message were added in this commit to avoid accessing an already
destroyed object.

Specifically, in rctx_done(), a reference to the message is attached
at the beginning of the function and detached at the end, since a
possible call to fctx_cancelquery() would release the dns_message_t
object, and in the next lines of code a call to rctx_nextserver()
or rctx_chaseds() would require a valid pointer to the same object.

In valcreate() a new reference is attached to the message object,
this ensures that if the corresponding query object is destroyed
before the validator attempts to access it, no invalid pointer
access occurs.

In validated() we have to attach a new reference to the message,
since we destroy the validator object at the beginning of the
function, and we need access to the message in the next lines of
the same function.

rctx_nextserver() and rctx_chaseds() functions were adapted to
receive a new parameter of dns_message_t* type, this was so they
could receive a valid reference to a dns_message_t since using the
response context respctx_t to access the message through
rctx->query->rmessage could lead to an already released reference
due to the query being canceled.

(cherry picked from commit cde6227a6878d2fe161028d7ff684d1d0e4957d2)

5 years agoFix invalid dns message state in resolver's logic
Diego Fronza [Mon, 21 Sep 2020 20:32:39 +0000 (17:32 -0300)] 
Fix invalid dns message state in resolver's logic

The assertion failure REQUIRE(msg->state == DNS_SECTION_ANY), caused
by calling dns_message_setclass within function resquery_response()
in resolver.c, was happening due to wrong management of dns message_t
objects used to process responses to the queries issued by the
resolver.

Before the fix, a resolver's fetch context (fetchctx_t) would hold
a pointer to the message, this same reference would then be used
over all the attempts to resolve the query, trying next server,
etc... for this to work the message object would have it's state
reset between each iteration, marking it as ready for a new processing.

The problem arose in a scenario with many different forwarders
configured, managing the state of the dns_message_t object was
lacking better synchronization, which have led it to a invalid
dns_message_t state in resquery_response().

Instead of adding unnecessarily complex code to synchronize the
object, the dns_message_t object was moved from fetchctx_t structure
to the query structure, where it better belongs to, since each query
will produce a response, this way whenever a new query is created
an associated dns_messate_t is also created.

This commit deals mainly with moving the dns_message_t object from
fetchctx_t to the query structure.

(cherry picked from commit 02f9e125c15f3fbf7eedd760f0a5468845029c9c)

5 years agoRefactored dns_message_t for using attach/detach semantics
Diego Fronza [Mon, 21 Sep 2020 19:16:15 +0000 (16:16 -0300)] 
Refactored dns_message_t for using attach/detach semantics

This commit will be used as a base for the next code updates in
order to have a better control of dns_message_t objects' lifetime.

(cherry picked from commit 12d6d13100c9b5b39d75342727710fdadb7df52f)

5 years agoMerge branch '2189-some-comments-in-lib-dns-stats-c-use-incorrect-notation-for-bit...
Mark Andrews [Tue, 29 Sep 2020 00:41:59 +0000 (00:41 +0000)] 
Merge branch '2189-some-comments-in-lib-dns-stats-c-use-incorrect-notation-for-bit-values-v9_16' into 'v9_16'

Update comments to have binary notation

See merge request isc-projects/bind9!4192

5 years agoUpdate comments to have binary notation
Mark Andrews [Tue, 29 Sep 2020 00:36:07 +0000 (10:36 +1000)] 
Update comments to have binary notation

(cherry picked from commit 6727e23a479747c65da7d7e26c8b07510f2e7c6c)

5 years agoMerge branch '2177-make-native-pkcs11-require-dlopen-support' into 'v9_16'
Michał Kępień [Mon, 28 Sep 2020 07:23:12 +0000 (07:23 +0000)] 
Merge branch '2177-make-native-pkcs11-require-dlopen-support' into 'v9_16'

Make native PKCS#11 require dlopen() support

See merge request isc-projects/bind9!4177

5 years agoMake native PKCS#11 require dlopen() support
Michał Kępień [Mon, 28 Sep 2020 07:21:59 +0000 (09:21 +0200)] 
Make native PKCS#11 require dlopen() support

PKCS#11 support in BIND requires dlopen() support from the operating
system and thus building with "--enable-native-pkcs11 --without-dlopen"
should not be possible.  Add an Autoconf check which enforces that
constraint.  Adjust the pairwise testing model accordingly.

5 years agoMerge branch '1725-clean-up-use-of-function-wrapping' into 'v9_16'
Michał Kępień [Mon, 28 Sep 2020 07:20:05 +0000 (07:20 +0000)] 
Merge branch '1725-clean-up-use-of-function-wrapping' into 'v9_16'

Clean up use of function wrapping

See merge request isc-projects/bind9!4175

5 years agoFix function overrides in unit tests on macOS
Michał Kępień [Mon, 28 Sep 2020 07:16:48 +0000 (09:16 +0200)] 
Fix function overrides in unit tests on macOS

Since Mac OS X 10.1, Mach-O object files are by default built with a
so-called two-level namespace which prevents symbol lookups in BIND unit
tests that attempt to override the implementations of certain library
functions from working as intended.  This feature can be disabled by
passing the "-flat_namespace" flag to the linker.  Fix unit tests
affected by this issue on macOS by adding "-flat_namespace" to LDFLAGS
used for building all object files on that operating system (it is not
enough to only set that flag for the unit test executables).

5 years agoClean up use of function wrapping
Michał Kępień [Mon, 28 Sep 2020 07:16:48 +0000 (09:16 +0200)] 
Clean up use of function wrapping

Currently, building BIND using "--without-dlopen" universally breaks
building unit tests which employ the --wrap linker option (because the
replacement functions are put in a shared library and building shared
objects requires "--with-dlopen").  Fix by moving the overridden symbol,
isc_nmhandle_unref(), to lib/ns/tests/nstest.c and dropping
lib/ns/tests/wrap.c altogether.  This makes lib/ns/tests/Makefile.in
simpler and prevents --without-dlopen from messing with the process of
building unit tests.

Remove parts of configure.ac which are made redundant by the above
changes.

Put the replacement definition of isc_nmhandle_unref() inside an #ifdef
block, so that the build does not break for non-libtool builds (see
below).

These changes allow the broadest possible set of build variants to work
while also simplifying the build process:

  - for libtool builds, overriding isc_nmhandle_unref() is done by
    placing that symbol directly in lib/ns/tests/nstest.c and relying on
    the dynamic linker to perform symbol resolution in the expected way
    when the test binary is run,

  - for non-libtool builds, overriding isc_nmhandle_unref() is done
    using the --wrap linker option (the libtool approach cannot be used
    in this case as multiple strong symbols with the same name cannot
    coexist in the same binary),

  - the "--without-dlopen" option no longer affects building unit tests.

5 years agoMerge branch '2185-nsdname-wait-recurse-speed-test-fails-under-tsan-v9_16' into ...
Mark Andrews [Mon, 28 Sep 2020 04:14:38 +0000 (04:14 +0000)] 
Merge branch '2185-nsdname-wait-recurse-speed-test-fails-under-tsan-v9_16' into 'v9_16'

Resolve "nsdname-wait-recurse speed test fails under tsan"

See merge request isc-projects/bind9!4188

5 years agoWait for 'rpz: policy: reload done' to signalled before proceeding.
Mark Andrews [Fri, 25 Sep 2020 07:42:41 +0000 (17:42 +1000)] 
Wait for 'rpz: policy: reload done' to signalled before proceeding.

RPZ rules cannot be fully relied upon until the summary RPZ database is
updated after an "rndc reload".  Wait until the relevant message is
logged after an "rndc reload" to prevent false positives in the
"rpzrecurse" system test caused by the RPZ rules not yet being in effect
by the time ns3 is queried.

(cherry picked from commit bdf8194af8855b0c5199ca49f3296e1160069a88)

5 years agoadd test markers to ns3 named.log
Mark Andrews [Thu, 24 Sep 2020 04:57:47 +0000 (14:57 +1000)] 
add test markers to ns3 named.log

(cherry picked from commit 22d10df0f0a94aa8db228fcd3693262b852ada68)

5 years agoMerge branch '1041-filter-aaaa-purge-memory-pool-upon-plugin-destruction-v9_16' into...
Evan Hunt [Fri, 25 Sep 2020 22:42:10 +0000 (22:42 +0000)] 
Merge branch '1041-filter-aaaa-purge-memory-pool-upon-plugin-destruction-v9_16' into 'v9_16'

Resolve "crash in 9.14.2, possibly on shutdown, cannot reproduce"

See merge request isc-projects/bind9!4187

5 years agoAdd CHANGES entry
Michał Kępień [Wed, 22 May 2019 08:58:41 +0000 (10:58 +0200)] 
Add CHANGES entry

5238. [bug] filter-aaaa: named crashed upon shutdown if it was in
the process of recursing for A RRsets. [GL #1040]

(cherry picked from commit 555e1f446c69092cd4d0a26c99387925b6e6e655)

5 years agoPurge memory pool upon plugin destruction
Evan Hunt [Wed, 22 May 2019 08:58:41 +0000 (10:58 +0200)] 
Purge memory pool upon plugin destruction

The typical sequence of events for AAAA queries which trigger recursion
for an A RRset at the same name is as follows:

 1. Original query context is created.
 2. An AAAA RRset is found in cache.
 3. Client-specific data is allocated from the filter-aaaa memory pool.
 4. Recursion is triggered for an A RRset.
 5. Original query context is torn down.

 6. Recursion for an A RRset completes.
 7. A second query context is created.
 8. Client-specific data is retrieved from the filter-aaaa memory pool.
 9. The response to be sent is processed according to configuration.
10. The response is sent.
11. Client-specific data is returned to the filter-aaaa memory pool.
12. The second query context is torn down.

However, steps 6-12 are not executed if recursion for an A RRset is
canceled.  Thus, if named is in the process of recursing for A RRsets
when a shutdown is requested, the filter-aaaa memory pool will have
outstanding allocations which will never get released.  This in turn
leads to a crash since every memory pool must not have any outstanding
allocations by the time isc_mempool_destroy() is called.

Fix by creating a stub query context whenever fetch_callback() is called,
including cancellation events. When the qctx is destroyed, it will ensure
the client is detached and the plugin memory is freed.

(cherry picked from commit 86eddebc836e82a993db2e5a1b13dccaa5b51614)

5 years agoMerge branch '1870-rndc-dumpdb-expired-v9_16' into 'v9_16'
Matthijs Mekking [Fri, 25 Sep 2020 06:46:15 +0000 (06:46 +0000)] 
Merge branch '1870-rndc-dumpdb-expired-v9_16' into 'v9_16'

Resolve "[Support#12071] [RT#46548] Output stale/expired data with 'rndc dumpdb'"

See merge request isc-projects/bind9!4186

5 years agorndc dumpdb -expired: print when RRsets expired
Matthijs Mekking [Tue, 22 Sep 2020 14:09:44 +0000 (16:09 +0200)] 
rndc dumpdb -expired: print when RRsets expired

When calling 'rndc dumpdb -expired', also print when the RRset expired.

(cherry picked from commit d14c2d0d7362da2898452d22fcd9779e2f6f70b0)

5 years agoAdd notes and CHANGES for #1870
Matthijs Mekking [Wed, 9 Sep 2020 09:23:28 +0000 (11:23 +0200)] 
Add notes and CHANGES for #1870

This is a new features so it requires a CHANGE and release notes entry.

(cherry picked from commit 1728599684fc077e6ac7d95eb388682e860f48b7)

5 years agoHandle ancient rrsets in bind_rdataset
Matthijs Mekking [Thu, 3 Sep 2020 13:10:28 +0000 (15:10 +0200)] 
Handle ancient rrsets in bind_rdataset

An ancient RRset is one still in the cache but expired, and awaiting
cleanup.

(cherry picked from commit 388cc666e51b90d46c4bcd8cb70d14196c923292)

5 years agoInclude expired rdatasets in iteration functions
Matthijs Mekking [Thu, 13 Aug 2020 05:47:27 +0000 (07:47 +0200)] 
Include expired rdatasets in iteration functions

By changing the check in 'rdatasetiter_first' and 'rdatasetiter_next'
from "now > header->rdh_ttl" to "now - RBDTB_VIRTUAL > header->rdh_ttl"
we include expired rdataset entries so that they can be used for
"rndc dumpdb -expired".

(cherry picked from commit 17d5bd4493d44b4b678ccf98a47c1a4ab928aea8)

5 years agoAdd test for 'rdnc dumpdb -expired'
Matthijs Mekking [Thu, 13 Aug 2020 06:03:05 +0000 (08:03 +0200)] 
Add test for 'rdnc dumpdb -expired'

This test makes sure that expired records are dumped with rndc's
'dumpdb' command if the '-expired' flag is used.

(cherry picked from commit 1c3e6f404538d24273d8f9c207e6af9ec3d45091)

5 years agoMinor changes to serve-stale tests
Matthijs Mekking [Thu, 13 Aug 2020 05:58:42 +0000 (07:58 +0200)] 
Minor changes to serve-stale tests

Minor changes are:
- Replace the "$RNDCCMD dumpdb" logic with "rndc_dumpdb" from
  conf.sh.common (it does the same thing).
- Update a comment to match the grep calls below it (comment said the
  rest should be expired, while the grep calls indicate that they
  are still in the cache, the comment now explains why).

(cherry picked from commit 86a1bbfe2893a76c72320dfd6c924a460468a5ee)

5 years agoAdd -expired flag to rndc dumpdb command
Matthijs Mekking [Thu, 13 Aug 2020 05:42:36 +0000 (07:42 +0200)] 
Add -expired flag to rndc dumpdb command

This flag is the same as -cache, but will use a different style format
that will also print expired entries (awaiting cleanup) from the cache.

(cherry picked from commit 8beda7d2ea1b37361eecd35830e4745df1d42d53)

5 years agoMerge branch '2184-add-rfc8096-to-list-of-rfcs-in-doc-general-rst-v9_16' into 'v9_16'
Mark Andrews [Thu, 24 Sep 2020 01:02:31 +0000 (01:02 +0000)] 
Merge branch '2184-add-rfc8096-to-list-of-rfcs-in-doc-general-rst-v9_16' into 'v9_16'

Resolve "Add RFC8906 to list of RFCs in doc/arm/general.rst"

See merge request isc-projects/bind9!4182

5 years agoAccidentally wrote RFC8096 instead of 8906
Suzanne Goldlust [Wed, 23 Sep 2020 19:41:58 +0000 (19:41 +0000)] 
Accidentally wrote RFC8096 instead of 8906

(cherry picked from commit bc604793d3b0ae3ba40700edbb361e5795eeeaf3)

5 years agoAdd RFC8096 to list in doc/arm/general.rst
Suzanne Goldlust [Wed, 23 Sep 2020 19:34:42 +0000 (19:34 +0000)] 
Add RFC8096 to list in doc/arm/general.rst

(cherry picked from commit 4c36b6bdf04391bddcd69def47ad96c24b17c8b0)

5 years agoMerge branch 'marka-filter-aaaa-prereq-tsan-v9_16' into 'v9_16'
Mark Andrews [Wed, 23 Sep 2020 05:51:12 +0000 (05:51 +0000)] 
Merge branch 'marka-filter-aaaa-prereq-tsan-v9_16' into 'v9_16'

filter-aaaa add prereq test for tsan [v9_16]

See merge request isc-projects/bind9!4173

5 years agotest whether we are running under tsan
Mark Andrews [Wed, 23 Sep 2020 05:15:20 +0000 (15:15 +1000)] 
test whether we are running under tsan

5 years agoMerge branch '2162-threadsanitizer-data-race-in-epoll_ctl-v9_16' into 'v9_16'
Mark Andrews [Wed, 23 Sep 2020 05:16:12 +0000 (05:16 +0000)] 
Merge branch '2162-threadsanitizer-data-race-in-epoll_ctl-v9_16' into 'v9_16'

It appears that you can't change what you are polling for while connecting.

See merge request isc-projects/bind9!4172

5 years agoIt appears that you can't change what you are polling for while connecting.
Mark Andrews [Wed, 23 Sep 2020 03:54:06 +0000 (13:54 +1000)] 
It appears that you can't change what you are polling for while connecting.

    WARNING: ThreadSanitizer: data race
    Read of size 8 at 0x000000000001 by thread T1 (mutexes: write M1):
    #0 epoll_ctl <null>
    #1 watch_fd lib/isc/unix/socket.c:704:8
    #2 wakeup_socket lib/isc/unix/socket.c:897:11
    #3 process_ctlfd lib/isc/unix/socket.c:3362:3
    #4 process_fds lib/isc/unix/socket.c:3275:10
    #5 netthread lib/isc/unix/socket.c:3516:10

    Previous write of size 8 at 0x000000000001 by thread T2 (mutexes: write M2):
    #0 connect <null>
    #1 isc_socket_connect lib/isc/unix/socket.c:4737:7
    #2 resquery_send lib/dns/resolver.c:2892:13
    #3 fctx_query lib/dns/resolver.c:2202:12
    #4 fctx_try lib/dns/resolver.c:4300:11
    #5 resquery_connected lib/dns/resolver.c:3130:4
    #6 dispatch lib/isc/task.c:1152:7
    #7 run lib/isc/task.c:1344:2

    Location is file descriptor 513 created by thread T2 at:
    #0 connect <null>
    #1 isc_socket_connect lib/isc/unix/socket.c:4737:7
    #2 resquery_send lib/dns/resolver.c:2892:13
    #3 fctx_query lib/dns/resolver.c:2202:12
    #4 fctx_try lib/dns/resolver.c:4300:11
    #5 resquery_connected lib/dns/resolver.c:3130:4
    #6 dispatch lib/isc/task.c:1152:7
    #7 run lib/isc/task.c:1344:2

    Mutex M1 (0x000000000016) created at:
    #0 pthread_mutex_init <null>
    #1 isc__mutex_init lib/isc/pthreads/mutex.c:288:8
    #2 setup_thread lib/isc/unix/socket.c:3584:3
    #3 isc_socketmgr_create2 lib/isc/unix/socket.c:3825:3
    #4 create_managers bin/named/main.c:932:11
    #5 setup bin/named/main.c:1223:11
    #6 main bin/named/main.c:1523:2

    Mutex M2 is already destroyed.

    Thread T1 'isc-socket-1' (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create lib/isc/pthreads/thread.c:73:8
    #2 isc_socketmgr_create2 lib/isc/unix/socket.c:3826:3
    #3 create_managers bin/named/main.c:932:11
    #4 setup bin/named/main.c:1223:11
    #5 main bin/named/main.c:1523:2

    Thread T2 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create lib/isc/pthreads/thread.c:73:8
    #2 isc_taskmgr_create lib/isc/task.c:1434:3
    #3 create_managers bin/named/main.c:915:11
    #4 setup bin/named/main.c:1223:11
    #5 main bin/named/main.c:1523:2

    SUMMARY: ThreadSanitizer: data race in epoll_ctl

(cherry picked from commit c37b251eb98d673716ad1e9d80e6f4deeb23bdb9)

5 years agoMerge branch '2156-threadsanitizer-lock-order-inversion-potential-deadlock-in-pthread...
Mark Andrews [Wed, 23 Sep 2020 02:09:01 +0000 (02:09 +0000)] 
Merge branch '2156-threadsanitizer-lock-order-inversion-potential-deadlock-in-pthread_mutex_lock-v9_16' into 'v9_16'

Address lock order inversions.

See merge request isc-projects/bind9!4170

5 years agoAddress lock order inversions.
Mark Andrews [Mon, 21 Sep 2020 05:27:50 +0000 (15:27 +1000)] 
Address lock order inversions.

    WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock)
    Cycle in lock order graph: M1 (0x000000000000) => M2 (0x000000000000) => M1

    Mutex M2 acquired here while holding mutex M1 in thread T1:
    #0 pthread_mutex_lock <null>
    #1 dns_view_findzonecut lib/dns/view.c:1310:2
    #2 fctx_create lib/dns/resolver.c:5070:13
    #3 dns_resolver_createfetch lib/dns/resolver.c:10813:12
    #4 dns_resolver_prime lib/dns/resolver.c:10442:12
    #5 dns_view_find lib/dns/view.c:1176:4
    #6 dbfind_name lib/dns/adb.c:3833:11
    #7 dns_adb_createfind lib/dns/adb.c:3155:12
    #8 findname lib/dns/resolver.c:3497:11
    #9 fctx_getaddresses lib/dns/resolver.c:3808:3
    #10 fctx_try lib/dns/resolver.c:4197:12
    #11 fctx_start lib/dns/resolver.c:4824:4
    #12 dispatch lib/isc/task.c:1152:7
    #13 run lib/isc/task.c:1344:2

    Mutex M1 previously acquired by the same thread here:
    #0 pthread_mutex_lock <null>
    #1 dns_resolver_createfetch lib/dns/resolver.c:10767:2
    #2 dns_resolver_prime lib/dns/resolver.c:10442:12
    #3 dns_view_find lib/dns/view.c:1176:4
    #4 dbfind_name lib/dns/adb.c:3833:11
    #5 dns_adb_createfind lib/dns/adb.c:3155:12
    #6 findname lib/dns/resolver.c:3497:11
    #7 fctx_getaddresses lib/dns/resolver.c:3808:3
    #8 fctx_try lib/dns/resolver.c:4197:12
    #9 fctx_start lib/dns/resolver.c:4824:4
    #10 dispatch lib/isc/task.c:1152:7
    #11 run lib/isc/task.c:1344:2

    Mutex M1 acquired here while holding mutex M2 in thread T1:
    #0 pthread_mutex_lock <null>
    #1 dns_resolver_shutdown lib/dns/resolver.c:10530:4
    #2 view_flushanddetach lib/dns/view.c:632:4
    #3 dns_view_detach lib/dns/view.c:689:2
    #4 qctx_destroy lib/ns/query.c:5152:2
    #5 fetch_callback lib/ns/query.c:5749:3
    #6 dispatch lib/isc/task.c:1152:7
    #7 run lib/isc/task.c:1344:2

    Mutex M2 previously acquired by the same thread here:
    #0 pthread_mutex_lock <null>
    #1 view_flushanddetach lib/dns/view.c:630:3
    #2 dns_view_detach lib/dns/view.c:689:2
    #3 qctx_destroy lib/ns/query.c:5152:2
    #4 fetch_callback lib/ns/query.c:5749:3
    #5 dispatch lib/isc/task.c:1152:7
    #6 run lib/isc/task.c:1344:2

    Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create lib/isc/pthreads/thread.c:73:8
    #2 isc_taskmgr_create lib/isc/task.c:1434:3
    #3 create_managers bin/named/main.c:915:11
    #4 setup bin/named/main.c:1223:11
    #5 main bin/named/main.c:1523:2

    SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) in pthread_mutex_lock

(cherry picked from commit a669c919c8e8354c6390dfafddfa67c221aaabee)

5 years agoMerge branch '2109-sig0-computation-could-be-wrong-v9_16' into 'v9_16'
Mark Andrews [Wed, 23 Sep 2020 01:46:15 +0000 (01:46 +0000)] 
Merge branch '2109-sig0-computation-could-be-wrong-v9_16' into 'v9_16'

Resolve "kind of use-after-free condition in SIG(0) signing"

See merge request isc-projects/bind9!4169

5 years agoadd CHANGES note
Mark Andrews [Fri, 18 Sep 2020 07:19:19 +0000 (17:19 +1000)] 
add CHANGES note

(cherry picked from commit c7406db46f33628e160db2f54ab4737a76556bd7)

5 years agoClone the saved / query message buffers
Mark Andrews [Fri, 18 Sep 2020 05:00:35 +0000 (15:00 +1000)] 
Clone the saved / query message buffers

The message buffer passed to ns__client_request is only valid for
the life of the the ns__client_request call.  Save a copy of it
when we recurse or process a update as ns__client_request will
return before those operations complete.

(cherry picked from commit f0d9bf7c30a6a219039e19d0a6e61dca874c2294)

5 years agoMerge branch '2156-threadsanitizer-lock-order-inversion-potential-deadlock-in-pthread...
Mark Andrews [Tue, 22 Sep 2020 13:39:39 +0000 (13:39 +0000)] 
Merge branch '2156-threadsanitizer-lock-order-inversion-potential-deadlock-in-pthread_mutex_lock-2-v9_16' into 'v9_16'

Break lock order loop by sending TAT in an event

See merge request isc-projects/bind9!4165

5 years agoBreak lock order loop by sending TAT in an event
Mark Andrews [Tue, 22 Sep 2020 05:22:34 +0000 (15:22 +1000)] 
Break lock order loop by sending TAT in an event

The dotat() function has been changed to send the TAT
query asynchronously, so there's no lock order loop
because we initialize the data first and then we schedule
the TAT send to happen asynchronously.

This breaks following lock-order loops:

zone->lock (dns_zone_setviewcommit) while holding view->lock
(dns_view_setviewcommit)

keytable->lock (dns_keytable_find) while holding zone->lock
(zone_asyncload)

view->lock (dns_view_findzonecut) while holding keytable->lock
(dns_keytable_forall)

(cherry picked from commit 3c4b68af7c0cd8213bcae92faee3bf2a7e9284d1)

5 years agoMerge branch '2157-threadsanitizer-lock-order-inversion-potential-deadlock-in-pthread...
Mark Andrews [Tue, 22 Sep 2020 12:45:54 +0000 (12:45 +0000)] 
Merge branch '2157-threadsanitizer-lock-order-inversion-potential-deadlock-in-pthread_rwlock_wrlock-v9_16' into 'v9_16'

Address lock-order-inversion

See merge request isc-projects/bind9!4163

5 years agoAddress lock-order-inversion
Mark Andrews [Tue, 22 Sep 2020 06:24:06 +0000 (16:24 +1000)] 
Address lock-order-inversion

    WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock)
    Cycle in lock order graph: M1 (0x000000000001) => M2 (0x000000000002) => M1

    Mutex M2 acquired here while holding mutex M1 in thread T1:
    #0 pthread_rwlock_wrlock <null>
    #1 isc_rwlock_lock lib/isc/rwlock.c:52:4
    #2 zone_postload lib/dns/zone.c:5101:2
    #3 receive_secure_db lib/dns/zone.c:16206:11
    #4 dispatch lib/isc/task.c:1152:7
    #5 run lib/isc/task.c:1344:2

    Mutex M1 previously acquired by the same thread here:
    #0 pthread_mutex_lock <null>
    #1 receive_secure_db lib/dns/zone.c:16204:2
    #2 dispatch lib/isc/task.c:1152:7
    #3 run lib/isc/task.c:1344:2

    Mutex M1 acquired here while holding mutex M2 in thread T1:
    #0 pthread_mutex_lock <null>
    #1 get_raw_serial lib/dns/zone.c:2518:2
    #2 zone_gotwritehandle lib/dns/zone.c:2559:4
    #3 dispatch lib/isc/task.c:1152:7
    #4 run lib/isc/task.c:1344:2

    Mutex M2 previously acquired by the same thread here:
    #0 pthread_rwlock_rdlock <null>
    #1 isc_rwlock_lock lib/isc/rwlock.c:48:3
    #2 zone_gotwritehandle lib/dns/zone.c:2552:2
    #3 dispatch lib/isc/task.c:1152:7
    #4 run lib/isc/task.c:1344:2

    Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create lib/isc/pthreads/thread.c:73:8
    #2 isc_taskmgr_create lib/isc/task.c:1434:3
    #3 create_managers bin/named/main.c:915:11
    #4 setup bin/named/main.c:1223:11
    #5 main bin/named/main.c:1523:2

    SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) in pthread_rwlock_wrlock

(cherry picked from commit 1090876693470eedf69211d0fe71ba2c88160f45)

5 years agoMerge branch 'mnowak/pairwise-configure-testing-v9_16' into 'v9_16'
Michał Kępień [Tue, 22 Sep 2020 09:43:42 +0000 (09:43 +0000)] 
Merge branch 'mnowak/pairwise-configure-testing-v9_16' into 'v9_16'

[v9_16] Add pairwise testing

See merge request isc-projects/bind9!4161

5 years agoAdd pairwise testing
Michal Nowak [Wed, 1 Jul 2020 08:29:36 +0000 (10:29 +0200)] 
Add pairwise testing

Pairwise testing is a test case generation technique based on the
observation that most faults are caused by interactions of at most two
factors.  For BIND, its configure options can be thought of as such
factors.

Process BIND configure options into a model that is subsequently
processed by the PICT tool in order to find an effective test vector.
That test vector is then used for configuring and building BIND using
various combinations of configure options.

(cherry picked from commit 420986bf187ed2a33321d5af362732184426f439)

5 years agoMerge branch '2127-xml2rst-add-missing-updates-v9_16' into 'v9_16'
Matthijs Mekking [Tue, 22 Sep 2020 08:08:32 +0000 (08:08 +0000)] 
Merge branch '2127-xml2rst-add-missing-updates-v9_16' into 'v9_16'

Resolve "Update ARM with lost changes since the conversion to RST files"

See merge request isc-projects/bind9!4160

5 years agoImprove language in documentation
Matthijs Mekking [Mon, 21 Sep 2020 09:03:30 +0000 (11:03 +0200)] 
Improve language in documentation

Various language specific improvements, from Suzanne Goldlust's
review.

(cherry picked from commit 49e76c15dd54c2710fe179e2821d9acbf45ba5be)

5 years agoUpdate DNSSEC documentation
Matthijs Mekking [Thu, 10 Sep 2020 11:48:04 +0000 (13:48 +0200)] 
Update DNSSEC documentation

This was originally done in commit
da0ae5299f51c0ffdd4edc3b880d105a64590cf6 but was lost when the
documentation was converted to RST files.

(cherry picked from commit 0b0320360fc652766739259f938a4bd6248ce676)

5 years agoAdd a note on DNSSEC sign metrics in the ARM
Matthijs Mekking [Thu, 10 Sep 2020 10:37:29 +0000 (12:37 +0200)] 
Add a note on DNSSEC sign metrics in the ARM

This was added previously in commit
3a3f40e3729e1e3ab32f6c18eeecfd4749812ffb but was lost when the
documentation was converted to RST files.

(cherry picked from commit 3a3ace0f412459c903190e08cad49e2cd5fff81c)

5 years agoRemove leftover 'dnssec-keys' references
Matthijs Mekking [Thu, 10 Sep 2020 09:38:07 +0000 (11:38 +0200)] 
Remove leftover 'dnssec-keys' references

The option 'dnssec-keys' was introduced in 9.15 and also renamed to
'trust-anchors'. Rename the leftover references to 'trust-anchors'.

(cherry picked from commit e6b335c2ab6ae106718c18595afbe5945b1cc905)

5 years agoMerge branch '2158-threadsanitizer-data-race-in-memmove-v9_16' into 'v9_16'
Mark Andrews [Mon, 21 Sep 2020 09:54:36 +0000 (09:54 +0000)] 
Merge branch '2158-threadsanitizer-data-race-in-memmove-v9_16' into 'v9_16'

Remove the memmove call on dns_rbtnode_t structure that contains atomics

See merge request isc-projects/bind9!4154