Commit Graph

32904 Commits

Author SHA1 Message Date
Ondřej Surý
db49ffca20 Change the isc_nm_(get|set)timeouts() to work with milliseconds
The RFC7828 specifies the keepalive interval to be 16-bit, specified in
units of 100 milliseconds and the configuration options tcp-*-timeouts
are following the suit.  The units of 100 milliseconds are very
unintuitive and while we can't change the configuration and presentation
format, we should not follow this weird unit in the API.

This commit changes the isc_nm_(get|set)timeouts() functions to work
with milliseconds and convert the values to milliseconds before passing
them to the function, not just internally.
2021-03-18 15:16:13 +01:00
Ondřej Surý
5d0647e067 Merge the common parts between udp, tcpdns and tlsdns protocol
The udp, tcpdns and tlsdns contained lot of cut&paste code or code that
was very similar making the stack harder to maintain as any change to
one would have to be copied to the the other protocols.

In this commit, we merge the common parts into the common functions
under isc__nm_<foo> namespace and just keep the little differences based
on the socket type.
2021-03-18 15:16:13 +01:00
Ondřej Surý
a017ba2615 Fix TCPDNS and TLSDNS timers
After the TCPDNS refactoring the initial and idle timers were broken and
only the tcp-initial-timeout was always applied on the whole TCP
connection.

This broke any TCP connection that took longer than tcp-initial-timeout,
most often this would affect large zone AXFRs.

This commit changes the timeout logic in this way:

  * On TCP connection accept the tcp-initial-timeout is applied
    and the timer is started
  * When we are processing and/or sending any DNS message the timer is
    stopped
  * When we stop processing all DNS messages, the tcp-idle-timeout
    is applied and the timer is started again
2021-03-18 15:16:13 +01:00
Ondřej Surý
94a32eaf29 Add TCP timeouts system test
The system tests were missing a test that would test tcp-initial-timeout
and tcp-idle-timeout.

This commit adds new "timeouts" system test that adds:

  * Test that waits longer than tcp-initial-timeout and then checks
    whether the socket was closed

  * Test that sends and receives DNS message then waits longer than
    tcp-initial-timeout but shorter time than tcp-idle-timeout than
    sends DNS message again than waits longer than tcp-idle-timeout
    and checks whether the socket was closed

  * Similar test, but bursting 25 DNS messages than waiting longer than
    tcp-initial-timeout and shorter than tcp-idle-timeout than do second
    25 DNS message burst

  * Check whether transfer longer than tcp-initial-timeout succeeds
2021-03-18 15:16:13 +01:00
Mark Andrews
30f749cdf3 Merge branch '2580-does-not-compile-without-deprecated-openssl-apis-v9_16' into 'v9_16'
Stop using deprecated calls in lib/isc/tls.c

See merge request isc-projects/bind9!4815
2021-03-17 23:39:13 +00:00
Mark Andrews
3f9d7227b3 Stop using deprecated calls in lib/isc/tls.c
from Rosen Penev @neheb

(cherry picked from commit a9f883cbc2)
2021-03-18 10:15:44 +11:00
Matthijs Mekking
bcfdb0a6f6 Merge branch '2523-thaw-dnssec-policy-zone-v9_16' into 'v9_16'
Resolve "Unable to thaw a frozen dynamic zone when KASP is configured."

See merge request isc-projects/bind9!4811
2021-03-17 10:56:19 +00:00
Matthijs Mekking
937e10a5f4 Add test for thaw dynamic kasp zone
Add a test for freezing, manually updating, and then thawing a dynamic
zone with "dnssec-policy". In the kasp system test we add parameters
to the "update_is_signed" check to signal the indicated IP addresses
for the labels "a" and "d". If set to '-', the test is skipped.

After nsupdating the dynamic.kasp zone, we revert the update (with
nsupdate) and update the zone again, but now with the freeze/thaw
approach.

(cherry picked from commit 0cae3249e3)
2021-03-17 11:12:48 +01:00
Matthijs Mekking
1a29d7ae7d Fully sign a thawed zone
When thawing a zone, we don't know what changes have been made. If we
do DNSSEC maintenance on this zone, schedule a full sign.

(cherry picked from commit b90846f222)
2021-03-17 11:12:39 +01:00
Matthijs Mekking
3ae16d0480 Fix "unable to thaw dynamic kasp zone"
Dynamic zones with dnssec-policy could not be thawed because KASP
zones were considered always dynamic. But a dynamic KASP zone should
also check whether updates are disabled.

