]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
5 years agoAlphabetise tests
Mark Andrews [Fri, 11 Sep 2020 03:37:56 +0000 (13:37 +1000)] 
Alphabetise tests

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

Resolve "Missing locks when accessing keynode.initial and keynode.managed triggered TSAN."

Closes #2191

See merge request isc-projects/bind9!4205

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

5 years agoMerge branch '2192-tsan-error-accessing-listener-connections' into 'main'
Mark Andrews [Thu, 1 Oct 2020 07:13:09 +0000 (07:13 +0000)] 
Merge branch '2192-tsan-error-accessing-listener-connections' into 'main'

Resolve "TSAN error accessing listener->connections"

Closes #2192

See merge request isc-projects/bind9!4206

5 years agoLock access to listener->connections
Mark Andrews [Thu, 1 Oct 2020 05:11:32 +0000 (15:11 +1000)] 
Lock access to listener->connections

as it is accessed from multiple threads with libuv.

    WARNING: ThreadSanitizer: data race
    Write of size 8 at 0x000000000001 by thread T1:
    #0 conn_reset bin/named/controlconf.c:574
    #1 isc_nmhandle_detach netmgr/netmgr.c:1257
    #2 isc__nm_uvreq_put netmgr/netmgr.c:1389
    #3 tcp_send_cb netmgr/tcp.c:1030
    #4 <null> <null>
    #5 <null> <null>

    Previous read of size 8 at 0x000000000001 by thread T2:
    #0 conn_reset bin/named/controlconf.c:574
    #1 isc_nmhandle_detach netmgr/netmgr.c:1257
    #2 control_recvmessage bin/named/controlconf.c:556
    #3 recv_data lib/isccc/ccmsg.c:110
    #4 isc__nm_tcp_shutdown netmgr/tcp.c:1161
    #5 shutdown_walk_cb netmgr/netmgr.c:1511
    #6 uv_walk <null>
    #7 process_queue netmgr/netmgr.c:656
    #8 process_normal_queue netmgr/netmgr.c:582
    #9 process_queues netmgr/netmgr.c:590
    #10 async_cb netmgr/netmgr.c:548
    #11 <null> <null>
    #12 <null> <null>

    Location is heap block of size 265 at 0x000000000017 allocated by thread T3:
    #0 malloc <null>
    #1 default_memalloc lib/isc/mem.c:713
    #2 mem_get lib/isc/mem.c:622
    #3 isc___mem_get lib/isc/mem.c:1044
    #4 isc__mem_get lib/isc/mem.c:2432
    #5 add_listener bin/named/controlconf.c:1127
    #6 named_controls_configure bin/named/controlconf.c:1324
    #7 load_configuration bin/named/server.c:9181
    #8 run_server bin/named/server.c:9819
    #9 dispatch lib/isc/task.c:1152
    #10 run lib/isc/task.c:1344
    #11 <null> <null>

    Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create pthreads/thread.c:73
    #2 isc_nm_start netmgr/netmgr.c:232
    #3 create_managers bin/named/main.c:909
    #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_nm_start netmgr/netmgr.c:232
    #3 create_managers bin/named/main.c:909
    #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 bin/named/controlconf.c:574 in conn_reset

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

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

See merge request isc-projects/bind9!4203

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.

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

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

Closes #2180

See merge request isc-projects/bind9!4167

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

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

dig: print timestamps with microsecond precision if "-u" is used in YAML output mode

Closes #2190

See merge request isc-projects/bind9!4193

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

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.

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

5 years agoMerge branch '2188-bug-in-message-c-673-ensure-isc_mempool_getallocated-msg-namepool...
Mark Andrews [Wed, 30 Sep 2020 13:43:20 +0000 (13:43 +0000)] 
Merge branch '2188-bug-in-message-c-673-ensure-isc_mempool_getallocated-msg-namepool-0-failed' into 'main'

Resolve "Bug in message.c:673: ENSURE(isc_mempool_getallocated(msg->namepool) == 0) failed"

Closes #2188

See merge request isc-projects/bind9!4189

