Commit Graph
8967 Commits
Author SHA1 Message Date
Mark Andrews 0e5a076cc1 Prevent inlining of code with thread sanitiser disabled 2020-12-10 06:31:19 +00:00
Ondřej SurýandOndřej Surý 6425dfa9cb Change the default value for nocookie-udp-size back to 4096
The DNS Flag Day 2020 reduced all the EDNS buffer sizes to 1232.  In
this commit, we revert the default value for nocookie-udp-size back to
4096 because the option is too obscure and most people don't realize
that they also need to change this configuration option in addition to
max-udp-size.

(cherry picked from commit 79c196fc77)
2020-12-02 12:04:28 +01:00
Mark Andrews d09991e4e9 Adjust default value of "max-recursion-queries"
Since the queries sent towards root and TLD servers are now included in
the count (as a result of the fix for CVE-2020-8616),
"max-recursion-queries" has a higher chance of being exceeded by
non-attack queries.  Increase its default value from 75 to 100.

(cherry picked from commit ab0bf49203)
2020-12-01 22:13:05 +00:00
Mark AndrewsandEvan Hunt ca9dc40634 Fix DNAME when QTYPE is CNAME or ANY
The synthesised CNAME is not supposed to be followed when the
QTYPE is CNAME or ANY as the lookup is satisfied by the CNAME
record.
2020-12-01 11:46:32 -08:00
Michał Kępień dfdd3a8a2f Make DocBook sources namespaced again
Every DocBook source document can be namespaced (DocBook 5) or
non-namespaced (DocBook 4).  The set of XSL stylesheets used for
producing an output document can also be namespaced or non-namespaced.
Namespaced source documents should be used with namespaced stylesheets
and non-namespaced source documents should be used with non-namespaced
stylesheets.  However, both stylesheet flavors contain processing rules
which allow them to be used interchangeably for any type of source
document.

Unfortunately, these processing rules became broken in version 1.79.1 of
the stylesheets, which means that non-namespaced source documents can no
longer be correctly transformed into man pages using namespaced
stylesheets and vice versa.  This problem was fixed upstream [1], but no
released version of the XSL stylesheets contains that fix yet.

Back in 2016, this problem was reported as RT #43831 and allegedly fixed
in commit 1b8ce3b330.  However, that fix
only helped for the non-namespaced version of the stylesheets - while
also breaking man page generation for the namespaced flavor.

Since using namespaced DocBook sources is the current best practice
(DocBook 5), make BIND DocBook sources namespaced again.  When using
version 1.79.1 or 1.79.2 of the XSL stylesheets, care must be taken to
ensure namespaced stylesheets are used for generating BIND
documentation.

[1] https://github.com/docbook/xslt10-stylesheets/issues/109
2020-11-30 09:33:32 +01:00
Mark Andrews 81e5877520 Check that missing cookies are handled
(cherry picked from commit bd9155590e)
2020-11-27 10:20:40 +11:00
Michal Nowak 76d1c90ef7 Write traceback file to the same directory as core file
The traceback files could overwrite each other on systems which do not
use different core dump file names for different processes.  Prevent
that by writing the traceback file to the same directory as the core
dump file.

These changes still do not prevent the operating system from overwriting
a core dump file if the same binary crashes multiple times in the same
directory and core dump files are named identically for different
processes.

(cherry picked from commit 6428fc26af)
2020-11-26 18:25:44 +01:00
Mark AndrewsandMichal Nowak 43c1e5be46 Unify whitespace in bin/tests/system/run.sh
Replace tabs with spaces to make whitespace consistent across the entire
bin/tests/system/run.sh script.