(cherry picked from commit b518ed9f46)
2021-03-17 11:12:29 +01:00
Matthijs Mekking
aba7f9856b Merge branch '2561-dnssec-guide-signing-type-v9_16' into 'v9_16'
Fix typo in DNSSEC Guide

See merge request isc-projects/bind9!4808
2021-03-17 08:00:06 +00:00
Matthijs Mekking
8bcb642049 Fix typo in DNSSEC Guide
The "dnssec-policy" example should say "keys" instead of "key".

(cherry picked from commit d45af8877a)
2021-03-16 14:38:25 +01:00
Mark Andrews
17e7f3643f Merge branch '2569-nsupdate-on-solaris-produces-different-failure-text-than-expected-v9_16' into 'v9_16'
Ignore the actual error code returned by getaddrinfo

See merge request isc-projects/bind9!4805
2021-03-16 00:37:51 +00:00
Mark Andrews
8dc5d63e1d Ignore the actual error code returned by getaddrinfo
when testing if interactive mode continues or not on
invalid hostname.  We only need to detect that getaddrinfo
failed and that we continued or not.

(cherry picked from commit 25d1276170)
2021-03-16 11:12:47 +11:00
Michal Nowak
9d9f8e4436 Merge branch '2565-servestale-fetchlimits-crash-v9_16' into 'v9_16'
[v9_16] Fix servestale fetchlimits crash

See merge request isc-projects/bind9!4798
2021-03-11 13:16:54 +00:00
Matthijs Mekking
96953fc293 Fix servestale fetchlimits crash
When we query the resolver for a domain name that is in the same zone
for which is already one or more fetches outstanding, we could
potentially hit the fetch limits. If so, recursion fails immediately
for the incoming query and if serve-stale is enabled, we may try to
return a stale answer.

If the resolver is also is authoritative for the parent zone (for
example the root zone), first a delegation is found, but we first
check the cache for a better response.

Nothing is found in the cache, so we try to recurse to find the
answer to the query.

Because of fetch-limits 'dns_resolver_createfetch()' returns an error,
which 'ns_query_recurse()' propagates to the caller,
'query_delegation_recurse()'.

Because serve-stale is enabled, 'query_usestale()' is called,
setting 'qctx->db' to the cache db, but leaving 'qctx->version'
untouched. Now 'query_lookup()' is called to search for stale data
in the cache database with a non-NULL 'qctx->version'
(which is set to a zone db version), and thus we hit an assertion
in rbtdb.

This crash was introduced in 'v9_16' by commit
2afaff75ed.

(cherry picked from commit 87591de6f7)
2021-03-11 13:47:20 +01:00
Michał Kępień
f31291d885 Merge branch '2556-fix-documentation-for-the-max-ixfr-ratio-option-v9_16' into 'v9_16'
[v9_16] Fix documentation for the "max-ixfr-ratio" option

See merge request isc-projects/bind9!4790
2021-03-08 11:35:32 +00:00
Michał Kępień
f78ce6ebb4 Fix documentation for the "max-ixfr-ratio" option
Commit 9fb6d11abb (which converted BIND 9
documentation from DocBook to Sphinx) inadvertently removed a paragraph
from the description of the "max-ixfr-ratio" option.  Add the missing
paragraph back.

(cherry picked from commit 3878cf4ac5)
2021-03-08 12:29:10 +01:00
Ondřej Surý
5207d07852 Merge branch '2555-workaround-truncated-64-bit-enum-in-journal-on-windows-v9_16' into 'v9_16'
Resolve "journal test fails on Windows"

See merge request isc-projects/bind9!4786
2021-03-08 09:45:27 +00:00
Evan Hunt
401642cbb4 fix automatic journal upgrade on windows
- use a value less than 2^32 for DNS_ZONEFLG_FIXJOURNAL; a larger value
  could cause problems in some build environments. the zone flag
  DNS_ZONEFLG_DIFFONRELOAD, which was no longer in use, has now been
  deleted and its value reused for _FIXJOURNAL.

(cherry picked from commit 990dd9dbff)
2021-03-08 09:43:00 +01:00
Evan Hunt
2aed5c5954 add start and end serial numbers to 'named-printjournal -x'
add the starting and ending serial number from the journal
header to the output of dns_journal_print().