5 years agoCheck that sig0 name is the root.
Mark Andrews [Tue, 29 Sep 2020 03:25:44 +0000 (13:25 +1000)] 
Check that sig0 name is the root.

5 years agoHave -d print out the message
Mark Andrews [Tue, 29 Sep 2020 03:19:24 +0000 (13:19 +1000)] 
Have -d print out the message

5 years agoAlways clean sig0name in msgresetsigs() and dns_message_renderreset()
Mark Andrews [Mon, 28 Sep 2020 02:54:17 +0000 (12:54 +1000)] 
Always clean sig0name in msgresetsigs() and dns_message_renderreset()

The fuzzing harness operates on dns_message_t in non-standard ways
and if 'sig0name' is non-NULL when msgresetsigs() and
dns_message_renderreset() are called it should be cleaned up.

5 years agoAdd packet from issue #4189
Mark Andrews [Mon, 28 Sep 2020 02:53:09 +0000 (12:53 +1000)] 
Add packet from issue #4189

5 years agoMerge branch 'marka-regen-ddns-confgen.8in' into 'main'
Ondřej Surý [Wed, 30 Sep 2020 12:19:26 +0000 (12:19 +0000)] 
Merge branch 'marka-regen-ddns-confgen.8in' into 'main'

regenerate ddns-confgen.8in

See merge request isc-projects/bind9!4198

5 years agoregenerate ddns-confgen.8in
Mark Andrews [Wed, 30 Sep 2020 05:52:54 +0000 (15:52 +1000)] 
regenerate ddns-confgen.8in

5 years agoMerge branch '2124-fix-assertion-failure-in-dns-message' into 'main'
Ondřej Surý [Tue, 29 Sep 2020 08:14:23 +0000 (08:14 +0000)] 
Merge branch '2124-fix-assertion-failure-in-dns-message' into 'main'

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

Closes #2124

See merge request isc-projects/bind9!4194

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

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.

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.

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.

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.

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.

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

Resolve "some comments in lib/dns/stats.c use incorrect notation for bit values"

Closes #2189

See merge request isc-projects/bind9!4191

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

5 years agoMerge branch '114-out-of-tree-system-tests' into 'main'
Michał Kępień [Mon, 28 Sep 2020 19:39:22 +0000 (19:39 +0000)] 
Merge branch '114-out-of-tree-system-tests' into 'main'

Add out-of-tree system test job

Closes #114

See merge request isc-projects/bind9!3895

5 years agoDo not remove $systest for out-of-tree builds
Michal Nowak [Fri, 31 Jul 2020 11:10:44 +0000 (13:10 +0200)] 
Do not remove $systest for out-of-tree builds

Previously, the $systest directory was being removed for out-of-tree
builds at the end of each system test.  Because of that, running tests
which depend on compiled objects was breaking subsequent "make check"
invocations:

    make: Target 'check' not remade because of errors.
    Making all in dyndb/driver
    /bin/bash: line 20: cd: dyndb/driver: No such file or directory
    Making all in dlzexternal/driver
    /bin/bash: line 20: cd: dlzexternal/driver: No such file or directory

Address by first removing build/test artifacts for a given test and then
removing empty directories inside (and potentially including) $systest.

5 years agoAdd an out-of-tree system test job to GitLab CI
Michal Nowak [Tue, 21 Jul 2020 13:54:27 +0000 (15:54 +0200)] 
Add an out-of-tree system test job to GitLab CI

Make sure the new job does not get run for every pipeline as it is not
expected to break often and it is similar enough to other system test
jobs.  Change the name of the variable holding the path to the
out-of-tree build directory to a more generic one.

5 years agoMerge branch 'ondrej/clear-the-uv-event-loop-before-exiting' into 'main'
Ondřej Surý [Mon, 28 Sep 2020 10:56:33 +0000 (10:56 +0000)] 
Merge branch 'ondrej/clear-the-uv-event-loop-before-exiting' into 'main'

Clear the libuv event loop before exiting

See merge request isc-projects/bind9!4181

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.

5 years agoMerge branch '1725-drop-function-wrapping' into 'main'
Michał Kępień [Mon, 28 Sep 2020 07:11:48 +0000 (07:11 +0000)] 
Merge branch '1725-drop-function-wrapping' into 'main'

