]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
5 years agoSimplify the EDNS buffer size logic for DNS Flag Day 2020
Ondřej Surý [Wed, 23 Sep 2020 12:47:26 +0000 (14:47 +0200)] 
Simplify the EDNS buffer size logic for DNS Flag Day 2020

The DNS Flag Day 2020 aims to remove the IP fragmentation problem from
the UDP DNS communication.  In this commit, we implement the required
changes and simplify the logic for picking the EDNS Buffer Size.

1. The defaults for `edns-udp-size`, `max-udp-size` and
   `nocookie-udp-size` have been changed to `1232` (the value picked by
   DNS Flag Day 2020).

2. The probing heuristics that would try 512->4096->1432->1232 buffer
   sizes has been removed and the resolver will always use just the
   `edns-udp-size` value.

3. Instead of just disabling the PMTUD mechanism on the UDP sockets, we
   now set IP_DONTFRAG (IPV6_DONTFRAG) flag.  That means that the UDP
   packets won't get ever fragmented.  If the ICMP packets are lost the
   UDP will just timeout and eventually be retried over TCP.

5 years agoMerge branch 'ondrej/refactor-setsockopt' into 'main'
Ondřej Surý [Mon, 5 Oct 2020 14:11:55 +0000 (14:11 +0000)] 
Merge branch 'ondrej/refactor-setsockopt' into 'main'

Refactor the setsockopt() code in network manager into helper functions

See merge request isc-projects/bind9!4227

5 years agoSplit reusing the addr/port and load-balancing socket options
Ondřej Surý [Mon, 5 Oct 2020 11:14:04 +0000 (13:14 +0200)] 
Split reusing the addr/port and load-balancing socket options

The SO_REUSEADDR, SO_REUSEPORT and SO_REUSEPORT_LB has different meaning
on different platform. In this commit, we split the function to set the
reuse of address/port and setting the load-balancing into separate
functions.

The libuv library already have multiplatform support for setting
SO_REUSEADDR and SO_REUSEPORT that allows binding to the same address
and port, but unfortunately, when used after the load-balancing socket
options have been already set, it overrides the previous setting, so we
need our own helper function to enable the SO_REUSEADDR/SO_REUSEPORT
first and then enable the load-balancing socket option.

5 years agoUse uv_os_sock_t instead of uv_os_fd_t for sockets
Ondřej Surý [Mon, 5 Oct 2020 10:25:19 +0000 (12:25 +0200)] 
Use uv_os_sock_t instead of uv_os_fd_t for sockets

On POSIX based systems both uv_os_sock_t and uv_os_fd_t are both typedef
to int.  That's not true on Windows, where uv_os_sock_t is SOCKET and
uv_os_fd_t is HANDLE and they differ in level of indirection.

5 years agoRefactor isc__nm_socket_freebind() to take fd and sa_family as args
Ondřej Surý [Mon, 5 Oct 2020 09:17:52 +0000 (11:17 +0200)] 
Refactor isc__nm_socket_freebind() to take fd and sa_family as args

The isc__nm_socket_freebind() has been refactored to match other
isc__nm_socket_...() helper functions and take uv_os_fd_t and
sa_family_t as function arguments.