(cherry picked from commit 46c11726d4)
2021-03-08 09:43:00 +01:00
Mark Andrews
b5aaacf77a Merge branch '2559-cid-329159-logically-dead-code-in-lib-dns-journal-c-v9_16' into 'v9_16'
Silence CID 329159: Logically dead code in lib/dns/journal.c

See merge request isc-projects/bind9!4783
2021-03-08 07:20:27 +00:00
Mark Andrews
898e9989f9 Silence CID 329159: Logically dead code in lib/dns/journal.c
*** CID 329159:    (DEADCODE)
    /lib/dns/journal.c: 1719 in dns_journal_print()
    1713     		}
    1714     		CHECK(dns_difftuple_create(
    1715     			diff.mctx, n_soa == 1 ? DNS_DIFFOP_DEL : DNS_DIFFOP_ADD,
    1716     			name, ttl, rdata, &tuple));
    1717     		dns_diff_append(&diff, &tuple);
    1718
    >>>     CID 329159:    (DEADCODE)
    >>>     Execution cannot reach the expression "printxhdr" inside this statement: "if (++n_put != 0U || printx...".
    1719     		if (++n_put != 0 || printxhdr) {
    1720     			result = dns_diff_print(&diff, file);
    1721     			dns_diff_clear(&diff);
    1722     			n_put = 0;
    1723     			if (result != ISC_R_SUCCESS) {
    1724     				break;
    /lib/dns/journal.c: 1734 in dns_journal_print()
    1728     	if (result == ISC_R_NOMORE) {
    1729     		result = ISC_R_SUCCESS;
    1730     	}
    1731     	CHECK(result);
    1732
    1733     	if (!printxhdr && n_put != 0) {
    >>>     CID 329159:    (DEADCODE)
    >>>     Execution cannot reach this statement: "result = dns_diff_print(&di...".
    1734     		result = dns_diff_print(&diff, file);
    1735     		dns_diff_clear(&diff);
    1736     	}
    1737     	goto cleanup;
    1738
    1739     failure:

(cherry picked from commit 848e336db4)
2021-03-08 16:44:43 +11:00
Mark Andrews
33c925476d Merge branch '2560-cid-329157-dereference-before-null-check-in-lib-dns-journal-c-v9_16' into 'v9_16'
Silence CID 329157: Dereference before null check in lib/dns/journal.c

See merge request isc-projects/bind9!4782
2021-03-08 05:43:12 +00:00
Mark Andrews
fb7e38cca2 Silence CID 329157: Dereference before null check in lib/dns/journal.c
*** CID 329157:  Null pointer dereferences  (REVERSE_INULL)
    /lib/dns/journal.c: 754 in journal_open()
    748     			    j->header.index_size * sizeof(journal_rawpos_t));
    749     	}
    750     	if (j->index != NULL) {
    751     		isc_mem_put(j->mctx, j->index,
    752     			    j->header.index_size * sizeof(journal_pos_t));
    753     	}
       CID 329157:  Null pointer dereferences  (REVERSE_INULL)
       Null-checking "j->filename" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
    754     	if (j->filename != NULL) {
    755     		isc_mem_free(j->mctx, j->filename);
    756     	}
    757     	if (j->fp != NULL) {
    758     		(void)isc_stdio_close(j->fp);
    759     	}

(cherry picked from commit 4054405909)
2021-03-08 16:12:01 +11:00
Ondřej Surý
ccb21b3f79 Merge branch '1529-add-threadsanitizer-core-dumping-flags-when-we-are-threadsanitizer-clean-v9_16' into 'v9_16'
Resolve "Add ThreadSanitizer core dumping flags when we are ThreadSanitizer-clean"

See merge request isc-projects/bind9!4775
2021-03-04 15:58:32 +00:00
Ondřej Surý
74c537adb9 Disable allow_failure for ThreadSanitizer jobs
Since the main branch is now TSAN-clean, it's a good opportunity to
enable hard failures for the TSAN system test jobs.

(cherry picked from commit 4072cc2b93)
2021-03-04 16:25:50 +01:00
Michal Nowak
13bf49fd5d Add ThreadSanitizer core dumping flags
This should let us have core dumps from crashed system test when
ThreadSanitizer is enabled.

(cherry picked from commit a730bc47f5)
2021-03-04 16:25:50 +01:00
Ondřej Surý
d714c48be0 Merge branch '2455-tcpdns_test-c-runtime-error-load-of-misaligned-address-for-type-uint64_t-v9_16' into 'v9_16'
Assigning uint64_t from buffer might be misaligned in netmgr tests