Drop function wrapping as it is redundant for now

Closes #1725

See merge request isc-projects/bind9!4174

5 years agoFix function overrides in unit tests on macOS
Michał Kępień [Mon, 28 Sep 2020 07:09:21 +0000 (09:09 +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 agoDrop function wrapping as it is redundant for now
Michał Kępień [Mon, 28 Sep 2020 07:09:21 +0000 (09:09 +0200)] 
Drop function wrapping as it is redundant for now

As currently used in the BIND source tree, the --wrap linker option is
redundant because:

  - static builds are no longer supported,

  - there is no need to wrap around existing functions - what is
    actually required (at least for now) is to replace them altogether
    in unit tests,

  - only functions exposed by shared libraries linked into unit test
    binaries are currently being replaced.

Given the above, providing the alternative implementations of functions
to be overridden in lib/ns/tests/nstest.c is a much simpler alternative
to using the --wrap linker option.  Drop the code detecting support for
the latter from configure.ac, simplify the relevant Makefile.am, and
remove lib/ns/tests/wrap.c, updating lib/ns/tests/nstest.c accordingly
(it is harmless for unit tests which are not calling the overridden
functions).

5 years agoMerge branch '2185-nsdname-wait-recurse-speed-test-fails-under-tsan' into 'main'
Mark Andrews [Mon, 28 Sep 2020 00:05:56 +0000 (00:05 +0000)] 
Merge branch '2185-nsdname-wait-recurse-speed-test-fails-under-tsan' into 'main'

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

Closes #2185

See merge request isc-projects/bind9!4184

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.

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

5 years agoMerge branch '1041-filter-aaaa-purge-memory-pool-upon-plugin-destruction' into 'main'
Evan Hunt [Fri, 25 Sep 2020 21:02:20 +0000 (21:02 +0000)] 
Merge branch '1041-filter-aaaa-purge-memory-pool-upon-plugin-destruction' into 'main'

filter-aaaa: Purge memory pool upon plugin destruction

Closes #1041

See merge request isc-projects/bind9!1957

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]

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.

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

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

Closes #2184

See merge request isc-projects/bind9!4180

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

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

5 years agoMerge branch '1870-rndc-dumpdb-expired-v2' into 'main'
Matthijs Mekking [Wed, 23 Sep 2020 14:38:54 +0000 (14:38 +0000)] 
Merge branch '1870-rndc-dumpdb-expired-v2' into 'main'

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

Closes #1870

See merge request isc-projects/bind9!4088

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.

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.

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.

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".

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.

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).

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.

5 years agoMerge branch '2162-threadsanitizer-data-race-in-epoll_ctl' into 'main'
Mark Andrews [Wed, 23 Sep 2020 04:19:58 +0000 (04:19 +0000)] 
Merge branch '2162-threadsanitizer-data-race-in-epoll_ctl' into 'main'

Resolve "ThreadSanitizer: data race in epoll_ctl"

Closes #2162

See merge request isc-projects/bind9!4171

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

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

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

Closes #2156

See merge request isc-projects/bind9!4150

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

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

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

Closes #2109

See merge request isc-projects/bind9!4168

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

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.

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

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

Closes #2156

See merge request isc-projects/bind9!4157

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)

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

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

Closes #2157

See merge request isc-projects/bind9!4158

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

5 years agoMerge branch '2144-double-attach-when-prefetching' into 'main'
Ondřej Surý [Tue, 22 Sep 2020 08:53:31 +0000 (08:53 +0000)] 
Merge branch '2144-double-attach-when-prefetching' into 'main'

Resolve "double-attach when prefetching"

Closes #2144

See merge request isc-projects/bind9!4124

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.

5 years agoMerge branch '2127-xml2rst-add-missing-updates' into 'main'
Matthijs Mekking [Tue, 22 Sep 2020 07:28:01 +0000 (07:28 +0000)] 
Merge branch '2127-xml2rst-add-missing-updates' into 'main'

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

Closes #2127

See merge request isc-projects/bind9!4112

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.

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.

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.

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'.