(cherry picked from commit 0f0a006c)
2020-11-26 18:21:05 +01:00
Tinderbox UserandMichał Kępień 66faf3215c prep 9.11.25 2020-11-26 12:33:58 +01:00
Havard EidnesandMichal Nowak e73d2f6bbe Avoid a non-standard bashism: use of "==" in "test".
(cherry picked from commit 1f83daa4ac)
2020-11-10 14:13:57 +01:00
Mark Andrews 1b8b355ec5 Add CHANGES note for [GL #2236]
(cherry picked from commit decf117eb6)
2020-10-30 09:08:44 +11:00
Mark Andrews 8d2e091d46 Check that a zone in the process of being signed resolves
ans10 simulates a local anycast server which has both signed and
unsigned instances of a zone.  'A' queries get answered from the
signed instance.  Everything else gets answered from the unsigned
instance.  The resulting answer should be insecure.

(cherry picked from commit d7840f4b93)
2020-10-30 08:25:34 +11:00
Evan Hunt c94559480e fix a typo in rpz test
"tcp-only" was not being tested correctly in the RPZ system test
because the option to the "digcmd" function that causes queries to
be sent via TCP was misspelled in one case, and was being interpreted
as a query name.

the "ckresult" function has also been changed to be case sensitive
for consistency with "digcmd".

(cherry picked from commit 78af071c11)
2020-10-28 22:42:37 -07:00
Michal Nowak 523050f054 Fix system test backtrace generation on OpenBSD
On Linux core dump contains absolute path to crashed binary

    Core was generated by `/home/newman/isc/ws/bind9/bin/named/.libs/lt-named -D glue-ns1 -X named.lock -m'.

However, on OpenBSD there's only a basename

    Core was generated by `named'.

This commit adds support for the latter, retains the former.

(cherry picked from commit f0b13873a3)
(cherry picked from commit 659feff963)
2020-10-26 16:58:30 +01:00
Diego Fronza 29043867c7 Update copyrights 2020-10-26 10:45:27 -03:00
Diego Fronza 4fef8acbfa Adjusted additional system test (NS, non-root zone)
After the updates from this branch, BIND now sends glue records for
NS queries even when configured with minimal-responses yes.
2020-10-26 10:45:27 -03:00
Diego Fronza acef95ce44 Added test for the proposed fix
This test is very simple, two nameserver instances are created:
    - ns4: master, with 'minimal-responses yes', authoritative
        for example. zone
    - ns5: slave, stub zone

The first thing verified is the transfer of zone data from master
to slave, which should be saved in ns5/example.db.

After that, a query is issued to ns5 asking for target.example.
TXT, a record present in the master database with the "test" string
as content.

If that query works, it means stub zone successfully request
nameserver addresses from master, ns4.example. A/AAAA

The presence of both A/AAAA records for ns4 is also verified in the
stub zone local file, ns5/example.db.
2020-10-26 10:45:27 -03:00
Diego Fronza 07564aedcf Always return address records in additional section for NS queries 2020-10-26 10:45:27 -03:00
Michal Nowak e0af53ac0f Ensure use of "echo_i" where possible
In many instances 'echo "I:' construct was used where echo_i function
should have been.
2020-10-22 12:16:24 +02:00
Diego Fronza 0cd414a390 Fix dnstap system test on FreeBSD
This commit ensures that dnstap output files captured
by fstrm_capture are properly flushed before any attempt
on reading them with dnstap-read is done.

By reading fstrm-capture source code it was noticed that
signal SIGHUP is used to flush the capture file.
2020-10-20 10:39:48 -03:00
Mark Andrews 140659c57a Drop the expected minimum number of buckets to 4.
The previous value of 5 produced too many false errors.

(cherry picked from commit 0abb49034e)
2020-10-15 12:32:26 +11:00
Mark Andrews 96399960c1 Try to improve rrl timing
Add a +burst option to mdig so that we have a second to setup the
mdig calls then they run at the start of the next second.

RRL uses 'queries in a second' as a approximation to
'queries per second'. Getting the bursts of traffic to all happen in
the same second should prevent false negatives in the system test.

We now have a second to setup the traffic in.  Then the traffic should
be sent at the start of the next second.  If that still fails we
should move to +burst=<now+2> (further extend mdig) instead of the
implicit <now+1> as the trigger second.

(cherry picked from commit 92cdc7b6c7)
2020-10-15 11:47:08 +11:00
Michal Nowak d7ea583ad0 Bring back --rpz-log-qtype-qclass feature-test option
It was unintentionally removed during a backport.
2020-10-07 11:24:16 +02:00
Ondřej SurýandOndřej Surý d7b16b780f Adjust legacy tests for default 1232 EDNS Buffer Size
* legacy test was just expecting default server EDNS buffer size to be 4096,
  the test needed the adjustment to reset the buffer sizes back to 4096.
2020-10-06 09:34:49 +02:00
Ondřej Surý 3ab08cdaa4 Adjust digdelv tests for default 1232 EDNS Buffer Size
* digdelv test was just expecting default server EDNS buffer size to be
  4096, the test needed only slight adjustment

(cherry picked from commit f1556f8c41)
(cherry picked from commit 6b303721f1ee472dc8ab2d1df03191a98d4e4e5e)
2020-10-05 17:00:24 +02:00
Ondřej Surý c164c9a819 Change the default ENDS buffer size to 1232 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 minimal
required changes by changing the defaults for `edns-udp-size`,
`max-udp-size` and `nocookie-udp-size` to `1232` (the value picked by
DNS Flag Day 2020).

(cherry picked from commit bb990030d3)
(cherry picked from commit df06773f9a73e4a4bb0b5e7f4bd8e40394e64032)
2020-10-05 16:54:39 +02:00
Diego FronzaandOndřej Surý 79c62017eb 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 resquery_response(), 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 add_bad() 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.
2020-09-30 14:04:04 +02:00
Diego FronzaandOndřej Surý 8781aef52e 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.
2020-09-30 13:33:43 +02:00
Mark Andrews d95a18711b Break lock order loop by sending TAT in an event
The dotat() function has been changed to send the TAT
query asynchronously, so there's no lock order loop
because we initialize the data first and then we schedule
the TAT send to happen asynchronously.

This breaks following lock-order loops:

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

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

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

(cherry picked from commit 3c4b68af7c)
2020-09-22 23:35:39 +10:00
Mark Andrews 7247df0fcf 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

(cherry picked from commit 0450acc1b6)
2020-09-17 20:06:27 +10:00
Tinderbox UserandMichał Kępień e7b0d5de15 prep 9.11.23 2020-09-16 23:00:15 +02:00
Evan Hunt 400171aee8 update all copyright headers to eliminate the typo 2020-09-14 17:00:40 -07:00
Mark Andrews e5ecb7f57d Wait for test instance of named to exit before completing subtest.
(cherry picked from commit dda5b7b0b8)
2020-09-10 20:41:00 +10:00
Mark Andrews 6dcdee08e9 Don't use production address (127.0.0.1) in runtime system test.
(cherry picked from commit 1f14705938)
2020-09-10 20:21:03 +10:00
Mark Andrews dc30a355bd Also wait for 'zone_dump: zone example/IN: enter'
use nextpartpeek as we don't want to reset the starting point

(cherry picked from commit 7b65bea6d2)
2020-09-10 18:48:52 +10:00
Mark Andrews ed0cb2e9e4 Use ns_g_server->recursionquota instead of client->recursionquota
as the later will be NULL on ISC_R_QUOTA.

*** CID 306732:  Null pointer dereferences  (FORWARD_NULL)
/bin/named/query.c: 4359 in query_recurse()
4353     			static _Atomic(isc_stdtime_t) last = 0;
4354     #else
4355     			static isc_stdtime_t last = 0;
4356     #endif
4357     			isc_stdtime_t now;
4358     			isc_stdtime_get(&now);
   CID 306732:  Null pointer dereferences  (FORWARD_NULL)
   Passing "client" to "log_quota", which dereferences null "client->recursionquota".
4359     			log_quota(client, &last, now,
4360     				  "no more recursive clients (%d/%d/%d): %s",
4361     				  isc_result_totext(result));
4362     			ns_client_killoldestquery(client);
4363     		}
4364     		if (result == ISC_R_SUCCESS && !client->mortal &&

** CID 306731:  Program hangs  (LOCK)
/lib/dns/resolver.c: 8943 in spillattimer_countdown()
2020-09-09 06:01:54 +00:00
Mark Andrews d6c727d669 ISC_QUEUE_POP is not tsan safe. Suppress warnings
ret->link.next is tested to see if it is NULL unlocked
to avoid obtaining taillock when it is not nexessary then
retested once the taillock is obtained.
2020-09-08 17:41:33 +10:00
Mark Andrews 6d9b1ed70c Address data race over query_recurse.last
WARNING: ThreadSanitizer: data race
  Read of size 4 at 0x000000000001 by thread T1:
    #0 query_recurse bin/named/query.c:4291:15
    #1 query_find bin/named/query.c
    #2 ns_query_start bin/named/query.c:9675:8
    #3 client_request bin/named/client.c:3133:3
    #4 dispatch lib/isc/task.c:1157:7
    #5 run lib/isc/task.c:1331:2

  Previous write of size 4 at 0x000000000001 by thread T2:
    #0 query_recurse bin/named/query.c:4292:10
    #1 query_find bin/named/query.c
    #2 ns_query_start bin/named/query.c:9675:8
    #3 client_request bin/named/client.c:3133:3
    #4 dispatch lib/isc/task.c:1157:7
    #5 run lib/isc/task.c:1331:2

  Location is global 'query_recurse.last' of size 4 at 0x000000000001
2020-09-08 09:25:43 +10:00
Mark Andrews 72cbe648c4 Test if linked while holding the queue lock
WARNING: ThreadSanitizer: data race
  Read of size 8 at 0x000000000001 by thread T1:
    #0 client_shutdown bin/named/client.c:849:6
    #1 dispatch lib/isc/task.c:1157:7
    #2 run lib/isc/task.c:1331:2

  Previous write of size 8 at 0x000000000001 by thread T2 (mutexes: write M1, write M2):
    #0 client_shutdown bin/named/client.c:850:3
    #1 dispatch lib/isc/task.c:1157:7
    #2 run lib/isc/task.c:1331:2
2020-09-08 09:25:43 +10:00
Mark Andrews be4ed41611 Obtain a lock on the quota structure.
WARNING: ThreadSanitizer: data race (pid=15228)
  Read of size 4 at 0x7b5c00000444 by thread T8:
    #0 ns_server_status /builds/isc-projects/bind9/bin/named/./server.c:10935:31 (named+0x514671)
    #1 ns_control_docommand /builds/isc-projects/bind9/bin/named/control.c:263:12 (named+0x4e4726)
    #2 control_recvmessage /builds/isc-projects/bind9/bin/named/controlconf.c:465:13 (named+0x4e9046)
    #3 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x50845)
    #4 run /builds/isc-projects/bind9/lib/isc/task.c:1331:2 (libisc.so.1107+0x4d799)

  Previous write of size 4 at 0x7b5c00000444 by thread T9 (mutexes: write M1082):
    #0 isc_quota_release /builds/isc-projects/bind9/lib/isc/quota.c:73:13 (libisc.so.1107+0x3bf10)
    #1 isc_quota_detach /builds/isc-projects/bind9/lib/isc/quota.c:111:2 (libisc.so.1107+0x3c12b)
    #2 ns_client_endrequest /builds/isc-projects/bind9/bin/named/client.c:896:3 (named+0x4dcad1)
    #3 exit_check /builds/isc-projects/bind9/bin/named/client.c:512:3 (named+0x4d570d)
    #4 ns_client_detach /builds/isc-projects/bind9/bin/named/client.c:3687:8 (named+0x4d7732)
    #5 query_find /builds/isc-projects/bind9/bin/named/query.c (named+0x4f8ff1)
    #6 query_resume /builds/isc-projects/bind9/bin/named/query.c:4164:12 (named+0x509b38)
    #7 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x50845)
    #8 run /builds/isc-projects/bind9/lib/isc/task.c:1331:2 (libisc.so.1107+0x4d799)
2020-09-08 09:25:43 +10:00
Mark Andrews 818520216d Missing locks in ns_lwresd_shutdown.
WARNING: ThreadSanitizer: data race
  Read of size 8 at 0x000000000001 by main thread:
    #0 ns_lwresd_shutdown bin/named/lwresd.c:885:3
    #1 destroy_managers bin/named/./main.c:938:2
    #2 cleanup bin/named/./main.c:1346:2
    #3 main bin/named/./main.c:1594:2

  Previous write of size 8 at 0x000000000001 by thread T1 (mutexes: write M1):
    #0 configure_listener bin/named/lwresd.c:768:2
    #1 ns_lwresd_configure bin/named/lwresd.c:836:5
    #2 load_configuration bin/named/./server.c:8230:2
    #3 run_server bin/named/./server.c
    #4 dispatch lib/isc/task.c:1157:7
    #5 run lib/isc/task.c:1331:2
2020-09-08 09:25:43 +10:00
Mark Andrews 00d315046b Defer read of zl->server and zl->reconfig until
the reference counter has gone to zero and there is
nolonger a possibility of changes in other threads.
2020-09-08 09:25:43 +10:00
Mark Andrews a26d0c5ef3 Access ns_client_requests atomically 2020-09-08 09:25:43 +10:00
Mark Andrews 690f557b09 Don't run dyndb and dlzexternal if running TSAN as
the dlopen flags being used are incompatible with TSAN.

(cherry picked from commit 86316ed29d)
2020-09-08 08:46:14 +10:00
Mark Andrews b66b5a096c alphabetize tests/usage
(cherry picked from commit bbece7389e)
2020-09-08 08:43:45 +10:00
Mark Andrews b1c36e7818 Check 'deny name' + 'grant subdomain' for the same name
(cherry picked from commit a402ffbced)
2020-09-03 16:22:54 +10:00
Mark Andrews b2c93102de Increase zone load timeout in the "rndc" test
The "huge.zone" zone can take longer than 100 seconds to load when
running under a sanitizer.  Increase the relevant zone load timeout to
prevent intermittent failures of the "rndc" system test.

(cherry picked from commit fd08918df5)
2020-09-03 07:15:54 +10:00
Mark Andrews 46dc1c34f9 dig +bufsize=0 failed to disable EDNS as a side effect.
(cherry picked from commit 0dc04cb901)
2020-09-02 20:47:19 +10:00
Mark AndrewsandOndřej Surý c237ca4d43 Dump the returned packet 2020-09-02 08:54:40 +02:00
Ondřej Surý 36ec930560 Add -r <repeats> option to packet.pl
For some tests, we need to send big data streams (for TCP) or repeated
packets (for UDP), this commits adds `-r` option to packet.pl that sends
the same input <repeats> times using the specified protocol.

(cherry picked from commit dd46559a19)
2020-09-02 08:54:40 +02:00