See merge request isc-projects/bind9!4773
2021-03-04 15:09:01 +00:00
Ondřej Surý
1c2e018962 Assigning uint64_t from buffer might be misaligned in netmgr tests
Resolve possible 8-byte unaligned access when assigning the magic
value from the received buffer.

(cherry picked from commit a55bdb28f9)
2021-03-04 15:29:44 +01:00
Ondřej Surý
c196779f53 Merge branch '2533-mdig-move-cleanup-v9_16' into 'v9_16'
Move cleanup of queries to later in the shutdown sequence

See merge request isc-projects/bind9!4772
2021-03-04 14:29:07 +00:00
Mark Andrews
ce5dc75e48 Move cleanup of queries to later in the shutdown sequence
to avoid TSAN report

    WARNING: ThreadSanitizer: data race
      Write of size 8 at 0x000000000001 by main thread:
        #0 free <null>
        #1 default_memfree lib/isc/mem.c:440
        #2 mem_put lib/isc/mem.c:363
        #3 isc__mem_free lib/isc/mem.c:1012
        #4 main bin/tools/mdig.c:2231

      Previous read of size 1 at 0x000000000005 by thread T1:
        #0 dns_name_fromtext lib/dns/name.c:1121
        #1 sendquery bin/tools/mdig.c:596
        #2 sendqueries bin/tools/mdig.c:779
        #3 dispatch lib/isc/task.c:1153
        #4 run lib/isc/task.c:1345
        #5 isc__trampoline_run lib/isc/trampoline.c:184
        #6 <null> <null>

      Thread T1 (running) created by main thread at:
        #0 pthread_create <null>
        #1 isc_thread_create pthreads/thread.c:79
        #2 isc_taskmgr_create lib/isc/task.c:1435
        #3 main bin/tools/mdig.c:2148

    SUMMARY: ThreadSanitizer: data race in __interceptor_free

(cherry picked from commit 4015af02d8)
2021-03-04 15:02:07 +01:00
Michal Nowak
d86578674e Merge branch '2357-add-CHANGES-entry-v9_16' into 'v9_16'
[v9_16] Add CHANGES entry for GL #2357

See merge request isc-projects/bind9!4771
2021-03-04 12:22:17 +00:00
Michal Nowak
588dae8e2b Add CHANGES entry for GL #2357
(cherry picked from commit d98f72de25)
2021-03-04 13:16:26 +01:00
Ondřej Surý
2f48007d18 Merge branch '2298-multiple-definition-of-librpz_dnsrpzd_path-v9_16' into 'v9_16'
Resolve "multiple definition of `librpz_dnsrpzd_path'"