5 years agoMerge branch 'michal/minimize-stdout-logging-in-pairwise-testing-jobs' into 'main'
Michał Kępień [Tue, 22 Sep 2020 06:41:08 +0000 (06:41 +0000)] 
Merge branch 'michal/minimize-stdout-logging-in-pairwise-testing-jobs' into 'main'

Minimize stdout logging in pairwise testing jobs

See merge request isc-projects/bind9!4159

5 years agoMinimize stdout logging in pairwise testing jobs
Michał Kępień [Tue, 22 Sep 2020 06:40:04 +0000 (08:40 +0200)] 
Minimize stdout logging in pairwise testing jobs

The size of the log generated by each GitLab CI job is limited to 4 MB
by default.  While this limit is configurable, it makes little sense to
print build logs to standard output if they are being captured to files
anyway.  Limit use of "tee" in util/pairwise-testing.sh to printing the
combination of configure switches used for a given build.  This way the
job should never exceed the default 4 MB log size limit, yet it will
still indicate its progress in a concise way.

5 years agoMerge branch 'michal/extend-the-artifact-list-for-the-pairwise-ci-job' into 'main'
Michał Kępień [Mon, 21 Sep 2020 10:11:16 +0000 (10:11 +0000)] 
Merge branch 'michal/extend-the-artifact-list-for-the-pairwise-ci-job' into 'main'

Extend the artifact list for the "pairwise" CI job

See merge request isc-projects/bind9!4156

5 years agoExtend the artifact list for the "pairwise" CI job
Michał Kępień [Mon, 21 Sep 2020 10:08:50 +0000 (12:08 +0200)] 
Extend the artifact list for the "pairwise" CI job

Include the log file generated by the last failed pairwise build among
the artifacts produced by the "pairwise" GitLab CI job in order to
simplify troubleshooting pairwise build failures.

5 years agoMerge branch 'matthijs-fix-deprected-typo' into 'main'
Michał Kępień [Mon, 21 Sep 2020 09:34:53 +0000 (09:34 +0000)] 
Merge branch 'matthijs-fix-deprected-typo' into 'main'

Fix deprected typo

See merge request isc-projects/bind9!4155

5 years agoMerge branch 'mnowak/pairwise-configure-testing' into 'main'
Michał Kępień [Mon, 21 Sep 2020 09:32:16 +0000 (09:32 +0000)] 
Merge branch 'mnowak/pairwise-configure-testing' into 'main'

Add pairwise testing

Closes isc-private/bind-qa#21

See merge request isc-projects/bind9!3784

5 years agoFix 'deprected' typo
Matthijs Mekking [Mon, 21 Sep 2020 09:26:52 +0000 (11:26 +0200)] 
Fix 'deprected' typo

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.

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

Resolve "ThreadSanitizer: data race in memmove"

Closes #2158

See merge request isc-projects/bind9!4149

5 years agoRemove the memmove call on dns_rbtnode_t structure that contains atomics
Mark Andrews [Mon, 21 Sep 2020 04:52:53 +0000 (14:52 +1000)] 
Remove the memmove call on dns_rbtnode_t structure that contains atomics

Calling the plain memmove on the structure that contains atomic members
triggers following TSAN warning (even when we don't really use the
atomic members in the code):

    WARNING: ThreadSanitizer: data race
      Read of size 8 at 0x000000000001 by thread T1 (mutexes: write M1, write M2):
#0 memmove <null>
#1 memmove /usr/include/x86_64-linux-gnu/bits/string_fortified.h:40:10
#2 deletefromlevel lib/dns/rbt.c:2675:3
#3 dns_rbt_deletenode lib/dns/rbt.c:2143:2
#4 delete_node lib/dns/rbtdb.c
#5 decrement_reference lib/dns/rbtdb.c:2202:4
#6 prune_tree lib/dns/rbtdb.c:2259:3
#7 dispatch lib/isc/task.c:1152:7
#8 run lib/isc/task.c:1344:2

      Previous atomic write of size 8 at 0x000000000001 by thread T2 (mutexes: read M3):