5 years agoAdd helper function to enable DF (don't fragment) flag on UDP sockets
Ondřej Surý [Mon, 5 Oct 2020 08:51:40 +0000 (10:51 +0200)] 
Add helper function to enable DF (don't fragment) flag on UDP sockets

This commits add isc__nm_socket_dontfrag() helper functions.

5 years agoAdd SO_REUSEPORT and SO_INCOMING_CPU helper functions
Ondřej Surý [Mon, 5 Oct 2020 08:40:02 +0000 (10:40 +0200)] 
Add SO_REUSEPORT and SO_INCOMING_CPU helper functions

The setting of SO_REUSE**** and SO_INCOMING_CPU have been moved into a
separate helper functions.

5 years agoMerge branch '1749-rndc-dnssec-rollover' into 'main'
Matthijs Mekking [Mon, 5 Oct 2020 09:46:48 +0000 (09:46 +0000)] 
Merge branch '1749-rndc-dnssec-rollover' into 'main'

Resolve "rndc trigger rollover"

Closes #1749

See merge request isc-projects/bind9!4004

5 years agoUse default algorithm in kasp test if possible
Matthijs Mekking [Fri, 4 Sep 2020 14:35:01 +0000 (16:35 +0200)] 
Use default algorithm in kasp test if possible

These tests don't require a specific algorithm so they should use
the DEFAULT_ALGORITHM from 'conf.sh.common'.

5 years agoUse explicit result codes for 'rndc dnssec' cmd
Matthijs Mekking [Fri, 4 Sep 2020 09:42:52 +0000 (11:42 +0200)] 
Use explicit result codes for 'rndc dnssec' cmd

It is better to add new result codes than to overload existing codes.

5 years agoVarious rndc dnssec -checkds fixes
Matthijs Mekking [Mon, 24 Aug 2020 08:05:28 +0000 (10:05 +0200)] 
Various rndc dnssec -checkds fixes

While working on 'rndc dnssec -rollover' I noticed the following
(small) issues:

- The key files where updated with hints set to "-when" and that
  should always be "now.
- The kasp system test did not properly update the test number when
  calling 'rndc dnssec -checkds' (and ensuring that works).
- There was a missing ']' in the rndc.c help output.

5 years agoTest rndc rollover inactive key
Matthijs Mekking [Mon, 24 Aug 2020 08:03:02 +0000 (10:03 +0200)] 
Test rndc rollover inactive key

When users (accidentally) try to roll an inactive key, throw an error.

5 years agoAdd rndc dnssec -rollover command
Matthijs Mekking [Fri, 21 Aug 2020 13:38:00 +0000 (15:38 +0200)] 
Add rndc dnssec -rollover command

This command is similar in arguments as -checkds so refactor the
'named_server_dnssec' function accordingly.  The only difference
are that:

- It does not take a "publish" or "withdrawn" argument.
- It requires the key id to be set (add a check to make sure).

Add tests that will trigger rollover immediately and one that
schedules a test in the future.

5 years agoAdd manual key rollover logic
Matthijs Mekking [Fri, 21 Aug 2020 13:31:57 +0000 (15:31 +0200)] 
Add manual key rollover logic

Add to the keymgr a function that will schedule a rollover. This
basically means setting the time when the key needs to retire,
and updating the key lifetime, then update the state file. The next
time that named runs the keymgr the new lifetime will be taken into
account.

5 years agoMerge branch '1870-fix-after-backport-to-9_11_s' into 'main'
Matthijs Mekking [Mon, 5 Oct 2020 08:47:07 +0000 (08:47 +0000)] 
Merge branch '1870-fix-after-backport-to-9_11_s' into 'main'

Change condition for rndc dumpdb -expired

See merge request isc-projects/bind9!4219

5 years agoChange condition for rndc dumpdb -expired
Matthijs Mekking [Fri, 2 Oct 2020 07:12:23 +0000 (09:12 +0200)] 
Change condition for rndc dumpdb -expired

After backporting #1870 to 9.11-S I saw that the condition check there
is different than in the main branch. In 9.11-S "stale" can mean
stale and serve-stale, or not active (awaiting cleanup). In 9.16 and
later versions, "stale" is stale and serve-stale, and "ancient" means
not active (awaiting cleanup). An "ancient" RRset is one that is not
active (TTL expired) and is not eligble for serve-stale.

Update the condition for rndc dumpdb -expired to closer match what is
in 9.11-S.

5 years agoMerge branch '2171-dnssec-policy-weird-algo-15-bug' into 'main'
Matthijs Mekking [Fri, 2 Oct 2020 08:06:45 +0000 (08:06 +0000)] 
Merge branch '2171-dnssec-policy-weird-algo-15-bug' into 'main'

Resolve "dnssec-policy behaviour for algorithm 15 keys different to algorithm 8 keys"

Closes #2171

See merge request isc-projects/bind9!4199

5 years agoFix a timing issue in kasp system test
Matthijs Mekking [Thu, 1 Oct 2020 09:07:05 +0000 (11:07 +0200)] 
Fix a timing issue in kasp system test

Sometimes, not all keys have been created in time before 'check_keys'
is called. Run a 'retry_quiet' on checking the number of keys before
continuing checking the key data.

5 years agoFix kasp min key size bug
Matthijs Mekking [Thu, 1 Oct 2020 09:05:01 +0000 (11:05 +0200)] 
Fix kasp min key size bug

The minimal size for RSASHA1, RSASHA256 is 512, but due to bad
assignment it was set to 1024.

5 years agoTest migration to dnssec-policy with views
Matthijs Mekking [Wed, 30 Sep 2020 08:06:37 +0000 (10:06 +0200)] 
Test migration to dnssec-policy with views

This test case is unrelated to the fix for #2171 but was added to
reproduce the problem.

5 years agoMinor fix in kasp system test
Matthijs Mekking [Wed, 30 Sep 2020 08:04:27 +0000 (10:04 +0200)] 
Minor fix in kasp system test

The 'wait_for_nsec' does not need to add TSIG because it calls
'dig_with_opts' and that already checks for TSIG.

5 years agoAdd change and note for #2171
Matthijs Mekking [Wed, 30 Sep 2020 08:03:43 +0000 (10:03 +0200)] 
Add change and note for #2171

This is a bug that needs to be noted.

5 years agoFix Ed25519 and Ed448 in dnssec-policy keymgr
Matthijs Mekking [Wed, 30 Sep 2020 07:57:45 +0000 (09:57 +0200)] 
Fix Ed25519 and Ed448 in dnssec-policy keymgr

The kasp code had bad implicit size values for the cryptographic
algorithms Ed25519 and Ed448. When creating keys they would never
match the dnssec-policy, leading to new attempts to create keys.

These algorithms were previously not yet added to the system tests,
due to lack of availability on some systems.

5 years agoAdd kasp tests for Ed25519 and Ed448
Matthijs Mekking [Wed, 30 Sep 2020 07:53:19 +0000 (09:53 +0200)] 
Add kasp tests for Ed25519 and Ed448

Use the testcrypto script to see if these algorithms are supported by
openssl. If so, add the specific configuration to the named.conf file
and touch a file to indicate support. If the file exists, the
corresponding setup and tests are performed.

5 years agoMerge branch '2139-rrset-order-fixes-and-cleanups' into 'main'
Michał Kępień [Fri, 2 Oct 2020 06:50:02 +0000 (06:50 +0000)] 
Merge branch '2139-rrset-order-fixes-and-cleanups' into 'main'

"rrset-order" fixes and cleanups

Closes #2139

See merge request isc-projects/bind9!4195

5 years agoAdd CHANGES entries
Michał Kępień [Fri, 2 Oct 2020 06:41:43 +0000 (08:41 +0200)] 
Add CHANGES entries

5 years agoRework "rrset-order" documentation
Michał Kępień [Fri, 2 Oct 2020 06:41:43 +0000 (08:41 +0200)] 
Rework "rrset-order" documentation

Certain parts of the existing documentation for the "rrset-order"
statement are incorrect, others are ambiguous.  Rework the relevant
section of the ARM to make it clear and up-to-date with the source code.

5 years agoAdd tests for "order none" RRset ordering rules
Michał Kępień [Fri, 2 Oct 2020 06:41:43 +0000 (08:41 +0200)] 
Add tests for "order none" RRset ordering rules

Make sure "order none" RRset ordering rules are tested in the
"rrsetorder" system test just like all other rule types are.  As the
check for the case of no "rrset-order" rule matching a given RRset also
tests "order none" (rather than "order random", as the test code may
suggest at first glance), replace the test code for that case so that it
matches other "order none" tests.

5 years agoAllow "order none" in "rrset-order" rules
Michał Kępień [Fri, 2 Oct 2020 06:41:43 +0000 (08:41 +0200)] 
Allow "order none" in "rrset-order" rules

named-checkconf treats the following configuration as valid:

    options {
        rrset-order {
            order none;
        };
    };

Yet, the above configuration causes named to crash on startup with:

    order.c:74: REQUIRE(mode == 0x00000800 || mode == 0x00000400 || mode == 0x00800000) failed, back trace

Add DNS_RDATASETATTR_NONE to the list of RRset ordering modes accepted
by dns_order_add() to allow "order none" to be used in "rrset-order"
rules.  This both prevents the aforementioned crashes and addresses the
discrepancy between named-checkconf and named.

5 years agoMerge branch '2112-allow-task_test-subtests-to-be-selected-at-runtime' into 'main'
Mark Andrews [Thu, 1 Oct 2020 12:46:00 +0000 (12:46 +0000)] 
Merge branch '2112-allow-task_test-subtests-to-be-selected-at-runtime' into 'main'

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

Closes #2112

See merge request isc-projects/bind9!4059

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

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)

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>]

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.