See merge request isc-projects/bind9!4764
2021-03-04 11:00:12 +00:00
Mark Andrews
a33d603cff Add CHANGES for [GL #2298]
(cherry picked from commit e12cf5eb57)
2021-03-04 11:28:49 +01:00
Mark Andrews
985566fea5 Fixed librpz_dnsrpzd_path being a duplicate symbol
librpz_dnsrpzd_path should have been declared extern in dns/librpz.h

(cherry picked from commit 8f016dd57a)
2021-03-04 11:28:49 +01:00
Ondřej Surý
6f975dc810 Merge branch '2551-char-is-unsigned-on-arm64-v9_16' into 'v9_16'
Use int type to store result from isc_commandline_parse()

See merge request isc-projects/bind9!4767
2021-03-04 10:24:56 +00:00
Ondřej Surý
7a8193efba Use int type to store result from isc_commandline_parse()
The C standard actually doesn't define char as signed or unsigned, and
it could be either according to underlying architecture.  It turns out
that while it's usually signed type, it isn't on arm64 where it's
unsigned.

isc_commandline_parse() return int, just use that instead of the char.

(cherry picked from commit 8153729d3a)
2021-03-04 11:21:26 +01:00
Evan Hunt
31cbf73bd4 Merge branch '2505-journal-compatibility-v9_16' into 'v9_16'
allow dns_journal_rollforward() to read old journal files

See merge request isc-projects/bind9!4763
2021-03-04 04:13:21 +00:00
Evan Hunt
c7d5329ae0 CHANGES, release note
(cherry picked from commit 82b82bb821)
2021-03-03 19:21:19 -08:00
Evan Hunt
bda028e0ee create 'journal' system test
tests that version 1 journal files containing version 1 transaction
headers are rolled forward correctly on server startup, then updated
into version 2 journals. also checks journal file consistency and
'max-journal-size' behavior.

(cherry picked from commit a0aefa1de6)
2021-03-03 19:21:16 -08:00
Evan Hunt
9f1f5abe0e print journal index data and test for consistency
'named-journalprint -x' now prints the journal's index table and
the offset of each transaction in the journal, so that index consistency
can be confirmed.

(cherry picked from commit a4972324a6)
2021-03-03 19:19:50 -08:00
Mark Andrews
5aea511e1b extend named-journalprint to be able to force the journal version
named-journalprint can now upgrade or downgrade a journal file
in place; the '-u' option upgrades and the '-d' option downgrades.

(cherry picked from commit fb2d0e2897)
2021-03-03 19:19:50 -08:00
Evan Hunt
47a274e9f1 allow dns_journal_rollforward() to read old journal files
when the 'max-ixfr-ratio' option was added, journal transaction
headers were revised to include a count of RR's in each transaction.
this made it impossible to read old journal files after an upgrade.

this branch restores the ability to read version 1 transaction
headers. when rolling forward, printing journal contents, if
the wrong transaction header format is found, we can switch.

when dns_journal_rollforward() detects a version 1 transaction
header, it returns DNS_R_RECOVERABLE.  this triggers zone_postload()
to force a rewrite of the journal file in the new format, and
also to schedule a dump of the zone database with minimal delay.
journal repair is done by dns_journal_compact(), which rewrites
the entire journal, ignoring 'max-journal-size'. journal size is
corrected later.

newly created journal files now have "BIND LOG V9.2" in their headers
instead of "BIND LOG V9". files with the new version string cannot be
read using the old transaction header format. note that this means
newly created journal files will be rejected by older versions of named.

named-journalprint now takes a "-x" option, causing it to print
transaction header information before each delta, including its
format version.

(cherry picked from commit ee19966326)
2021-03-03 19:19:50 -08:00
Matthijs Mekking
079294bd28 Merge branch '2443-cid-316608-memory-corruptions-overrun-v9_16' into 'v9_16'
Address theoretical buffer overrun in recent change

See merge request isc-projects/bind9!4761
2021-03-03 10:34:26 +00:00
Mark Andrews
7a703244ed Address theoretical buffer overrun in recent change
The strlcat() call was wrong.

    *** CID 316608:  Memory - corruptions  (OVERRUN)
    /lib/dns/resolver.c: 5017 in fctx_create()
    5011     	 * Make fctx->info point to a copy of a formatted string
    5012     	 * "name/type".
    5013     	 */
    5014     	dns_name_format(name, buf, sizeof(buf));
    5015     	dns_rdatatype_format(type, typebuf, sizeof(typebuf));
    5016     	p = strlcat(buf, "/", sizeof(buf));
    >>>     CID 316608:  Memory - corruptions  (OVERRUN)
    >>>     Calling "strlcat" with "buf + p" and "1036UL" is suspicious because "buf" points into a buffer of 1036 bytes and the function call may access "(char *)(buf + p) + 1035UL". [Note: The source code implementation of the function has been overridden by a builtin model.]
    5017     	strlcat(buf + p, typebuf, sizeof(buf));
    5018     	fctx->info = isc_mem_strdup(mctx, buf);
    5019
    5020     	FCTXTRACE("create");
    5021     	dns_name_init(&fctx->name, NULL);
    5022     	dns_name_dup(name, mctx, &fctx->name);

(cherry picked from commit 59bf6e71e2)
2021-03-03 10:55:38 +01:00
Ondřej Surý
2cc4e15788 Merge branch 'ondrej/call-isc__initialize-shutdown-from-DllMain-v9_16' into 'v9_16'
Call isc__initialize()/isc__shutdown() from win32 DllMain

See merge request isc-projects/bind9!4760
2021-03-02 08:23:26 +00:00
Ondřej Surý
59d92c8af8 Call isc__initialize()/isc__shutdown() from win32 DllMain
Call the libisc isc__initialize() constructor and isc__shutdown()
destructor from DllMain instead of having duplicate code between
those and DllMain() code.

(cherry picked from commit a50f5d0cf5)
2021-03-02 08:50:29 +01:00
Ondřej Surý
5ab6d1b30e Merge branch '2396-add-thread-trampoline-for-thread-accounting-v9_16' into 'v9_16'
Resolve "BIND 9.16 unit tests failing reliably on x86_64 NUMA machines"

See merge request isc-projects/bind9!4756
2021-02-26 20:39:25 +00:00