#0 __tsan_atomic64_fetch_sub <null>
#1 decrement_reference lib/dns/rbtdb.c:2103:7
#2 detachnode lib/dns/rbtdb.c:5440:6
#3 dns_db_detachnode lib/dns/db.c:588:2
#4 qctx_clean lib/ns/query.c:5104:3
#5 ns_query_done lib/ns/query.c:10868:2
#6 query_sign_nodata lib/ns/query.c
#7 query_nodata lib/ns/query.c:8438:11
#8 query_gotanswer lib/ns/query.c
#9 query_lookup lib/ns/query.c:5624:10
#10 ns__query_start lib/ns/query.c:5500:10
#11 query_setup lib/ns/query.c:5224:11
#12 ns_query_start lib/ns/query.c:11357:8
#13 ns__client_request lib/ns/client.c:2166:3
#14 udp_recv_cb lib/isc/netmgr/udp.c:414:2
#15 uv__udp_recvmsg /home/ondrej/Projects/tsan/libuv/src/unix/udp.c
#16 uv__udp_io /home/ondrej/Projects/tsan/libuv/src/unix/udp.c:180:5
#17 uv__io_poll /home/ondrej/Projects/tsan/libuv/src/unix/linux-core.c:461:11
#18 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:385:5
#19 nm_thread lib/isc/netmgr/netmgr.c:500:11

      Location is heap block of size 132 at 0x000000000030 allocated by thread T3:
#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 create_node lib/dns/rbt.c:2239:9
#9 dns_rbt_addnode lib/dns/rbt.c:1435:12
#10 findnodeintree lib/dns/rbtdb.c:2895:12
#11 findnode lib/dns/rbtdb.c:2941:10
#12 dns_db_findnode lib/dns/db.c:439:11
#13 diff_apply lib/dns/diff.c:306:5
#14 dns_diff_apply lib/dns/diff.c:459:10
#15 do_one_tuple lib/ns/update.c:444:11
#16 update_one_rr lib/ns/update.c:495:10
#17 update_action lib/ns/update.c:3123:6
#18 dispatch lib/isc/task.c:1152:7
#19 run lib/isc/task.c:1344:2

      Mutex M1 is already destroyed.

      Mutex M2 is already destroyed.

      Mutex M3 is already destroyed.

      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_nm_start lib/isc/netmgr/netmgr.c:223:3
#3 create_managers bin/named/main.c:909:15
#4 setup bin/named/main.c:1223:11
#5 main bin/named/main.c:1523:2

      Thread T3 (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 memmove

5 years agoMerge branch '2166-bind-9-16-7-trap-divide-error' into 'main'
Ondřej Surý [Mon, 21 Sep 2020 08:57:12 +0000 (08:57 +0000)] 
Merge branch '2166-bind-9-16-7-trap-divide-error' into 'main'

Resolve "bind 9.16.7 trap divide error"

Closes #2166

See merge request isc-projects/bind9!4141

5 years agoAdd CHANGES and release note for GL #2166
Ondřej Surý [Thu, 17 Sep 2020 12:47:16 +0000 (14:47 +0200)] 
Add CHANGES and release note for GL #2166

5 years agoHandle the errors from sysconf() call in isc_meminfo_totalphys()
Ondřej Surý [Thu, 17 Sep 2020 12:37:24 +0000 (14:37 +0200)] 
Handle the errors from sysconf() call in isc_meminfo_totalphys()

isc_meminfo_totalphys() would return invalid memory size when sysconf()
call would fail, because ((size_t)-1 * -1) is very large number.

5 years agoMerge branch '2164-threadsanitizer-data-race-bin-named-controlconf-c-257-22-in-contro...
Mark Andrews [Mon, 21 Sep 2020 08:43:21 +0000 (08:43 +0000)] 
Merge branch '2164-threadsanitizer-data-race-bin-named-controlconf-c-257-22-in-control_senddone' into 'main'

Resolve "ThreadSanitizer: data race bin/named/controlconf.c:257:22 in control_senddone"

Closes #2164

See merge request isc-projects/bind9!4147

5 years agoRemove .listener member of controlistener struct
Ondřej Surý [Mon, 21 Sep 2020 08:16:36 +0000 (10:16 +0200)] 
Remove .listener member of controlistener struct

In the new netmgr code, the .listener member was mostly functionally
only duplicating the .exiting member and was unneeded.  This also
resolves following ThreadSanitizer (harmless) warning:

    WARNING: ThreadSanitizer: data race
      Write of size 1 at 0x000000000001 by thread T1:
#0 control_senddone bin/named/controlconf.c:257:22
#1 tcp_send_cb lib/isc/netmgr/tcp.c:1027:2
#2 uv__write_callbacks /home/ondrej/Projects/tsan/libuv/src/unix/stream.c:953:7
#3 uv__stream_io /home/ondrej/Projects/tsan/libuv/src/unix/stream.c:1330:5
#4 uv__run_pending /home/ondrej/Projects/tsan/libuv/src/unix/core.c:812:5
#5 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:377:19
#6 nm_thread lib/isc/netmgr/netmgr.c:500:11

      Previous write of size 1 at 0x000000000001 by thread T2:
#0 control_senddone bin/named/controlconf.c:257:22
#1 tcp_send_cb lib/isc/netmgr/tcp.c:1027:2
#2 uv__write_callbacks /home/ondrej/Projects/tsan/libuv/src/unix/stream.c:953:7
#3 uv__stream_io /home/ondrej/Projects/tsan/libuv/src/unix/stream.c:1330:5
#4 uv__run_pending /home/ondrej/Projects/tsan/libuv/src/unix/core.c:812:5
#5 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:377:19
#6 nm_thread lib/isc/netmgr/netmgr.c:500:11

      Location is heap block of size 265 at 0x000000000009 allocated by thread T3:
#0 malloc <null>
#1 default_memalloc lib/isc/mem.c:713:8
#2 mem_get lib/isc/mem.c:622:8
#3 isc___mem_get lib/isc/mem.c:1044:9
#4 isc__mem_get lib/isc/mem.c:2432:10
#5 add_listener bin/named/controlconf.c:1133:13
#6 named_controls_configure bin/named/controlconf.c:1331:6
#7 load_configuration bin/named/server.c:9133:2
#8 run_server bin/named/server.c:9771:2
#9 dispatch lib/isc/task.c:1152:7
#10 run lib/isc/task.c:1344: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_nm_start lib/isc/netmgr/netmgr.c:223:3
#3 create_managers bin/named/main.c:909:15
#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_nm_start lib/isc/netmgr/netmgr.c:223:3
#3 create_managers bin/named/main.c:909:15
#4 setup bin/named/main.c:1223:11
#5 main bin/named/main.c:1523:2

      Thread T3 (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/controlconf.c:257:22 in control_senddone

5 years agoMerge branch '2169-fix-updating-summary-rpz-db-for-mixed-case-rpzs' into 'main'
Michał Kępień [Mon, 21 Sep 2020 07:32:09 +0000 (07:32 +0000)] 
Merge branch '2169-fix-updating-summary-rpz-db-for-mixed-case-rpzs' into 'main'

Fix updating summary RPZ DB for mixed-case RPZs

Closes #2169

See merge request isc-projects/bind9!4146

5 years agoAdd CHANGES entry
Michał Kępień [Mon, 21 Sep 2020 07:28:36 +0000 (09:28 +0200)] 
Add CHANGES entry

5 years agoAdd release note
Michał Kępień [Mon, 21 Sep 2020 07:28:36 +0000 (09:28 +0200)] 
Add release note

5 years agoFix updating summary RPZ DB for mixed-case RPZs
Michał Kępień [Mon, 21 Sep 2020 07:28:36 +0000 (09:28 +0200)] 
Fix updating summary RPZ DB for mixed-case RPZs

Each dns_rpz_zone_t structure keeps a hash table of the names this RPZ
database contains.  Here is what happens when an RPZ is updated:

  - a new hash table is prepared for the new version of the RPZ by
    iterating over it; each name found is added to the summary RPZ
    database,

  - every name added to the new hash table is searched for in the old
    hash table; if found, it is removed from the old hash table,

  - the old hash table is iterated over; all names found in it are
    removed from the summary RPZ database (because at that point the old
    hash table should only contain names which are not present in the
    new version of the RPZ),

  - the new hash table replaces the old hash table.

When the new version of the RPZ is iterated over, if a given name is
spelled using a different letter case than in the old version of the
RPZ, the new variant will hash to a different value than the old
variant, which means it will not be removed from the old hash table.
When the old hash table is subsequently iterated over to remove
seemingly deleted names, the old variant of the name will still be
there, causing the name to be deleted from the summary RPZ database
(which effectively causes a given rule to be ignored).

The issue can be triggered not just by altering the case of existing
names in an RPZ, but also by adding sibling names spelled with a
different letter case.  This is because RBT code preserves case when
node splitting occurs.  The end result is that when the RPZ is iterated
over, a given name may be using a different case than in the zone file
(or XFR contents).

Fix by downcasing all names found in the RPZ database before adding them
to the summary RPZ database.

5 years agoMerge branch '2160-threadsanitizer-data-race-bin-named-controlconf-c-422-37-in-contro...
Mark Andrews [Mon, 21 Sep 2020 03:41:49 +0000 (03:41 +0000)] 
Merge branch '2160-threadsanitizer-data-race-bin-named-controlconf-c-422-37-in-control_recvmessage' into 'main'

Resolve "ThreadSanitizer: data race bin/named/controlconf.c:422:37 in control_recvmessage"

Closes #2160

See merge request isc-projects/bind9!4148

5 years agomake controls->shuttingdown an atomic_bool
Mark Andrews [Mon, 21 Sep 2020 02:48:10 +0000 (12:48 +1000)] 
make controls->shuttingdown an atomic_bool

5 years agoMerge branch '2163-threadsanitizer-data-race-lib-isc-mem-c-1119-19-in-isc___mem_put...
Ondřej Surý [Thu, 17 Sep 2020 15:34:35 +0000 (15:34 +0000)] 
Merge branch '2163-threadsanitizer-data-race-lib-isc-mem-c-1119-19-in-isc___mem_put' into 'main'

Exclude isc_mem_isovermem from ThreadSanitizer

Closes #2163

See merge request isc-projects/bind9!4140

5 years agoExclude isc_mem_isovermem from ThreadSanitizer
Ondřej Surý [Thu, 17 Sep 2020 12:05:10 +0000 (14:05 +0200)] 
Exclude isc_mem_isovermem from ThreadSanitizer

The .is_overmem member of isc_mem_t structure is intentionally accessed
unlocked as 100% accuracy isn't necessary here.

Without the attribute, following TSAN warning would show up:

    WARNING: ThreadSanitizer: data race
      Write of size 1 at 0x000000000001 by thread T1 (mutexes: write M1, write M2):
#0 isc___mem_put lib/isc/mem.c:1119:19
#1 isc__mem_put lib/isc/mem.c:2439:2
#2 dns_rdataslab_fromrdataset lib/dns/rdataslab.c:327:2
#3 addrdataset lib/dns/rbtdb.c:6761:11
#4 dns_db_addrdataset lib/dns/db.c:719:10
#5 cache_name lib/dns/resolver.c:6538:13
#6 cache_message lib/dns/resolver.c:6628:14
#7 resquery_response lib/dns/resolver.c:7883:13
#8 dispatch lib/isc/task.c:1152:7
#9 run lib/isc/task.c:1344:2

      Previous read of size 1 at 0x000000000001 by thread T2 (mutexes: write M3):
#0 isc_mem_isovermem lib/isc/mem.c:1553:15
#1 addrdataset lib/dns/rbtdb.c:6866:25
#2 dns_db_addrdataset lib/dns/db.c:719:10
#3 addoptout lib/dns/ncache.c:281:10
#4 dns_ncache_add lib/dns/ncache.c:101:10
#5 ncache_adderesult lib/dns/resolver.c:6668:12
#6 ncache_message lib/dns/resolver.c:6845:11
#7 rctx_ncache lib/dns/resolver.c:9174:11
#8 resquery_response lib/dns/resolver.c:7894:2
#9 dispatch lib/isc/task.c:1152:7
#10 run lib/isc/task.c:1344:2

      Location is heap block of size 328 at 0x000000000020 allocated by thread T3:
#0 malloc <null>
#1 default_memalloc lib/isc/mem.c:713:8
#2 mem_create lib/isc/mem.c:763:8
#3 isc_mem_create lib/isc/mem.c:2425:2
#4 configure_view bin/named/server.c:4494:4
#5 load_configuration bin/named/server.c:9062:3
#6 run_server bin/named/server.c:9771:2
#7 dispatch lib/isc/task.c:1152:7
#8 run lib/isc/task.c:1344:2

    [...]

    SUMMARY: ThreadSanitizer: data race lib/isc/mem.c:1119:19 in isc___mem_put

5 years agoMerge branch 'michal/update-release-checklist' into 'main'
Michał Kępień [Thu, 17 Sep 2020 13:43:23 +0000 (13:43 +0000)] 
Merge branch 'michal/update-release-checklist' into 'main'

Update release checklist

See merge request isc-projects/bind9!4142

5 years agoUpdate release checklist
Michał Kępień [Thu, 17 Sep 2020 13:39:11 +0000 (15:39 +0200)] 
Update release checklist

Add an item to the release checklist to make sure eligible customers get
notified about the location of the latest version of BIND Subscription
Edition upon its release.

5 years agoMerge branch '2131-tsan-data-race-in-accessing-controls-symtab' into 'main'
Mark Andrews [Thu, 17 Sep 2020 09:28:40 +0000 (09:28 +0000)] 
Merge branch '2131-tsan-data-race-in-accessing-controls-symtab' into 'main'

Resolve "TSAN data race in accessing controls->symtab"

Closes #2131

See merge request isc-projects/bind9!4098

5 years agoLock access to control->symtab to prevent data race
Mark Andrews [Tue, 8 Sep 2020 02:11:06 +0000 (12:11 +1000)] 
Lock access to control->symtab to prevent data race

    WARNING: ThreadSanitizer: data race
    Read of size 8 at 0x000000000001 by thread T1:
    #0 isccc_symtab_foreach lib/isccc/symtab.c:277:14
    #1 isccc_cc_cleansymtab lib/isccc/cc.c:954:2
    #2 control_recvmessage bin/named/controlconf.c:477:2
    #3 recv_data lib/isccc/ccmsg.c:110:2
    #4 read_cb lib/isc/netmgr/tcp.c:769:4
    #5 <null> <null>

    Previous write of size 8 at 0x000000000001 by thread T2:
    #0 isccc_symtab_define lib/isccc/symtab.c:242:2
    #1 isccc_cc_checkdup lib/isccc/cc.c:1026:11
    #2 control_recvmessage bin/named/controlconf.c:478:11
    #3 recv_data lib/isccc/ccmsg.c:110:2
    #4 read_cb lib/isc/netmgr/tcp.c:769:4
    #5 <null> <null>

    Location is heap block of size 190352 at 0x000000000011 allocated by main thread:
    #0 malloc <null>
    #1 isccc_symtab_create lib/isccc/symtab.c:76:18
    #2 isccc_cc_createsymtab lib/isccc/cc.c:948:10
    #3 named_controls_create bin/named/controlconf.c:1483:11
    #4 named_server_create bin/named/server.c:10057:2
    #5 setup bin/named/main.c:1256:2
    #6 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_nm_start lib/isc/netmgr/netmgr.c:215:3
    #3 create_managers bin/named/main.c:909:15
    #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_nm_start lib/isc/netmgr/netmgr.c:215:3
    #3 create_managers bin/named/main.c:909:15
    #4 setup bin/named/main.c:1223:11
    #5 main bin/named/main.c:1523:2

    SUMMARY: ThreadSanitizer: data race lib/isccc/symtab.c:277:14 in isccc_symtab_foreach

5 years agoMerge branch '2123-lock-order-inversions-in-main' into 'main'
Mark Andrews [Thu, 17 Sep 2020 08:12:21 +0000 (08:12 +0000)] 
Merge branch '2123-lock-order-inversions-in-main' into 'main'

Resolve "Lock order inversions in main"

Closes #2123

See merge request isc-projects/bind9!4090